]> granicus.if.org Git - postgresql/commitdiff
Shut down test servers after pg_rewind regression tests.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Wed, 15 Apr 2015 16:54:38 +0000 (19:54 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Wed, 15 Apr 2015 16:54:38 +0000 (19:54 +0300)
Now that the test servers are initialized twice in each .pl script,
the single END block is not enough to stop them. Add a new clean_rewind_test
function that is called at the end of each test.

Michael Paquier

src/bin/pg_rewind/RewindTest.pm
src/bin/pg_rewind/t/001_basic.pl
src/bin/pg_rewind/t/002_databases.pl
src/bin/pg_rewind/t/003_extrafiles.pl

index 50cae2c2632b06d6493ba892d93884fe1bfa23b3..e6a5b9b3d955321588e306e7771f7a18a12bf9ee 100644 (file)
@@ -22,6 +22,9 @@ package RewindTest;
 # 5. run_pg_rewind - stops the old master (if it's still running) and runs
 # pg_rewind to synchronize it with the now-promoted standby server.
 #
+# 6. clean_rewind_test - stops both servers used in the test, if they're
+# still running.
+#
 # The test script can use the helper functions master_psql and standby_psql
 # to run psql against the master and standby servers, respectively. The
 # test script can also use the $connstr_master and $connstr_standby global
@@ -56,6 +59,7 @@ our @EXPORT = qw(
   create_standby
   promote_standby
   run_pg_rewind
+  clean_rewind_test
 );
 
 
@@ -262,9 +266,8 @@ recovery_target_timeline='latest'
 }
 
 # Clean up after the test. Stop both servers, if they're still running.
-END
+sub clean_rewind_test
 {
-       my $save_rc = $?;
        if ($test_master_datadir)
        {
                system "pg_ctl -D $test_master_datadir -s -m immediate stop 2> /dev/null";
@@ -273,5 +276,12 @@ END
        {
                system "pg_ctl -D $test_standby_datadir -s -m immediate stop 2> /dev/null";
        }
+}
+
+# Stop the test servers, just in case they're still running.
+END
+{
+       my $save_rc = $?;
+       clean_rewind_test();
        $? = $save_rc;
 }
index ae26d0129eadf930afd1f4122474867bbca819cc..a1d679f6b8fd5df9b0206dba952e3df64e10aef1 100644 (file)
@@ -78,6 +78,7 @@ in master, before promotion
 ),
                'tail-copy');
 
+       RewindTest::clean_rewind_test();
 }
 
 # Run the test in both modes
index 1cf9a3a65d3904fd04871f715b63d8d75bd2b049..be1e1948a7f76a0e8930ebef9b6596fe5d0d4d84 100644 (file)
@@ -40,6 +40,7 @@ standby_afterpromotion
 ),
                           'database names');
 
+       RewindTest::clean_rewind_test();
 }
 
 # Run the test in both modes.
index 218b865940c6f68a356c87f6296ae3792777805a..ed50659195b6e517c32ff444809f1059c3f38c74 100644 (file)
@@ -62,6 +62,8 @@ sub run_test
                           "$test_master_datadir/tst_standby_dir/standby_subdir",
                           "$test_master_datadir/tst_standby_dir/standby_subdir/standby_file3"],
                          "file lists match");
+
+       RewindTest::clean_rewind_test();
 }
 
 # Run the test in both modes.