Skip to content

Commit aaa3c1d

Browse files
committed
Load more data in smoke spec and cleanup
1 parent 4e581a3 commit aaa3c1d

File tree

3 files changed

+30
-14
lines changed

3 files changed

+30
-14
lines changed

docker-compose.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
version: "2"
22
services:
33
postgres:
4-
image: postgres:9.6.2-alpine
4+
image: postgres:14-alpine
55
ports:
66
- "5432:5432"
77
environment:
88
POSTGRES_USER: jamesbond
99
POSTGRES_DB: postgres
10+
POSTGRES_HOST_AUTH_METHOD: trust

spec/fixtures/bench.sql

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ BEGIN;
66
UPDATE pgbench_accounts SET abalance = abalance + :delta WHERE aid = :aid;
77
UPDATE pgbench_accounts_validate SET abalance = abalance + :delta WHERE aid = :aid;
88
SELECT abalance FROM pgbench_accounts WHERE aid = :aid;
9-
UPDATE pgbench_tellers SET tbalance = tbalance + :delta WHERE tid = :tid;
10-
UPDATE pgbench_branches SET bbalance = bbalance + :delta WHERE bid = :bid;
9+
-- UPDATE pgbench_tellers SET tbalance = tbalance + :delta WHERE tid = :tid;
10+
-- UPDATE pgbench_branches SET bbalance = bbalance + :delta WHERE bid = :bid;
1111
INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CURRENT_TIMESTAMP);
12-
END;
12+
END;

spec/lib/smoke_spec.rb

+25-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
# frozen_string_literal: true
22

3+
require 'English'
34
def log(msg)
45
puts "======= #{msg} ======="
56
end
67

78
def setup_pgbench_tables(foreign_keys:)
89
log("Setting up pgbench")
910
if foreign_keys
10-
`pgbench --initialize -s 10 --foreign-keys --host #{client.host} -U #{client.username} -d #{client.dbname}`
11+
`pgbench --initialize -s 100 --foreign-keys --host #{client.host} -U #{client.username} -d #{client.dbname}`
1112
else
12-
`pgbench --initialize -s 10 --host #{client.host} -U #{client.username} -d #{client.dbname}`
13+
`pgbench --initialize -s 100 --host #{client.host} -U #{client.username} -d #{client.dbname}`
1314
end
1415

1516
log("Setting up pgbench validate table")
@@ -81,23 +82,29 @@ def setup_pgbench_tables(foreign_keys:)
8182
fork do
8283
log("Running pgbench")
8384
exec(
84-
"pgbench --file spec/fixtures/bench.sql -T 60000 -c 5 --host #{client.host} -U #{client.username} -d #{client.dbname}",
85+
"pgbench --file spec/fixtures/bench.sql -T 600000 -c 15 --host #{client.host} -U #{client.username} -d #{client.dbname}",
8586
)
8687
end
8788
Process.detach(pid)
89+
sleep(10)
8890

8991
log("Running pg-osc")
9092
statement = <<~SCRIPT
91-
PGPASSWORD="#{client.password}" bundle exec bin/pg-online-schema-change perform \
93+
PGPASSWORD="#{client.password}" DEBUG=true bundle exec bin/pg-online-schema-change perform \
9294
-a 'ALTER TABLE pgbench_accounts ALTER COLUMN aid TYPE BIGINT' \
9395
-d #{client.dbname} \
9496
-h #{client.host} \
9597
-u #{client.username} \
9698
--drop
9799
SCRIPT
98-
result = `#{statement}`
100+
IO.popen(statement) do |io|
101+
io.each do |line|
102+
puts line
103+
output << line
104+
end
105+
end
99106

100-
expect(result).to match(/All tasks successfully completed/)
107+
expect(output.join(",")).to match(/All tasks successfully completed/)
101108
Process.kill("KILL", pid)
102109

103110
log("Comparing data between two tables")
@@ -137,23 +144,31 @@ def setup_pgbench_tables(foreign_keys:)
137144
fork do
138145
log("Running pgbench")
139146
exec(
140-
"pgbench --file spec/fixtures/bench.sql -T 60000 -c 5 --host #{client.host} -U #{client.username} -d #{client.dbname}",
147+
"pgbench --file spec/fixtures/bench.sql -T 600000 -c 15 --host #{client.host} -U #{client.username} -d #{client.dbname} >/dev/null 2>&1",
141148
)
142149
end
143150
Process.detach(pid)
144151

152+
sleep(10)
153+
145154
log("Running pg-osc")
146155
statement = <<~SCRIPT
147-
PGPASSWORD="#{client.password}" bundle exec bin/pg-online-schema-change perform \
156+
PGPASSWORD="#{client.password}" DEBUG=true bundle exec bin/pg-online-schema-change perform \
148157
-a 'ALTER TABLE pgbench_accounts ALTER COLUMN aid TYPE BIGINT' \
149158
-d #{client.dbname} \
150159
-h #{client.host} \
151160
-u #{client.username} \
152161
--drop
153162
SCRIPT
154-
result = `#{statement}`
163+
output = []
164+
IO.popen(statement) do |io|
165+
io.each do |line|
166+
puts line
167+
output << line
168+
end
169+
end
155170

156-
expect(result).to match(/All tasks successfully completed/)
171+
expect(output.join(",")).to match(/All tasks successfully completed/)
157172
Process.kill("KILL", pid)
158173

159174
log("Comparing data between two tables")

0 commit comments

Comments
 (0)