diff --git a/src/test/binary_swap/.gitignore b/src/test/binary_swap/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..32e02b0b4839482ff276982854d0e34e27dcf569 --- /dev/null +++ b/src/test/binary_swap/.gitignore @@ -0,0 +1,5 @@ +results +regression.out +regression.diffs +dump_current.sql +dump_other.sql diff --git a/src/test/binary_swap/expected/diff_dumps.out b/src/test/binary_swap/expected/diff_dumps.out new file mode 100644 index 0000000000000000000000000000000000000000..80c56283bb0445cd18373fef5ef32a623c66a753 --- /dev/null +++ b/src/test/binary_swap/expected/diff_dumps.out @@ -0,0 +1 @@ +\! diff dump_other.sql dump_current.sql diff --git a/src/test/binary_swap/expected/gpcheckcat.out b/src/test/binary_swap/expected/gpcheckcat.out new file mode 100644 index 0000000000000000000000000000000000000000..8649b138003e8cb988a0fcc07e8a346e38ac424e --- /dev/null +++ b/src/test/binary_swap/expected/gpcheckcat.out @@ -0,0 +1,5 @@ +-- start_ignore +\! gpcheckcat binary_swap +-- end_ignore +\! echo $? +0 diff --git a/src/test/binary_swap/expected/inserts.out b/src/test/binary_swap/expected/inserts.out new file mode 100644 index 0000000000000000000000000000000000000000..f0a377960a4d55c2108c27d33a063e374460c2c8 --- /dev/null +++ b/src/test/binary_swap/expected/inserts.out @@ -0,0 +1,6 @@ +\c regression +-- Insert into tables generated from src/test/regress +-- Following tables from freeze_aux_tables: +INSERT INTO test_table_heap_with_toast SELECT i, i*2, i*5 FROM generate_series(1, 20)i; +INSERT INTO test_table_ao_with_toast SELECT * FROM test_table_heap_with_toast; +INSERT INTO test_table_co_with_toast SELECT * FROM test_table_heap_with_toast; diff --git a/src/test/binary_swap/expected/pg_dumpall_current.out b/src/test/binary_swap/expected/pg_dumpall_current.out new file mode 100644 index 0000000000000000000000000000000000000000..4277056259ae0c7735c3eb0ccae9f66a8cca4669 --- /dev/null +++ b/src/test/binary_swap/expected/pg_dumpall_current.out @@ -0,0 +1,3 @@ +\! pg_dumpall -f dump_current.sql +\! echo $? +0 diff --git a/src/test/binary_swap/expected/pg_dumpall_other.out b/src/test/binary_swap/expected/pg_dumpall_other.out new file mode 100644 index 0000000000000000000000000000000000000000..78d4e9c4f64f99df30c1c644c48824d6387a6506 --- /dev/null +++ b/src/test/binary_swap/expected/pg_dumpall_other.out @@ -0,0 +1,3 @@ +\! pg_dumpall -f dump_other.sql +\! echo $? +0 diff --git a/src/test/binary_swap/schedule1 b/src/test/binary_swap/schedule1 new file mode 100644 index 0000000000000000000000000000000000000000..4cbb52c1157ad0bc8fb04a467ad7bb01950d265d --- /dev/null +++ b/src/test/binary_swap/schedule1 @@ -0,0 +1,2 @@ +test: pg_dumpall_current +test: gpcheckcat diff --git a/src/test/binary_swap/schedule2 b/src/test/binary_swap/schedule2 new file mode 100644 index 0000000000000000000000000000000000000000..0114ac3db5320f200cc50b5b5ae64aa5bf39fe98 --- /dev/null +++ b/src/test/binary_swap/schedule2 @@ -0,0 +1,5 @@ +test: pg_dumpall_other +test: diff_dumps +test: inserts +test: pg_dumpall_other +test: gpcheckcat diff --git a/src/test/binary_swap/schedule3 b/src/test/binary_swap/schedule3 new file mode 100644 index 0000000000000000000000000000000000000000..c990dd5992c1cf614498c2224e618e4e7a4e4eed --- /dev/null +++ b/src/test/binary_swap/schedule3 @@ -0,0 +1,5 @@ +test: pg_dumpall_current +test: diff_dumps +test: inserts +test: pg_dumpall_current +test: gpcheckcat diff --git a/src/test/binary_swap/sql/diff_dumps.sql b/src/test/binary_swap/sql/diff_dumps.sql new file mode 100644 index 0000000000000000000000000000000000000000..80c56283bb0445cd18373fef5ef32a623c66a753 --- /dev/null +++ b/src/test/binary_swap/sql/diff_dumps.sql @@ -0,0 +1 @@ +\! diff dump_other.sql dump_current.sql diff --git a/src/test/binary_swap/sql/gpcheckcat.sql b/src/test/binary_swap/sql/gpcheckcat.sql new file mode 100644 index 0000000000000000000000000000000000000000..5469aa55c33797dadde521f6fedf4e904b7122bb --- /dev/null +++ b/src/test/binary_swap/sql/gpcheckcat.sql @@ -0,0 +1,5 @@ +-- start_ignore +\! gpcheckcat binary_swap +-- end_ignore + +\! echo $? diff --git a/src/test/binary_swap/sql/inserts.sql b/src/test/binary_swap/sql/inserts.sql new file mode 100644 index 0000000000000000000000000000000000000000..7b9ea0880ee0ef9aac2df43fa816f05ef097b064 --- /dev/null +++ b/src/test/binary_swap/sql/inserts.sql @@ -0,0 +1,7 @@ +\c regression + +-- Insert into tables generated from src/test/regress +-- Following tables from freeze_aux_tables: +INSERT INTO test_table_heap_with_toast SELECT i, i*2, i*5 FROM generate_series(1, 20)i; +INSERT INTO test_table_ao_with_toast SELECT * FROM test_table_heap_with_toast; +INSERT INTO test_table_co_with_toast SELECT * FROM test_table_heap_with_toast; diff --git a/src/test/binary_swap/sql/pg_dumpall_current.sql b/src/test/binary_swap/sql/pg_dumpall_current.sql new file mode 100644 index 0000000000000000000000000000000000000000..9a41a6574bd63e9f117e6288a681e0932dfe7bb3 --- /dev/null +++ b/src/test/binary_swap/sql/pg_dumpall_current.sql @@ -0,0 +1,2 @@ +\! pg_dumpall -f dump_current.sql +\! echo $? diff --git a/src/test/binary_swap/sql/pg_dumpall_other.sql b/src/test/binary_swap/sql/pg_dumpall_other.sql new file mode 100644 index 0000000000000000000000000000000000000000..70be1daabd0f26a38fec15077a6acb1bcffb7d37 --- /dev/null +++ b/src/test/binary_swap/sql/pg_dumpall_other.sql @@ -0,0 +1,2 @@ +\! pg_dumpall -f dump_other.sql +\! echo $? diff --git a/src/test/binary_swap/test_binary_swap.sh b/src/test/binary_swap/test_binary_swap.sh new file mode 100755 index 0000000000000000000000000000000000000000..5aec118acf9a9fdb28c0309a89a4150ceb39764f --- /dev/null +++ b/src/test/binary_swap/test_binary_swap.sh @@ -0,0 +1,139 @@ +#! /bin/bash + +## ================================================================== +## Required: regression database generated from src/test/regress +## +## Test binary swap from current Greenplum install to another +## Greenplum install. The flow goes like this: +## 1. Run pg_dumpall on current database +## 2. Start binaries provided by -b (required) +## 3. Run pg_dumpall on other binary and diff dumps +## 4. Run some inserts and do another pg_dumpall +## 5. Start binaries provided by -c (default current $GPHOME). +## 6. Run pg_dumpall on current binary and diff dumps +## 7. Run some more inserts and run another pg_dumpall +## +## Providing the binaries can be interchangeable between -b and -c +## but technically shouldn't matter. However, the binary provided in +## -c will be the active binary at the end of the run. +## ================================================================== + +## Clean previous generated test output +clean_output() +{ + rm -rf results + rm -f dump_current.sql dump_other.sql +} + +## Run tests via pg_regress with given schedule name +run_tests() +{ + SCHEDULE_NAME=$1 + ../regress/pg_regress --dbname=binswap_connect --init-file=../regress/init_file --schedule=${SCHEDULE_NAME} + if [ $? != 0 ]; then + exit 1 + fi +} + +## Start up a Greenplum binary using same $MASTER_DATA_DIRECTORY +start_binary() +{ + BINARY_PATH=$1 + gpstop -ai + source $BINARY_PATH/greenplum_path.sh + gpstart -a + echo "Select our Greenplum version just to be sure..." + psql -c "select version()" postgres +} + +usage() +{ + appname=`basename $0` + echo "$appname usage:" + echo " -b Greenplum install path for another binary to test upgrade/downgrade from (Required User Input)" + echo " -c Greenplum install path for current binary to test upgrade/downgrade to (Default: \$GPHOME)" + echo " -m Greenplum Master Data Directory (Default: \$MASTER_DATA_DIRECTORY)" + echo " -p Greenplum Master Port (Default: \$PGPORT)" + exit 0 +} + +while getopts ":c:b:m:p" opt; do + case ${opt} in + c) + GPHOME_CURRENT=$OPTARG + ;; + b) + GPHOME_OTHER=$OPTARG + ;; + m) + MDD_CURRENT=$OPTARG + ;; + p) + PGPORT_CURRENT=$OPTARG + ;; + *) + usage + ;; + esac +done + +## Main script +## ================================================== + +## Argument checking +GPHOME_CURRENT=${GPHOME_CURRENT:=$GPHOME} +MDD_CURRENT=${MDD_CURRENT:=$MASTER_DATA_DIRECTORY} +PGPORT_CURRENT=${PGPORT_CURRENT:=$PGPORT} + +if [ "${GPHOME_OTHER}x" == "x" ] || ! [ -f $GPHOME_OTHER/greenplum_path.sh ]; then + echo "Use -b to provide a valid Greenplum install path to upgrade/downgrade from" + exit 1 +fi + +if [ "${GPHOME_CURRENT}x" == "x" ] || ! [ -f $GPHOME_CURRENT/greenplum_path.sh ]; then + echo "Use -c to provide a valid Greenplum install path to upgrade/downgrade to (Default: \$GPHOME)" + exit 1 +fi + +if [ "${MDD_CURRENT}x" == "x" ]; then + echo "Use -m to provide a valid Greenplum Master Data Directory (Default: \$MASTER_DATA_DIRECTORY)" + exit 1 +fi + +if [ "${PGPORT_CURRENT}x" == "x" ]; then + echo "Use -p to provide a valid Greenplum Master Port (Default: \$PGPORT)" + exit 1 +fi + +## Grab the Greenplum versions of each binary for display +CURRENT_VERSION=`$GPHOME_CURRENT/bin/gpstart --version | awk '{ for (i=3; i