提交 a1d62a46 编写于 作者: A Ashwin Agrawal

pg_rewind: Avoid need for empty callback test function.

Melanie suggested usage of
`declare -F <function_name> > /dev/null && <function_name>` in pg_rewind test.

-F will return only the name of the function and then the error code will be
non-zero if it is not defined and then by and-ing it with the function
definition alone, that function will only run in run_test if it is defined. So,
this helps to avoid coding empty functions if the test doesn't wish to have any
implementation for the same.
Co-authored-by: NMelanie Plageman <mplageman@pivotal.io>
上级 97a76214
......@@ -10,12 +10,6 @@ TESTNAME=ao_rewind
. sql/config_test.sh
# Nothing to do here
function before_master
{
:
}
# Do an insert in master.
function before_standby
{
......
......@@ -10,12 +10,6 @@ TESTNAME=basictest
. sql/config_test.sh
# Nothing to do here
function before_master
{
:
}
# Do an insert in master.
function before_standby
{
......
......@@ -10,12 +10,6 @@ TESTNAME=databases
. sql/config_test.sh
# Nothing to do here
function before_master
{
:
}
# Create a database in master.
function before_standby
{
......
......@@ -12,12 +12,6 @@ TESTNAME=extrafiles
. sql/config_test.sh
# Nothing to do here
function before_master
{
:
}
# Create a subdir that will be present in both
function before_standby
{
......@@ -43,11 +37,6 @@ function standby_following_master
echo "in master3" > $TEST_MASTER/tst_master_dir/master_subdir/master_file3
}
function after_promotion
{
:
}
# See what files and directories are present after rewind.
function after_rewind
{
......
......@@ -49,13 +49,13 @@ EOF
#### Now run the test-specific parts to initialize the master before setting
echo "Master initialized."
before_master
declare -F before_master > /dev/null && before_master
pg_ctl -w -D $TEST_MASTER start -o "$MASTER_PG_CTL_OPTIONS" >>$log_path 2>&1
# up standby
echo "Master running."
before_standby
declare -F before_standby > /dev/null && before_standby
# Set up standby with necessary parameter
rm -rf $TEST_STANDBY
......@@ -76,7 +76,7 @@ pg_ctl -w -D $TEST_STANDBY start -o "$STANDBY_PG_CTL_OPTIONS" >>$log_path 2>&1
#### Now run the test-specific parts to run after standby has been started
# up standby
echo "Standby initialized and running."
standby_following_master
declare -F standby_following_master > /dev/null && standby_following_master
# sleep a bit to make sure the standby has caught up.
sleep 1
......@@ -95,7 +95,7 @@ wait_until_standby_is_promoted >>$log_path 2>&1
#### Now run the test-specific parts to run after promotion
echo "Standby promoted."
after_promotion
declare -F after_promotion > /dev/null && after_promotion
# For some tests, we want to stop the master after standby promotion
if [ "$STOP_MASTER_BEFORE_PROMOTE" != "true" ]; then
......@@ -168,7 +168,7 @@ pg_ctl -w -D $TEST_MASTER promote >>$log_path 2>&1
wait_until_master_is_promoted >>$log_path 2>&1
echo "Master promoted."
after_rewind
declare -F after_rewind > /dev/null && after_rewind
# Stop remaining servers
pg_ctl stop -D $TEST_MASTER -m fast -w >>$log_path 2>&1
......
......@@ -11,24 +11,6 @@ STOP_MASTER_BEFORE_PROMOTE=true
. sql/config_test.sh
# Nothing to do here
function before_master
{
:
}
# Nothing to do here
function before_standby
{
:
}
# Nothing to do here
function standby_following_master
{
:
}
# Run checkpoint to update Control File with new timeline ID
function after_promotion
{
......
......@@ -12,38 +12,10 @@ TESTNAME=unclean_shutdown
MASTER_PG_CTL_STOP_MODE="immediate"
# Nothing to do here
function before_master
{
:
}
# Nothing to do here
function before_standby
{
:
}
# Nothing to do here
function standby_following_master
{
:
}
# Nothing to do here
function after_promotion
{
:
}
# The old master was stopped with immediate mode which will cause unclean
# shutdown and leave "in production" in the control file. At the beginning of
# pg_rewind, a single-user mode postgres session should have been run to ensure
# clean shutdown on the target instance.
function after_rewind
{
:
}
# Run the test
. sql/run_test.sh
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册