@@ -924,6 +924,99 @@ def test_alter_table_set_tablespace_delta(self):
924
924
# Clean after yourself
925
925
self .del_test_dir (module_name , fname )
926
926
927
+ # @unittest.skip("skip")
928
+ def test_alter_database_set_tablespace_delta (self ):
929
+ """
930
+ Make node, take full backup, create database,
931
+ take delta backup, alter database tablespace location, take delta backup
932
+ restore last delta backup.
933
+ """
934
+ fname = self .id ().split ('.' )[3 ]
935
+ backup_dir = os .path .join (self .tmp_path , module_name , fname , 'backup' )
936
+ node = self .make_simple_node (
937
+ base_dir = "{0}/{1}/node" .format (module_name , fname ),
938
+ set_replication = True , initdb_params = ['--data-checksums' ],
939
+ pg_options = {
940
+ 'wal_level' : 'replica' ,
941
+ 'max_wal_senders' : '2' ,
942
+ 'checkpoint_timeout' : '30s' ,
943
+ 'autovacuum' : 'off'
944
+ }
945
+ )
946
+
947
+ self .init_pb (backup_dir )
948
+ self .add_instance (backup_dir , 'node' , node )
949
+ node .start ()
950
+ self .create_tblspace_in_node (node , 'somedata' )
951
+
952
+ # FULL backup
953
+ self .backup_node (backup_dir , 'node' , node , options = ["--stream" ])
954
+
955
+ # CREATE DATABASE DB1
956
+ node .safe_psql ("postgres" , "create database db1 tablespace = 'somedata'" )
957
+ node .safe_psql (
958
+ "db1" ,
959
+ "create table t_heap as select i as id, md5(i::text) as text, "
960
+ "md5(i::text)::tsvector as tsvector from generate_series(0,100) i" )
961
+
962
+ # DELTA BACKUP
963
+ self .backup_node (
964
+ backup_dir , 'node' , node ,
965
+ backup_type = 'delta' ,
966
+ options = ["--stream" ]
967
+ )
968
+
969
+ # ALTER TABLESPACE
970
+ self .create_tblspace_in_node (node , 'somedata_new' )
971
+ node .safe_psql (
972
+ "postgres" ,
973
+ "alter database db1 set tablespace somedata_new"
974
+ )
975
+
976
+ # DELTA BACKUP
977
+ self .backup_node (
978
+ backup_dir , 'node' , node ,
979
+ backup_type = 'delta' ,
980
+ options = ["--stream" ]
981
+ )
982
+
983
+ if self .paranoia :
984
+ pgdata = self .pgdata_content (node .data_dir )
985
+
986
+ # RESTORE
987
+ node_restored = self .make_simple_node (
988
+ base_dir = "{0}/{1}/node_restored" .format (module_name , fname )
989
+ )
990
+ node_restored .cleanup ()
991
+
992
+ self .restore_node (
993
+ backup_dir , 'node' , node_restored ,
994
+ options = [
995
+ "-j" , "4" ,
996
+ "-T" , "{0}={1}" .format (
997
+ self .get_tblspace_path (node , 'somedata' ),
998
+ self .get_tblspace_path (node_restored , 'somedata' )
999
+ ),
1000
+ "-T" , "{0}={1}" .format (
1001
+ self .get_tblspace_path (node , 'somedata_new' ),
1002
+ self .get_tblspace_path (node_restored , 'somedata_new' )
1003
+ )
1004
+ ]
1005
+ )
1006
+
1007
+ # GET RESTORED PGDATA AND COMPARE
1008
+ if self .paranoia :
1009
+ pgdata_restored = self .pgdata_content (node_restored .data_dir )
1010
+ self .compare_pgdata (pgdata , pgdata_restored )
1011
+
1012
+ # START RESTORED NODE
1013
+ node_restored .append_conf (
1014
+ 'postgresql.auto.conf' , 'port = {0}' .format (node_restored .port ))
1015
+ node_restored .start ()
1016
+
1017
+ # Clean after yourself
1018
+ self .del_test_dir (module_name , fname )
1019
+
927
1020
# @unittest.skip("skip")
928
1021
def test_delta_delete (self ):
929
1022
"""Make node, create tablespace with table, take full backup,
@@ -1055,7 +1148,7 @@ def test_page_corruption_heal_via_ptrack_1(self):
1055
1148
with open (os .path .join (backup_dir , 'log' , 'pg_probackup.log' )) as f :
1056
1149
log_content = f .read ()
1057
1150
self .assertIn ('block 1, try to fetch via SQL' , log_content )
1058
- self .assertIn ('SELECT pg_ptrack_get_block' , log_content )
1151
+ self .assertIn ('SELECT pg_catalog. pg_ptrack_get_block' , log_content )
1059
1152
f .close
1060
1153
1061
1154
self .assertTrue (
@@ -1127,7 +1220,7 @@ def test_page_corruption_heal_via_ptrack_2(self):
1127
1220
"calculated checksum" in e .message and
1128
1221
"ERROR: query failed: "
1129
1222
"ERROR: invalid page in block" in e .message and
1130
- "query was: SELECT pg_ptrack_get_block_2 " in e .message ,
1223
+ "query was: SELECT pg_catalog.pg_ptrack_get_block " in e .message ,
1131
1224
"\n Unexpected Error Message: {0}\n CMD: {1}" .format (
1132
1225
repr (e .message ), self .cmd ))
1133
1226
0 commit comments