Hi hackers, There is already a databases tap tests in pg_rewind, wonder if there is a need for tablespace tap tests in pg_rewind. Attached is a initial patch from me.
Here is a patch for runing pg_rewind, it is very similar to src/bin/pg_rewind/t/002_databases.pl, but there is no master_psql("CREATE TABLESPACE beforepromotion LOCATION '$tempdir/beforepromotion'"); after create_standby() and before promote_standby(), because pg_rewind will error out : could not create directory "/Users/sbai/work/postgres/src/bin/pg_rewind/tmp_check/t_006_tablespace_master_local_data/pgdata/pg_tblspc/24576/PG_12_201903063": File exists Failure, exiting The patch is created on top of the commit e1e0e8d58c5c70da92e36cb9d59c2f7ecf839e00 (origin/master, origin/HEAD) Author: Michael Paquier <mich...@paquier.xyz> Date: Fri Mar 8 15:10:14 2019 +0900 Fix function signatures of pageinspect in documentation tuple_data_split() lacked the type of the first argument, and heap_page_item_attrs() has reversed the first and second argument, with the bytea argument using an incorrect name. Author: Laurenz Albe Discussion: https://postgr.es/m/8f9ab7b16daf623e87eeef5203a4ffc0dece8dfd.ca...@cybertec.at Backpatch-through: 9.6
From 4280335c4b81aa04b967d93348ccc6874bc9c287 Mon Sep 17 00:00:00 2001 From: Shaoqi Bai <sbai@pivotal.io> Date: Fri, 8 Mar 2019 18:04:20 +0800 Subject: [PATCH] Add tablespace tap test for pg_rewind --- src/bin/pg_rewind/t/006_tablespace.pl | 51 +++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/bin/pg_rewind/t/006_tablespace.pl diff --git a/src/bin/pg_rewind/t/006_tablespace.pl b/src/bin/pg_rewind/t/006_tablespace.pl new file mode 100644 index 0000000000..094041dd89 --- /dev/null +++ b/src/bin/pg_rewind/t/006_tablespace.pl @@ -0,0 +1,51 @@ +use strict; +use warnings; +use TestLib; +use Test::More tests => 2; + +use FindBin; +use lib $FindBin::RealBin; + +use RewindTest; + +my $tempdir = TestLib::tempdir; + +sub run_test +{ + my $test_mode = shift; + + RewindTest::setup_cluster($test_mode, ['-g']); + RewindTest::start_master(); + + RewindTest::create_standby($test_mode); + + RewindTest::promote_standby(); + + mkdir "$tempdir/master_afterpromotion"; + mkdir "$tempdir/standby_afterpromotion"; + + # Create tablespaces in the old master and the new promoted standby. + master_psql("CREATE TABLESPACE master_afterpromotion LOCATION '$tempdir/master_afterpromotion'"); + standby_psql("CREATE TABLESPACE standby_afterpromotion LOCATION '$tempdir/standby_afterpromotion'"); + + # The clusters are now diverged. + + RewindTest::run_pg_rewind($test_mode); + + # Check that the correct databases are present after pg_rewind. + check_query( + 'SELECT spcname FROM pg_tablespace ORDER BY spcname', + qq(pg_default +pg_global +standby_afterpromotion +), + 'tablespace names'); + + RewindTest::clean_rewind_test(); + return; +} + +# Run the test in both modes. +run_test('local'); + +exit(0); -- 2.19.1