3
3
import os
4
4
from .helpers .ptrack_helpers import ProbackupTest , ProbackupException
5
5
from sys import exit
6
+ import shutil
6
7
7
8
module_name = 'compatibility'
8
9
@@ -627,24 +628,23 @@ def test_backward_compatibility_merge_1(self):
627
628
self .set_archiving (backup_dir , 'node' , node , old_binary = True )
628
629
node .slow_start ()
629
630
630
- node .pgbench_init (scale = 1 )
631
+ node .pgbench_init (scale = 20 )
631
632
632
633
# FULL backup with OLD binary
633
634
self .backup_node (
634
- backup_dir , 'node' , node ,
635
- old_binary = True )
635
+ backup_dir , 'node' , node , old_binary = True )
636
636
637
637
pgbench = node .pgbench (
638
638
stdout = subprocess .PIPE ,
639
639
stderr = subprocess .STDOUT ,
640
- options = ["-c" , "4 " , "-T" , "10" ])
640
+ options = ["-c" , "1 " , "-T" , "10" , "--no-vacuum " ])
641
641
pgbench .wait ()
642
642
pgbench .stdout .close ()
643
643
644
644
# PAGE1 backup with OLD binary
645
- backup_id = self .backup_node (
645
+ self .backup_node (
646
646
backup_dir , 'node' , node ,
647
- backup_type = 'page' , old_binary = True )
647
+ backup_type = 'page' , old_binary = True , options = [ '--log-level-file=LOG' ] )
648
648
649
649
node .safe_psql (
650
650
'postgres' ,
@@ -655,20 +655,20 @@ def test_backward_compatibility_merge_1(self):
655
655
'VACUUM pgbench_accounts' )
656
656
657
657
# PAGE2 backup with OLD binary
658
- backup_id = self .backup_node (
658
+ self .backup_node (
659
659
backup_dir , 'node' , node ,
660
- backup_type = 'page' , old_binary = True )
660
+ backup_type = 'page' , old_binary = True , options = [ '--log-level-file=LOG' ] )
661
661
662
662
# PAGE3 backup with OLD binary
663
663
backup_id = self .backup_node (
664
664
backup_dir , 'node' , node ,
665
- backup_type = 'page' , old_binary = True )
665
+ backup_type = 'page' , old_binary = True , options = [ '--log-level-file=LOG' ] )
666
666
667
667
pgdata = self .pgdata_content (node .data_dir )
668
668
669
669
# merge chain created by old binary with new binary
670
670
output = self .merge_backup (
671
- backup_dir , "node" , backup_id )
671
+ backup_dir , "node" , backup_id , options = [ '--log-level-file=LOG' ] )
672
672
673
673
# check that in-place is disabled
674
674
self .assertIn (
@@ -689,6 +689,129 @@ def test_backward_compatibility_merge_1(self):
689
689
# Clean after yourself
690
690
self .del_test_dir (module_name , fname )
691
691
692
+ # @unittest.expectedFailure
693
+ # @unittest.skip("skip")
694
+ def test_backward_compatibility_merge_2 (self ):
695
+ """
696
+ Create node, take FULL and PAGE backups with old binary,
697
+ merge them with new binary.
698
+ old binary version =< 2.2.7
699
+ """
700
+ fname = self .id ().split ('.' )[3 ]
701
+ backup_dir = os .path .join (self .tmp_path , module_name , fname , 'backup' )
702
+ node = self .make_simple_node (
703
+ base_dir = os .path .join (module_name , fname , 'node' ),
704
+ set_replication = True ,
705
+ initdb_params = ['--data-checksums' ],
706
+ pg_options = {'autovacuum' : 'off' })
707
+
708
+ self .init_pb (backup_dir , old_binary = True )
709
+ self .add_instance (backup_dir , 'node' , node , old_binary = True )
710
+
711
+ self .set_archiving (backup_dir , 'node' , node , old_binary = True )
712
+ node .slow_start ()
713
+
714
+ node .pgbench_init (scale = 50 )
715
+
716
+ node .safe_psql (
717
+ 'postgres' ,
718
+ 'VACUUM pgbench_accounts' )
719
+
720
+ node_restored = self .make_simple_node (
721
+ base_dir = os .path .join (module_name , fname , 'node_restored' ))
722
+
723
+ # FULL backup with OLD binary
724
+ self .backup_node (backup_dir , 'node' , node , old_binary = True )
725
+
726
+ pgbench = node .pgbench (
727
+ stdout = subprocess .PIPE ,
728
+ stderr = subprocess .STDOUT ,
729
+ options = ["-c" , "1" , "-T" , "10" , "--no-vacuum" ])
730
+ pgbench .wait ()
731
+ pgbench .stdout .close ()
732
+
733
+ # PAGE1 backup with OLD binary
734
+ page1 = self .backup_node (
735
+ backup_dir , 'node' , node ,
736
+ backup_type = 'page' , old_binary = True )
737
+
738
+ pgdata1 = self .pgdata_content (node .data_dir )
739
+
740
+ node .safe_psql (
741
+ 'postgres' ,
742
+ "DELETE from pgbench_accounts where ctid > '(10,1)'" )
743
+
744
+ # PAGE2 backup with OLD binary
745
+ page2 = self .backup_node (
746
+ backup_dir , 'node' , node ,
747
+ backup_type = 'page' , old_binary = True )
748
+
749
+ pgdata2 = self .pgdata_content (node .data_dir )
750
+
751
+ # PAGE3 backup with OLD binary
752
+ page3 = self .backup_node (
753
+ backup_dir , 'node' , node ,
754
+ backup_type = 'page' , old_binary = True )
755
+
756
+ pgdata3 = self .pgdata_content (node .data_dir )
757
+
758
+ pgbench = node .pgbench (
759
+ stdout = subprocess .PIPE ,
760
+ stderr = subprocess .STDOUT ,
761
+ options = ["-c" , "1" , "-T" , "10" , "--no-vacuum" ])
762
+ pgbench .wait ()
763
+ pgbench .stdout .close ()
764
+
765
+ # PAGE4 backup with NEW binary
766
+ page4 = self .backup_node (
767
+ backup_dir , 'node' , node , backup_type = 'page' )
768
+ pgdata4 = self .pgdata_content (node .data_dir )
769
+
770
+ # merge backups one by one and check data correctness
771
+ # merge PAGE1
772
+ self .merge_backup (
773
+ backup_dir , "node" , page1 , options = ['--log-level-file=VERBOSE' ])
774
+
775
+ # check data correctness for PAGE1
776
+ node_restored .cleanup ()
777
+ self .restore_node (
778
+ backup_dir , 'node' , node_restored , backup_id = page1 ,
779
+ options = ['--log-level-file=VERBOSE' ])
780
+ pgdata_restored = self .pgdata_content (node_restored .data_dir )
781
+ self .compare_pgdata (pgdata1 , pgdata_restored )
782
+
783
+ # merge PAGE2
784
+ self .merge_backup (backup_dir , "node" , page2 )
785
+
786
+ # check data correctness for PAGE2
787
+ node_restored .cleanup ()
788
+ self .restore_node (backup_dir , 'node' , node_restored , backup_id = page2 )
789
+ pgdata_restored = self .pgdata_content (node_restored .data_dir )
790
+ self .compare_pgdata (pgdata2 , pgdata_restored )
791
+
792
+ # merge PAGE3
793
+ self .show_pb (backup_dir , 'node' , page3 )
794
+ self .merge_backup (backup_dir , "node" , page3 )
795
+ self .show_pb (backup_dir , 'node' , page3 )
796
+
797
+ # check data correctness for PAGE3
798
+ node_restored .cleanup ()
799
+ self .restore_node (backup_dir , 'node' , node_restored , backup_id = page3 )
800
+ pgdata_restored = self .pgdata_content (node_restored .data_dir )
801
+ self .compare_pgdata (pgdata3 , pgdata_restored )
802
+
803
+ # merge PAGE4
804
+ self .merge_backup (backup_dir , "node" , page4 )
805
+
806
+ # check data correctness for PAGE4
807
+ node_restored .cleanup ()
808
+ self .restore_node (backup_dir , 'node' , node_restored , backup_id = page4 )
809
+ pgdata_restored = self .pgdata_content (node_restored .data_dir )
810
+ self .compare_pgdata (pgdata4 , pgdata_restored )
811
+
812
+ # Clean after yourself
813
+ self .del_test_dir (module_name , fname )
814
+
692
815
# @unittest.skip("skip")
693
816
def test_page_vacuum_truncate (self ):
694
817
"""
0 commit comments