|
1 | 1 | # frozen_string_literal: true
|
2 | 2 |
|
| 3 | +require 'English' |
3 | 4 | def log(msg)
|
4 | 5 | puts "======= #{msg} ======="
|
5 | 6 | end
|
6 | 7 |
|
7 | 8 | def setup_pgbench_tables(foreign_keys:)
|
8 | 9 | log("Setting up pgbench")
|
9 | 10 | 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}` |
11 | 12 | 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}` |
13 | 14 | end
|
14 | 15 |
|
15 | 16 | log("Setting up pgbench validate table")
|
@@ -81,23 +82,29 @@ def setup_pgbench_tables(foreign_keys:)
|
81 | 82 | fork do
|
82 | 83 | log("Running pgbench")
|
83 | 84 | 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}", |
85 | 86 | )
|
86 | 87 | end
|
87 | 88 | Process.detach(pid)
|
| 89 | + sleep(10) |
88 | 90 |
|
89 | 91 | log("Running pg-osc")
|
90 | 92 | 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 \ |
92 | 94 | -a 'ALTER TABLE pgbench_accounts ALTER COLUMN aid TYPE BIGINT' \
|
93 | 95 | -d #{client.dbname} \
|
94 | 96 | -h #{client.host} \
|
95 | 97 | -u #{client.username} \
|
96 | 98 | --drop
|
97 | 99 | 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 |
99 | 106 |
|
100 |
| - expect(result).to match(/All tasks successfully completed/) |
| 107 | + expect(output.join(",")).to match(/All tasks successfully completed/) |
101 | 108 | Process.kill("KILL", pid)
|
102 | 109 |
|
103 | 110 | log("Comparing data between two tables")
|
@@ -137,23 +144,31 @@ def setup_pgbench_tables(foreign_keys:)
|
137 | 144 | fork do
|
138 | 145 | log("Running pgbench")
|
139 | 146 | 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", |
141 | 148 | )
|
142 | 149 | end
|
143 | 150 | Process.detach(pid)
|
144 | 151 |
|
| 152 | + sleep(10) |
| 153 | + |
145 | 154 | log("Running pg-osc")
|
146 | 155 | 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 \ |
148 | 157 | -a 'ALTER TABLE pgbench_accounts ALTER COLUMN aid TYPE BIGINT' \
|
149 | 158 | -d #{client.dbname} \
|
150 | 159 | -h #{client.host} \
|
151 | 160 | -u #{client.username} \
|
152 | 161 | --drop
|
153 | 162 | 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 |
155 | 170 |
|
156 |
| - expect(result).to match(/All tasks successfully completed/) |
| 171 | + expect(output.join(",")).to match(/All tasks successfully completed/) |
157 | 172 | Process.kill("KILL", pid)
|
158 | 173 |
|
159 | 174 | log("Comparing data between two tables")
|
|
0 commit comments