diff --git a/src/test/isolation2/.gitignore b/src/test/isolation2/.gitignore index a6cc7918f60ccd8aac18a8bae66331e255b025a9..3a7ca823c5b1900942ba48ffa3d508e6aed27ebd 100644 --- a/src/test/isolation2/.gitignore +++ b/src/test/isolation2/.gitignore @@ -6,6 +6,10 @@ sql/ao_upgrade.sql expected/ao_upgrade.out expected/ao_upgrade_optimizer.out +-- ignore generated pg_basebackup tests +/sql/pg_basebackup*.sql +/expected/pg_basebackup*.out + # Local binaries and symbolic links /pg_isolation2_regress /atmsort.pm diff --git a/src/test/isolation2/sql/segwalrep/pg_basebackup.sql b/src/test/isolation2/input/pg_basebackup.source similarity index 65% rename from src/test/isolation2/sql/segwalrep/pg_basebackup.sql rename to src/test/isolation2/input/pg_basebackup.source index f3348e4f756a94f658f98c308e1767e3828b0666..12f898d1b8ceab24f6e979338276ee19593d9363 100644 --- a/src/test/isolation2/sql/segwalrep/pg_basebackup.sql +++ b/src/test/isolation2/input/pg_basebackup.source @@ -1,11 +1,8 @@ include: helpers/gp_management_utils_helpers.sql; --- Given a segment running without a replication slot -0U: select * from pg_drop_replication_slot('some_replication_slot'); -!\retcode rm -rf /tmp/some_isolation2_pg_basebackup; -- When pg_basebackup runs with --slot and stream as xlog-method -select pg_basebackup(address, dbid, port, 'some_replication_slot', '/tmp/some_isolation2_pg_basebackup') from gp_segment_configuration where content = 0 and role = 'p'; +select pg_basebackup(address, dbid, port, 'some_replication_slot', '@testtablespace@/some_isolation2_pg_basebackup', false) from gp_segment_configuration where content = 0 and role = 'p'; -- Then a replication slot gets created on that segment with the slot -- name and the slot's restart_lsn is not NULL, indicating that the @@ -14,22 +11,26 @@ select pg_basebackup(address, dbid, port, 'some_replication_slot', '/tmp/some_is 0U: select slot_name, slot_type, active, restart_lsn is not NULL as slot_was_used from pg_get_replication_slots() where slot_name = 'some_replication_slot'; -- When another basebackup is run with the same slot name -select pg_basebackup(address, dbid, port, 'some_replication_slot', '/tmp/some_other_isolation2_pg_basebackup') from gp_segment_configuration where content = 0 and role = 'p'; +select pg_basebackup(address, dbid, port, 'some_replication_slot', '@testtablespace@/some_other_isolation2_pg_basebackup', false) from gp_segment_configuration where content = 0 and role = 'p'; -- Then the backup should exist on the filesystem, ready for mirroring -!\retcode cat /tmp/some_other_isolation2_pg_basebackup/recovery.conf; +!\retcode cat @testtablespace@/some_other_isolation2_pg_basebackup/recovery.conf; -- And the replication slot information should be unchanged 0U: select slot_name, slot_type, active, restart_lsn is not NULL as slot_was_used from pg_get_replication_slots() where slot_name = 'some_replication_slot'; -- Given we remove the replication slot 0U: select * from pg_drop_replication_slot('some_replication_slot'); -!\retcode rm -rf /tmp/some_isolation2_pg_basebackup; -!\retcode rm -rf /tmp/some_other_isolation2_pg_basebackup; +!\retcode rm -rf @testtablespace@/some_isolation2_pg_basebackup; +!\retcode rm -rf @testtablespace@/some_other_isolation2_pg_basebackup; -- When pg_basebackup runs without --slot -select pg_basebackup(address, dbid, port, null, '/tmp/some_isolation2_pg_basebackup') from gp_segment_configuration where content = 0 and role = 'p'; +select pg_basebackup(address, dbid, port, null, '@testtablespace@/some_isolation2_pg_basebackup', false) from gp_segment_configuration where content = 0 and role = 'p'; -- Then there should NOT be a replication slot 0U: select count(1) from pg_get_replication_slots() where slot_name = 'some_replication_slot'; + +-- Cleanup things we've created +!\retcode rm -rf @testtablespace@/some_isolation2_pg_basebackup; + diff --git a/src/test/isolation2/sql/segwalrep/pg_basebackup_with_tablespaces.sql b/src/test/isolation2/input/pg_basebackup_with_tablespaces.source similarity index 50% rename from src/test/isolation2/sql/segwalrep/pg_basebackup_with_tablespaces.sql rename to src/test/isolation2/input/pg_basebackup_with_tablespaces.source index 41654d0f73d2c13a6592f4f37b9858f0bdbc28f9..d4fc7ed8fc7080b1153971beba41b0859812c3a6 100644 --- a/src/test/isolation2/sql/segwalrep/pg_basebackup_with_tablespaces.sql +++ b/src/test/isolation2/input/pg_basebackup_with_tablespaces.source @@ -1,27 +1,30 @@ include: helpers/gp_management_utils_helpers.sql; --- Ensure we have a clean slate to begin with -!\retcode rm -rf /tmp/some_isolation2_pg_basebackup; -!\retcode rm -rf /tmp/some_isolation2_pg_basebackup_tablespace; - -- Given a segment with a database that has a tablespace -!\retcode mkdir -p /tmp/some_isolation2_pg_basebackup_tablespace; +!\retcode mkdir -p @testtablespace@/some_isolation2_pg_basebackup_tablespace; drop tablespace if exists some_isolation2_pg_basebackup_tablespace; -create tablespace some_isolation2_pg_basebackup_tablespace location '/tmp/some_isolation2_pg_basebackup_tablespace'; +create tablespace some_isolation2_pg_basebackup_tablespace location '@testtablespace@/some_isolation2_pg_basebackup_tablespace'; -- And a database using the tablespace drop database if exists some_database_with_tablespace; create database some_database_with_tablespace tablespace some_isolation2_pg_basebackup_tablespace; -- When we create a full backup -select pg_basebackup(address, 100, port, 'some_replication_slot', '/tmp/some_isolation2_pg_basebackup', false) from gp_segment_configuration where content = 0 and role = 'p'; +select pg_basebackup(address, 100, port, 'some_replication_slot', '@testtablespace@/some_isolation2_pg_basebackup', false) from gp_segment_configuration where content = 0 and role = 'p'; -- Then we should have a backup of the source segment files in the newly created target tablespace -select count_of_items_in_directory('/tmp/some_isolation2_pg_basebackup_tablespace/GPDB_*db100/'); +select count_of_items_in_directory('@testtablespace@/some_isolation2_pg_basebackup_tablespace/GPDB_*db100/'); -- When we create a full backup using force overwrite -select pg_basebackup(address, 200, port, 'some_replication_slot', '/tmp/some_isolation2_pg_basebackup', true) from gp_segment_configuration where content = 0 and role = 'p'; +select pg_basebackup(address, 200, port, 'some_replication_slot', '@testtablespace@/some_isolation2_pg_basebackup', true) from gp_segment_configuration where content = 0 and role = 'p'; -- Then we should have a backup of the source segment files in the newly created target tablespace -select count_of_items_in_directory('/tmp/some_isolation2_pg_basebackup_tablespace/GPDB_*db200/'); +select count_of_items_in_directory('@testtablespace@/some_isolation2_pg_basebackup_tablespace/GPDB_*db200/'); + + +-- Cleanup things we've created +0U: select pg_drop_replication_slot('some_replication_slot'); +!\retcode rm -rf @testtablespace@/some_isolation2_pg_basebackup; +!\retcode rm -rf @testtablespace@/some_isolation2_pg_basebackup_tablespace; + diff --git a/src/test/isolation2/expected/segwalrep/pg_basebackup.out b/src/test/isolation2/output/pg_basebackup.source similarity index 76% rename from src/test/isolation2/expected/segwalrep/pg_basebackup.out rename to src/test/isolation2/output/pg_basebackup.source index 3a9f836ae2fb4999ccb9767bdc35a9b5e0cf5769..4b0ad4d55375827786bab7a41013fc629251abec 100644 --- a/src/test/isolation2/expected/segwalrep/pg_basebackup.out +++ b/src/test/isolation2/output/pg_basebackup.source @@ -1,17 +1,9 @@ include: helpers/gp_management_utils_helpers.sql; CREATE --- Given a segment running without a replication slot -0U: select * from pg_drop_replication_slot('some_replication_slot'); -ERROR: replication slot "some_replication_slot" does not exist -!\retcode rm -rf /tmp/some_isolation2_pg_basebackup; --- start_ignore - --- end_ignore -(exited with code 0) -- When pg_basebackup runs with --slot and stream as xlog-method -select pg_basebackup(address, dbid, port, 'some_replication_slot', '/tmp/some_isolation2_pg_basebackup') from gp_segment_configuration where content = 0 and role = 'p'; +select pg_basebackup(address, dbid, port, 'some_replication_slot', '@testtablespace@/some_isolation2_pg_basebackup', false) from gp_segment_configuration where content = 0 and role = 'p'; pg_basebackup --------------- @@ -28,14 +20,14 @@ select pg_basebackup(address, dbid, port, 'some_replication_slot', '/tmp/some_is (1 row) -- When another basebackup is run with the same slot name -select pg_basebackup(address, dbid, port, 'some_replication_slot', '/tmp/some_other_isolation2_pg_basebackup') from gp_segment_configuration where content = 0 and role = 'p'; +select pg_basebackup(address, dbid, port, 'some_replication_slot', '@testtablespace@/some_other_isolation2_pg_basebackup', false) from gp_segment_configuration where content = 0 and role = 'p'; pg_basebackup --------------- (1 row) -- Then the backup should exist on the filesystem, ready for mirroring -!\retcode cat /tmp/some_other_isolation2_pg_basebackup/recovery.conf; +!\retcode cat @testtablespace@/some_other_isolation2_pg_basebackup/recovery.conf; -- start_ignore standby_mode = 'on' primary_conninfo = 'user=adamberlin host=adamberlin-linux port=25432 sslmode=disable sslcompression=1 application_name=gp_walreceiver' @@ -57,19 +49,19 @@ primary_slot_name = 'some_replication_slot' -------------------------- (1 row) -!\retcode rm -rf /tmp/some_isolation2_pg_basebackup; +!\retcode rm -rf @testtablespace@/some_isolation2_pg_basebackup; -- start_ignore -- end_ignore (exited with code 0) -!\retcode rm -rf /tmp/some_other_isolation2_pg_basebackup; +!\retcode rm -rf @testtablespace@/some_other_isolation2_pg_basebackup; -- start_ignore -- end_ignore (exited with code 0) -- When pg_basebackup runs without --slot -select pg_basebackup(address, dbid, port, null, '/tmp/some_isolation2_pg_basebackup') from gp_segment_configuration where content = 0 and role = 'p'; +select pg_basebackup(address, dbid, port, null, '@testtablespace@/some_isolation2_pg_basebackup', false) from gp_segment_configuration where content = 0 and role = 'p'; pg_basebackup --------------- @@ -82,3 +74,11 @@ select pg_basebackup(address, dbid, port, null, '/tmp/some_isolation2_pg_basebac 0 (1 row) + +-- Cleanup things we've created +!\retcode rm -rf /home/adamberlin/workspace/gpdb/src/test/isolation2/testtablespace/some_isolation2_pg_basebackup; +-- start_ignore + +-- end_ignore +(exited with code 0) + diff --git a/src/test/isolation2/expected/segwalrep/pg_basebackup_with_tablespaces.out b/src/test/isolation2/output/pg_basebackup_with_tablespaces.source similarity index 59% rename from src/test/isolation2/expected/segwalrep/pg_basebackup_with_tablespaces.out rename to src/test/isolation2/output/pg_basebackup_with_tablespaces.source index 0cb1c4374479f0a85f1ada5372b1c873281a3b9f..a30bd1d9671b1529451e68a8f14329691da9892b 100644 --- a/src/test/isolation2/expected/segwalrep/pg_basebackup_with_tablespaces.out +++ b/src/test/isolation2/output/pg_basebackup_with_tablespaces.source @@ -1,20 +1,8 @@ include: helpers/gp_management_utils_helpers.sql; CREATE --- Ensure we have a clean slate to begin with -!\retcode rm -rf /tmp/some_isolation2_pg_basebackup; --- start_ignore - --- end_ignore -(exited with code 0) -!\retcode rm -rf /tmp/some_isolation2_pg_basebackup_tablespace; --- start_ignore - --- end_ignore -(exited with code 0) - -- Given a segment with a database that has a tablespace -!\retcode mkdir -p /tmp/some_isolation2_pg_basebackup_tablespace; +!\retcode mkdir -p @testtablespace@/some_isolation2_pg_basebackup_tablespace; -- start_ignore -- end_ignore @@ -22,7 +10,7 @@ CREATE drop tablespace if exists some_isolation2_pg_basebackup_tablespace; DROP -create tablespace some_isolation2_pg_basebackup_tablespace location '/tmp/some_isolation2_pg_basebackup_tablespace'; +create tablespace some_isolation2_pg_basebackup_tablespace location '@testtablespace@/some_isolation2_pg_basebackup_tablespace'; CREATE -- And a database using the tablespace @@ -32,29 +20,48 @@ create database some_database_with_tablespace tablespace some_isolation2_pg_base CREATE -- When we create a full backup -select pg_basebackup(address, 100, port, 'some_replication_slot', '/tmp/some_isolation2_pg_basebackup', false) from gp_segment_configuration where content = 0 and role = 'p'; +select pg_basebackup(address, 100, port, 'some_replication_slot', '@testtablespace@/some_isolation2_pg_basebackup', false) from gp_segment_configuration where content = 0 and role = 'p'; pg_basebackup --------------- (1 row) -- Then we should have a backup of the source segment files in the newly created target tablespace -select count_of_items_in_directory('/tmp/some_isolation2_pg_basebackup_tablespace/GPDB_*db100/'); +select count_of_items_in_directory('@testtablespace@/some_isolation2_pg_basebackup_tablespace/GPDB_*db100/'); count_of_items_in_directory ----------------------------- 1 (1 row) -- When we create a full backup using force overwrite -select pg_basebackup(address, 200, port, 'some_replication_slot', '/tmp/some_isolation2_pg_basebackup', true) from gp_segment_configuration where content = 0 and role = 'p'; +select pg_basebackup(address, 200, port, 'some_replication_slot', '@testtablespace@/some_isolation2_pg_basebackup', true) from gp_segment_configuration where content = 0 and role = 'p'; pg_basebackup --------------- (1 row) -- Then we should have a backup of the source segment files in the newly created target tablespace -select count_of_items_in_directory('/tmp/some_isolation2_pg_basebackup_tablespace/GPDB_*db200/'); +select count_of_items_in_directory('@testtablespace@/some_isolation2_pg_basebackup_tablespace/GPDB_*db200/'); count_of_items_in_directory ----------------------------- 1 (1 row) + + +-- Cleanup things we've created +0U: select pg_drop_replication_slot('some_replication_slot'); + pg_drop_replication_slot +-------------------------- + +(1 row) +!\retcode rm -rf @testtablespace@/some_isolation2_pg_basebackup; +-- start_ignore + +-- end_ignore +(exited with code 0) +!\retcode rm -rf @testtablespace@/some_isolation2_pg_basebackup_tablespace; +-- start_ignore + +-- end_ignore +(exited with code 0) +