@@ -79,7 +79,6 @@ mkdir "regress_log";
7979my $port_master =$ENV {PGPORT };
8080my $port_standby =$port_master + 1;
8181
82- my $log_path ;
8382my $tempdir_short ;
8483
8584my $connstr_master =" port=$port_master " ;
@@ -91,14 +90,16 @@ sub master_psql
9190{
9291my $cmd =shift ;
9392
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 " ;
9595}
9696
9797sub standby_psql
9898{
9999my $cmd =shift ;
100100
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 " ;
102103}
103104
104105# Run a query against the master, and check that the output matches what's
@@ -171,16 +172,6 @@ sub append_to_file
171172close $fh ;
172173}
173174
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-
184175sub setup_cluster
185176{
186177$tempdir_short = tempdir_short;
@@ -209,9 +200,10 @@ max_connections = 10
209200local replication all trust
210201) );
211202
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' );
215207
216208# ### Now run the test-specific parts to initialize the master before setting
217209# up standby
@@ -225,8 +217,8 @@ sub create_standby
225217remove_tree$test_standby_datadir ;
226218
227219# 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 ' );
230222append_to_file(
231223" $test_standby_datadir /recovery.conf" ,qq(
232224primary_conninfo='$connstr_master application_name=rewind_standby'
@@ -235,9 +227,9 @@ recovery_target_timeline='latest'
235227) );
236228
237229# 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 ' );
241233
242234# Wait until the standby has caught up with the primary, by polling
243235# pg_stat_replication.
@@ -255,8 +247,7 @@ sub promote_standby
255247# Now promote slave and insert some new data on master, this will put
256248# the master out-of-sync with the standby. Wait until the standby is
257249# 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' );
260251poll_query_until(" SELECT NOT pg_is_in_recovery()" ,$connstr_standby )
261252or die " Timed out while waiting for promotion of standby" ;
262253
@@ -274,8 +265,7 @@ sub run_pg_rewind
274265my $test_mode =shift ;
275266
276267# 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' );
279269
280270# At this point, the rewind processing is ready to run.
281271# We now have a very simple scenario with a few diverged WAL record.
@@ -291,35 +281,24 @@ sub run_pg_rewind
291281# Now run pg_rewind
292282if ($test_mode eq " local" )
293283{
294-
295284# Do rewind using a local pgdata as source
296285# 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' );
309293}
310294elsif ($test_mode eq " remote" )
311295{
312-
313296# 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' );
323302}
324303else
325304{
@@ -342,9 +321,9 @@ recovery_target_timeline='latest'
342321) );
343322
344323# 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 ' );
348327
349328# ### Now run the test-specific parts to check the result
350329}
@@ -355,12 +334,12 @@ sub clean_rewind_test
355334if ($test_master_datadir )
356335{
357336system
358- " pg_ctl -D $test_master_datadir -s -m immediate stop 2> /dev/null " ;
337+ ' pg_ctl' , ' -D ' , $test_master_datadir , ' -m ' , ' immediate' , ' stop' ;
359338}
360339if ($test_standby_datadir )
361340{
362341system
363- " pg_ctl -D $test_standby_datadir -s -m immediate stop 2> /dev/null " ;
342+ ' pg_ctl' , ' -D ' , $test_standby_datadir , ' -m ' , ' immediate' , ' stop' ;
364343}
365344}
366345