@@ -780,6 +780,7 @@ def test_pg_dump(self):
780
780
con .commit ()
781
781
782
782
# compare strategies
783
+ CMP_OK , PLANS_MISMATCH , CONTENTS_MISMATCH = range (3 )
783
784
def cmp_full (con1 , con2 ):
784
785
"""Compare selection partitions in plan and contents in partitioned tables"""
785
786
@@ -794,11 +795,15 @@ def cmp_full(con1, con2):
794
795
for table_ref in table_refs :
795
796
plan_initial = con1 .execute (plan_query % table_ref )[0 ][0 ][0 ]['Plan' ]
796
797
plan_copy = con2 .execute (plan_query % table_ref )[0 ][0 ][0 ]['Plan' ]
797
- self .assertEqual (ordered (plan_initial ), ordered (plan_copy ))
798
+ if ordered (plan_initial ) != ordered (plan_copy ):
799
+ return PLANS_MISMATCH
798
800
799
801
content_initial = [x [0 ] for x in con1 .execute (content_query % table_ref )]
800
802
content_copy = [x [0 ] for x in con2 .execute (content_query % table_ref )]
801
- self .assertEqual (content_initial , content_copy )
803
+ if content_initial != content_copy :
804
+ return CONTENTS_MISMATCH
805
+
806
+ return CMP_OK
802
807
803
808
def turnoff_pathman (node ):
804
809
node .psql ('initial' , 'alter system set pg_pathman.enable to off' )
@@ -845,12 +850,15 @@ def turnon_pathman(node):
845
850
]
846
851
for preproc , postproc , pg_dump_params , pg_restore_params , cmp_dbs in test_params :
847
852
853
+ dump_restore_cmd = " | " .join ((' ' .join (pg_dump_params ), ' ' .join (pg_restore_params )))
854
+
848
855
if (preproc != None ):
849
856
preproc (node )
850
857
851
858
# transfer and restore data
859
+ FNULL = open (os .devnull , 'w' )
852
860
p1 = subprocess .Popen (pg_dump_params , stdout = subprocess .PIPE )
853
- p2 = subprocess .Popen (pg_restore_params , stdin = p1 .stdout , stdout = subprocess . PIPE )
861
+ p2 = subprocess .Popen (pg_restore_params , stdin = p1 .stdout , stdout = FNULL , stderr = FNULL )
854
862
p1 .stdout .close () # Allow p1 to receive a SIGPIPE if p2 exits.
855
863
p2 .communicate ()
856
864
@@ -861,7 +869,11 @@ def turnon_pathman(node):
861
869
with node .connect ('initial' ) as con1 , node .connect ('copy' ) as con2 :
862
870
863
871
# compare plans and contents of initial and copy
864
- cmp_dbs (con1 , con2 )
872
+ cmp_result = cmp_dbs (con1 , con2 )
873
+ self .assertNotEqual (cmp_result , PLANS_MISMATCH ,
874
+ "mismatch in plans of select query on partitioned tables under the command: %s" % dump_restore_cmd )
875
+ self .assertNotEqual (cmp_result , CONTENTS_MISMATCH ,
876
+ "mismatch in contents of partitioned tables under the command: %s" % dump_restore_cmd )
865
877
866
878
# compare enable_parent flag and callback function
867
879
config_params_query = """
@@ -872,7 +884,8 @@ def turnon_pathman(node):
872
884
config_params_initial [row [0 ]] = row [1 :]
873
885
for row in con2 .execute (config_params_query ):
874
886
config_params_copy [row [0 ]] = row [1 :]
875
- self .assertEqual (config_params_initial , config_params_copy )
887
+ self .assertEqual (config_params_initial , config_params_copy , \
888
+ "mismatch in pathman_config_params under the command: %s" % dump_restore_cmd )
876
889
877
890
# compare constraints on each partition
878
891
constraints_query = """
@@ -885,7 +898,8 @@ def turnon_pathman(node):
885
898
constraints_initial [row [0 ]] = row [1 :]
886
899
for row in con2 .execute (constraints_query ):
887
900
constraints_copy [row [0 ]] = row [1 :]
888
- self .assertEqual (constraints_initial , constraints_copy )
901
+ self .assertEqual (constraints_initial , constraints_copy , \
902
+ "mismatch in partitions' constraints under the command: %s" % dump_restore_cmd )
889
903
890
904
# clear copy database
891
905
node .psql ('copy' , 'drop schema public cascade' )
0 commit comments