@@ -60,7 +60,11 @@ def test_ptrack_disable(self):
60
60
node .start ()
61
61
62
62
# FULL BACKUP
63
+ print ('START' )
64
+ print (node .safe_psql ('postgres' , "select pg_ptrack_control_lsn()" ))
63
65
self .backup_node (backup_dir , 'node' , node , options = ['--stream' ])
66
+ print ('AFTER FULL' )
67
+ print (node .safe_psql ('postgres' , "select pg_ptrack_control_lsn()" ))
64
68
# DISABLE PTRACK
65
69
node .safe_psql ('postgres' , "alter system set ptrack_enable to off" )
66
70
node .restart ()
@@ -85,44 +89,6 @@ def test_ptrack_disable(self):
85
89
# Clean after yourself
86
90
self .del_test_dir (module_name , fname )
87
91
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
-
126
92
# @unittest.skip("skip")
127
93
def test_ptrack_stream (self ):
128
94
"""make node, make full and ptrack stream backups, restore them and check data correctness"""
@@ -417,9 +383,8 @@ def test_create_db(self):
417
383
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" )
418
384
419
385
# PTRACK BACKUP
420
- node .safe_psql ("postgres" , "checkpoint" )
421
- pgdata = self .pgdata_content (node .data_dir )
422
386
backup_id = self .backup_node (backup_dir , 'node' , node , backup_type = 'ptrack' , options = ["--stream" ])
387
+ pgdata = self .pgdata_content (node .data_dir )
423
388
424
389
# RESTORE
425
390
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):
432
397
# START RESTORED NODE
433
398
node_restored .append_conf ("postgresql.auto.conf" , "port = {0}" .format (node_restored .port ))
434
399
node_restored .start ()
435
- # result_new = node_restored.safe_psql("postgres", "select * from pg_class")
436
400
437
401
# DROP DATABASE DB1
438
402
node .safe_psql (
439
403
"postgres" , "drop database db1" )
440
404
# SECOND PTRACK BACKUP
441
405
backup_id = self .backup_node (backup_dir , 'node' , node , backup_type = 'ptrack' , options = ["--stream" ])
406
+ pgdata = self .pgdata_content (node .data_dir )
442
407
443
408
# RESTORE SECOND PTRACK BACKUP
444
409
node_restored .cleanup ()
@@ -447,10 +412,10 @@ def test_create_db(self):
447
412
# START RESTORED NODE
448
413
node_restored .append_conf ("postgresql.auto.conf" , "port = {0}" .format (node_restored .port ))
449
414
node_restored .start ()
415
+
450
416
# 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 )
454
419
455
420
try :
456
421
node_restored .safe_psql ('db1' , 'select 1' )
@@ -495,7 +460,6 @@ def test_alter_table_set_tablespace_ptrack(self):
495
460
496
461
# PTRACK BACKUP
497
462
result = node .safe_psql ("postgres" , "select * from t_heap" )
498
- node .safe_psql ("postgres" , "select * from pg_class; checkpoint" )
499
463
self .backup_node (backup_dir , 'node' , node , backup_type = 'ptrack' , options = ["--stream" ])
500
464
pgdata_content = self .pgdata_content (node .data_dir )
501
465
node .stop ()
@@ -549,7 +513,7 @@ def test_alter_database_set_tablespace_ptrack(self):
549
513
550
514
# PTRACK BACKUP
551
515
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 )
553
517
node .stop ()
554
518
555
519
# RESTORE
@@ -559,9 +523,9 @@ def test_alter_database_set_tablespace_ptrack(self):
559
523
"-T" , "{0}={1}" .format (self .get_tblspace_path (node ,'somedata' ), self .get_tblspace_path (node_restored ,'somedata' ))])
560
524
561
525
# GET PHYSICAL CONTENT
562
- pgdata_content_new = self .pgdata_content (node_restored .data_dir )
526
+ pgdata_new = self .pgdata_content (node_restored .data_dir )
563
527
# COMPARE PHYSICAL CONTENT
564
- self .compare_pgdata (pgdata_content , pgdata_content_new )
528
+ self .compare_pgdata (pgdata , pgdata_new )
565
529
# START RESTORED NODE
566
530
node_restored .start ()
567
531
@@ -718,11 +682,10 @@ def test_relation_with_multiple_segments(self):
718
682
self .add_instance (backup_dir , 'node' , node )
719
683
node .start ()
720
684
721
- # self.create_tblspace_in_node(node, 'somedata')
685
+ self .create_tblspace_in_node (node , 'somedata' )
722
686
723
687
# 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' ])
726
689
# FULL BACKUP
727
690
self .backup_node (backup_dir , 'node' , node , options = ["--stream" ])
728
691
@@ -736,24 +699,25 @@ def test_relation_with_multiple_segments(self):
736
699
pgdata = self .pgdata_content (node .data_dir )
737
700
738
701
# RESTORE NODE
739
- # self.restore_node(backup_dir, 'node', restored_node, options=[
740
- # "-j", "4", "-T", "{0}={1}".format(tblspc_path, tblspc_path_new)])
741
702
restored_node = self .make_simple_node (base_dir = "{0}/{1}/restored_node" .format (module_name , fname ))
742
703
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' )
745
706
746
707
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"])
748
711
# GET PHYSICAL CONTENT FROM NODE_RESTORED
749
712
pgdata_restored = self .pgdata_content (restored_node .data_dir )
750
- self .compare_pgdata (pgdata , pgdata_restored )
751
713
714
+ # START RESTORED NODE
752
715
restored_node .append_conf ("postgresql.auto.conf" , "port = {0}" .format (restored_node .port ))
753
716
restored_node .start ()
754
717
755
718
result_new = restored_node .safe_psql ("postgres" , "select * from pgbench_accounts" )
756
719
self .assertEqual (result , result_new )
720
+ self .compare_pgdata (pgdata , pgdata_restored )
757
721
758
722
# Clean after yourself
759
723
self .del_test_dir (module_name , fname )
0 commit comments