@@ -79,7 +79,6 @@ mkdir "regress_log";
79
79
my $port_master = $ENV {PGPORT };
80
80
my $port_standby = $port_master + 1;
81
81
82
- my $log_path ;
83
82
my $tempdir_short ;
84
83
85
84
my $connstr_master = " port=$port_master " ;
@@ -91,14 +90,16 @@ sub master_psql
91
90
{
92
91
my $cmd = shift ;
93
92
94
- system_or_bail(" psql -q --no-psqlrc -d $connstr_master -c \" $cmd \" " );
93
+ system_or_bail ' psql' , ' -q' , ' --no-psqlrc' , ' -d' , $connstr_master ,
94
+ ' -c' , " $cmd " ;
95
95
}
96
96
97
97
sub standby_psql
98
98
{
99
99
my $cmd = shift ;
100
100
101
- system_or_bail(" psql -q --no-psqlrc -d $connstr_standby -c \" $cmd \" " );
101
+ system_or_bail ' psql' , ' -q' , ' --no-psqlrc' , ' -d' , $connstr_standby ,
102
+ ' -c' , " $cmd " ;
102
103
}
103
104
104
105
# Run a query against the master, and check that the output matches what's
@@ -171,16 +172,6 @@ sub append_to_file
171
172
close $fh ;
172
173
}
173
174
174
- sub init_rewind_test
175
- {
176
- my $testname = shift ;
177
- my $test_mode = shift ;
178
-
179
- $log_path = " regress_log/pg_rewind_log_${testname} _${test_mode} " ;
180
-
181
- remove_tree $log_path ;
182
- }
183
-
184
175
sub setup_cluster
185
176
{
186
177
$tempdir_short = tempdir_short;
@@ -209,9 +200,10 @@ max_connections = 10
209
200
local replication all trust
210
201
) );
211
202
212
- system_or_bail(
213
- " pg_ctl -w -D $test_master_datadir -o \" -k $tempdir_short --listen-addresses='' -p $port_master \" start >>$log_path 2>&1"
214
- );
203
+ system_or_bail(' pg_ctl' , ' -w' ,
204
+ ' -D' , $test_master_datadir ,
205
+ " -o" , " -k $tempdir_short --listen-addresses='' -p $port_master " ,
206
+ ' start' );
215
207
216
208
# ### Now run the test-specific parts to initialize the master before setting
217
209
# up standby
@@ -225,8 +217,8 @@ sub create_standby
225
217
remove_tree $test_standby_datadir ;
226
218
227
219
# Base backup is taken with xlog files included
228
- system_or_bail(
229
- " pg_basebackup -D $test_standby_datadir -p $port_master -x >> $log_path 2>&1 " );
220
+ system_or_bail(' pg_basebackup ' , ' -D ' , $test_standby_datadir ,
221
+ ' -p ' , $port_master , ' -x ' );
230
222
append_to_file(
231
223
" $test_standby_datadir /recovery.conf" , qq(
232
224
primary_conninfo='$connstr_master application_name=rewind_standby'
@@ -235,9 +227,9 @@ recovery_target_timeline='latest'
235
227
) );
236
228
237
229
# Start standby
238
- system_or_bail(
239
- " pg_ctl -w -D $test_standby_datadir -o \ " -k $tempdir_short --listen-addresses='' -p $port_standby \" start >> $log_path 2>&1 "
240
- );
230
+ system_or_bail(' pg_ctl ' , ' -w ' , ' -D ' , $test_standby_datadir ,
231
+ ' -o ' , " -k $tempdir_short --listen-addresses='' -p $port_standby " ,
232
+ ' start ' );
241
233
242
234
# Wait until the standby has caught up with the primary, by polling
243
235
# pg_stat_replication.
@@ -255,8 +247,7 @@ sub promote_standby
255
247
# Now promote slave and insert some new data on master, this will put
256
248
# the master out-of-sync with the standby. Wait until the standby is
257
249
# out of recovery mode, and is ready to accept read-write connections.
258
- system_or_bail(
259
- " pg_ctl -w -D $test_standby_datadir promote >>$log_path 2>&1" );
250
+ system_or_bail(' pg_ctl' , ' -w' , ' -D' , $test_standby_datadir , ' promote' );
260
251
poll_query_until(" SELECT NOT pg_is_in_recovery()" , $connstr_standby )
261
252
or die " Timed out while waiting for promotion of standby" ;
262
253
@@ -274,8 +265,7 @@ sub run_pg_rewind
274
265
my $test_mode = shift ;
275
266
276
267
# Stop the master and be ready to perform the rewind
277
- system_or_bail(
278
- " pg_ctl -w -D $test_master_datadir stop -m fast >>$log_path 2>&1" );
268
+ system_or_bail(' pg_ctl' , ' -D' , $test_master_datadir , ' stop' , ' -m' , ' fast' );
279
269
280
270
# At this point, the rewind processing is ready to run.
281
271
# We now have a very simple scenario with a few diverged WAL record.
@@ -291,35 +281,24 @@ sub run_pg_rewind
291
281
# Now run pg_rewind
292
282
if ($test_mode eq " local" )
293
283
{
294
-
295
284
# Do rewind using a local pgdata as source
296
285
# Stop the master and be ready to perform the rewind
297
- system_or_bail(
298
- " pg_ctl -w -D $test_standby_datadir stop -m fast >>$log_path 2>&1"
299
- );
300
- my $result = run(
301
- [ ' pg_rewind' ,
302
- " --debug" ,
303
- " --source-pgdata=$test_standby_datadir " ,
304
- " --target-pgdata=$test_master_datadir " ],
305
- ' >>' ,
306
- $log_path ,
307
- ' 2>&1' );
308
- ok($result , ' pg_rewind local' );
286
+ system_or_bail(' pg_ctl' , ' -D' , $test_standby_datadir , ' stop' ,
287
+ ' -m' , ' fast' );
288
+ command_ok([' pg_rewind' ,
289
+ " --debug" ,
290
+ " --source-pgdata=$test_standby_datadir " ,
291
+ " --target-pgdata=$test_master_datadir " ],
292
+ ' pg_rewind local' );
309
293
}
310
294
elsif ($test_mode eq " remote" )
311
295
{
312
-
313
296
# Do rewind using a remote connection as source
314
- my $result = run(
315
- [ ' pg_rewind' ,
316
- " --source-server" ,
317
- " port=$port_standby dbname=postgres" ,
318
- " --target-pgdata=$test_master_datadir " ],
319
- ' >>' ,
320
- $log_path ,
321
- ' 2>&1' );
322
- ok($result , ' pg_rewind remote' );
297
+ command_ok([' pg_rewind' ,
298
+ " --source-server" ,
299
+ " port=$port_standby dbname=postgres" ,
300
+ " --target-pgdata=$test_master_datadir " ],
301
+ ' pg_rewind remote' );
323
302
}
324
303
else
325
304
{
@@ -342,9 +321,9 @@ recovery_target_timeline='latest'
342
321
) );
343
322
344
323
# Restart the master to check that rewind went correctly
345
- system_or_bail(
346
- " pg_ctl -w -D $test_master_datadir -o \ " -k $tempdir_short --listen-addresses='' -p $port_master \" start >> $log_path 2>&1 "
347
- );
324
+ system_or_bail(' pg_ctl ' , ' -w ' , ' -D ' , $test_master_datadir ,
325
+ ' -o ' , " -k $tempdir_short --listen-addresses='' -p $port_master " ,
326
+ ' start ' );
348
327
349
328
# ### Now run the test-specific parts to check the result
350
329
}
@@ -355,12 +334,12 @@ sub clean_rewind_test
355
334
if ($test_master_datadir )
356
335
{
357
336
system
358
- " pg_ctl -D $test_master_datadir -s -m immediate stop 2> /dev/null " ;
337
+ ' pg_ctl' , ' -D ' , $test_master_datadir , ' -m ' , ' immediate' , ' stop' ;
359
338
}
360
339
if ($test_standby_datadir )
361
340
{
362
341
system
363
- " pg_ctl -D $test_standby_datadir -s -m immediate stop 2> /dev/null " ;
342
+ ' pg_ctl' , ' -D ' , $test_standby_datadir , ' -m ' , ' immediate' , ' stop' ;
364
343
}
365
344
}
366
345
0 commit comments