# 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
create_standby
promote_standby
run_pg_rewind
+ clean_rewind_test
);
}
# 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";
{
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;
}
"$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.