@@ -60,7 +60,11 @@ def test_ptrack_disable(self):
6060 node .start ()
6161
6262 # FULL BACKUP
63+ print ('START' )
64+ print (node .safe_psql ('postgres' , "select pg_ptrack_control_lsn()" ))
6365 self .backup_node (backup_dir , 'node' , node , options = ['--stream' ])
66+ print ('AFTER FULL' )
67+ print (node .safe_psql ('postgres' , "select pg_ptrack_control_lsn()" ))
6468 # DISABLE PTRACK
6569 node .safe_psql ('postgres' , "alter system set ptrack_enable to off" )
6670 node .restart ()
@@ -85,44 +89,6 @@ def test_ptrack_disable(self):
8589 # Clean after yourself
8690 self .del_test_dir (module_name , fname )
8791
88- # @unittest.skip("skip")
89- # @unittest.expectedFailure
90- def test_ptrack_control (self ):
91- """make ptrack without full backup, should result in error"""
92- self .maxDiff = None
93- fname = self .id ().split ('.' )[3 ]
94- backup_dir = os .path .join (self .tmp_path , module_name , fname , 'backup' )
95- node = self .make_simple_node (base_dir = "{0}/{1}/node" .format (module_name , fname ),
96- set_replication = True ,
97- initdb_params = ['--data-checksums' ],
98- pg_options = {'wal_level' : 'replica' , 'max_wal_senders' : '2' , 'checkpoint_timeout' : '30s' , 'ptrack_enable' : 'on' }
99- )
100- self .init_pb (backup_dir )
101- self .add_instance (backup_dir , 'node' , node )
102- node .start ()
103-
104- # FULL BACKUP
105- self .backup_node (backup_dir , 'node' , node , options = ['--stream' ])
106- # DISABLE PTRACK
107- node .safe_psql ('postgres' , "select " )
108- node .restart ()
109- # ENABLE PTRACK
110- node .safe_psql ('postgres' , "alter system set ptrack_enable to on" )
111- node .restart ()
112-
113- # PTRACK BACKUP
114- try :
115- self .backup_node (backup_dir , 'node' , node , backup_type = 'ptrack' , options = ["--stream" ])
116- # we should die here because exception is what we expect to happen
117- self .assertEqual (1 , 0 , "Expecting Error because ptrack_enable was set to OFF at some point after previous backup.\n Output: {0} \n CMD: {1}" .format (
118- repr (self .output ), self .cmd ))
119- except ProbackupException as e :
120- self .assertIn ('ERROR: LSN from ptrack_control' , e .message ,
121- '\n Unexpected Error Message: {0}\n CMD: {1}' .format (repr (e .message ), self .cmd ))
122-
123- # Clean after yourself
124- self .del_test_dir (module_name , fname )
125-
12692 # @unittest.skip("skip")
12793 def test_ptrack_stream (self ):
12894 """make node, make full and ptrack stream backups, restore them and check data correctness"""
@@ -417,9 +383,8 @@ def test_create_db(self):
417383 node .safe_psql ("db1" , "create table t_heap as select i as id, md5(i::text) as text, md5(i::text)::tsvector as tsvector from generate_series(0,100) i" )
418384
419385 # PTRACK BACKUP
420- node .safe_psql ("postgres" , "checkpoint" )
421- pgdata = self .pgdata_content (node .data_dir )
422386 backup_id = self .backup_node (backup_dir , 'node' , node , backup_type = 'ptrack' , options = ["--stream" ])
387+ pgdata = self .pgdata_content (node .data_dir )
423388
424389 # RESTORE
425390 node_restored = self .make_simple_node (base_dir = "{0}/{1}/node_restored" .format (module_name , fname ))
@@ -432,13 +397,13 @@ def test_create_db(self):
432397 # START RESTORED NODE
433398 node_restored .append_conf ("postgresql.auto.conf" , "port = {0}" .format (node_restored .port ))
434399 node_restored .start ()
435- # result_new = node_restored.safe_psql("postgres", "select * from pg_class")
436400
437401 # DROP DATABASE DB1
438402 node .safe_psql (
439403 "postgres" , "drop database db1" )
440404 # SECOND PTRACK BACKUP
441405 backup_id = self .backup_node (backup_dir , 'node' , node , backup_type = 'ptrack' , options = ["--stream" ])
406+ pgdata = self .pgdata_content (node .data_dir )
442407
443408 # RESTORE SECOND PTRACK BACKUP
444409 node_restored .cleanup ()
@@ -447,10 +412,10 @@ def test_create_db(self):
447412 # START RESTORED NODE
448413 node_restored .append_conf ("postgresql.auto.conf" , "port = {0}" .format (node_restored .port ))
449414 node_restored .start ()
415+
450416 # COMPARE PHYSICAL CONTENT
451- #pgdata = self.pgdata_content(node.data_dir)
452- #pgdata_new = self.pgdata_content(node_restored.data_dir)
453- #self.compare_pgdata(pgdata, pgdata_new)
417+ pgdata_new = self .pgdata_content (node_restored .data_dir )
418+ self .compare_pgdata (pgdata , pgdata_new )
454419
455420 try :
456421 node_restored .safe_psql ('db1' , 'select 1' )
@@ -495,7 +460,6 @@ def test_alter_table_set_tablespace_ptrack(self):
495460
496461 # PTRACK BACKUP
497462 result = node .safe_psql ("postgres" , "select * from t_heap" )
498- node .safe_psql ("postgres" , "select * from pg_class; checkpoint" )
499463 self .backup_node (backup_dir , 'node' , node , backup_type = 'ptrack' , options = ["--stream" ])
500464 pgdata_content = self .pgdata_content (node .data_dir )
501465 node .stop ()
@@ -549,7 +513,7 @@ def test_alter_database_set_tablespace_ptrack(self):
549513
550514 # PTRACK BACKUP
551515 self .backup_node (backup_dir , 'node' , node , backup_type = 'ptrack' , options = ["--stream" ])
552- pgdata_content = self .pgdata_content (node .data_dir )
516+ pgdata = self .pgdata_content (node .data_dir )
553517 node .stop ()
554518
555519 # RESTORE
@@ -559,9 +523,9 @@ def test_alter_database_set_tablespace_ptrack(self):
559523 "-T" , "{0}={1}" .format (self .get_tblspace_path (node ,'somedata' ), self .get_tblspace_path (node_restored ,'somedata' ))])
560524
561525 # GET PHYSICAL CONTENT
562- pgdata_content_new = self .pgdata_content (node_restored .data_dir )
526+ pgdata_new = self .pgdata_content (node_restored .data_dir )
563527 # COMPARE PHYSICAL CONTENT
564- self .compare_pgdata (pgdata_content , pgdata_content_new )
528+ self .compare_pgdata (pgdata , pgdata_new )
565529 # START RESTORED NODE
566530 node_restored .start ()
567531
@@ -718,11 +682,10 @@ def test_relation_with_multiple_segments(self):
718682 self .add_instance (backup_dir , 'node' , node )
719683 node .start ()
720684
721- # self.create_tblspace_in_node(node, 'somedata')
685+ self .create_tblspace_in_node (node , 'somedata' )
722686
723687 # CREATE TABLE
724- # node.pgbench_init(scale=300, options=['--tablespace=somedata'])
725- pgbench = node .pgbench_init (scale = 30 )
688+ node .pgbench_init (scale = 30 , options = ['--tablespace=somedata' ])
726689 # FULL BACKUP
727690 self .backup_node (backup_dir , 'node' , node , options = ["--stream" ])
728691
@@ -736,24 +699,25 @@ def test_relation_with_multiple_segments(self):
736699 pgdata = self .pgdata_content (node .data_dir )
737700
738701 # RESTORE NODE
739- # self.restore_node(backup_dir, 'node', restored_node, options=[
740- # "-j", "4", "-T", "{0}={1}".format(tblspc_path, tblspc_path_new)])
741702 restored_node = self .make_simple_node (base_dir = "{0}/{1}/restored_node" .format (module_name , fname ))
742703 restored_node .cleanup ()
743- # tblspc_path = self.get_tblspace_path(node, 'somedata')
744- # tblspc_path_new = self.get_tblspace_path(restored_node, 'somedata_restored')
704+ tblspc_path = self .get_tblspace_path (node , 'somedata' )
705+ tblspc_path_new = self .get_tblspace_path (restored_node , 'somedata_restored' )
745706
746707 self .restore_node (backup_dir , 'node' , restored_node , options = [
747- "-j" , "4" ])
708+ "-j" , "4" , "-T" , "{0}={1}" .format (tblspc_path , tblspc_path_new )])
709+ # self.restore_node(backup_dir, 'node', restored_node, options=[
710+ # "-j", "4"])
748711 # GET PHYSICAL CONTENT FROM NODE_RESTORED
749712 pgdata_restored = self .pgdata_content (restored_node .data_dir )
750- self .compare_pgdata (pgdata , pgdata_restored )
751713
714+ # START RESTORED NODE
752715 restored_node .append_conf ("postgresql.auto.conf" , "port = {0}" .format (restored_node .port ))
753716 restored_node .start ()
754717
755718 result_new = restored_node .safe_psql ("postgres" , "select * from pgbench_accounts" )
756719 self .assertEqual (result , result_new )
720+ self .compare_pgdata (pgdata , pgdata_restored )
757721
758722 # Clean after yourself
759723 self .del_test_dir (module_name , fname )
0 commit comments