@@ -87,7 +87,7 @@ def cleanup_folder(p):
8787
8888#--------------------------------------------
8989
90- def reset_replication (act_db_main , act_db_repl , db_main_file , db_repl_file ):
90+ def reset_replication (act_db_main , act_db_repl , db_main_file , db_repl_file , cleanup_repl_dirs = True ):
9191 out_reset = ''
9292
9393 with act_db_main .connect_server () as srv :
@@ -116,9 +116,11 @@ def reset_replication(act_db_main, act_db_repl, db_main_file, db_repl_file):
116116 os .unlink (f )
117117
118118 # Clean folders repl_journal and repl_archive: remove all files from there.
119- for p in (repl_jrn_sub_dir ,repl_arc_sub_dir ):
120- if cleanup_folder (repl_root_path / p ) > 0 :
121- out_reset += f"Directory { str (p )} remains non-empty.\n "
119+ #
120+ if cleanup_repl_dirs :
121+ for p in (repl_jrn_sub_dir ,repl_arc_sub_dir ):
122+ if cleanup_folder (repl_root_path / p ) > 0 :
123+ out_reset += f"Directory { str (p )} remains non-empty.\n "
122124
123125 if out_reset == '' :
124126 for a in (act_db_main ,act_db_repl ):
@@ -382,6 +384,16 @@ def generate_inject_setting_sql(working_mode, mcode, new_value, allow_insert_if_
382384
383385 return sql_adjust_settings_table
384386
387+ #--------------------------------------------
388+ def get_replication_log (a : Action ):
389+
390+ replication_log = a .home_dir / 'replication.log'
391+ rlog_lines = []
392+ with open (replication_log , 'r' ) as f :
393+ rlog_lines = f .readlines ()
394+
395+ return rlog_lines
396+
385397#--------------------------------------------
386398
387399@pytest .mark .version ('>=4.0.1' )
@@ -402,6 +414,9 @@ def test_1(act_db_main: Action, act_db_repl: Action, tmp_oltp_build_sql: Path,
402414 db_info [a , 'db_full_path' ] = con .info .name
403415
404416
417+ repl_log_old = get_replication_log (act_db_main )
418+ repl_log_new = repl_log_old .copy ()
419+
405420 # Must be EMPTY:
406421 out_prep = capsys .readouterr ().out
407422 if out_prep :
@@ -468,6 +483,7 @@ def test_1(act_db_main: Action, act_db_repl: Action, tmp_oltp_build_sql: Path,
468483 for p in tmp_oltp_sql_files :
469484 p .unlink (missing_ok = True )
470485
486+ repl_log_new = get_replication_log (act_db_main )
471487
472488 if out_prep :
473489 # Some problem raised during execution of initial SQL
@@ -499,6 +515,7 @@ def test_1(act_db_main: Action, act_db_repl: Action, tmp_oltp_build_sql: Path,
499515 watch_replica ( act_db_repl , MAX_TIME_FOR_WAIT_DATA_IN_REPLICA , ddl_ready_query , isql_check_script , isql_expected_out )
500516 # Must be EMPTY:
501517 out_main = capsys .readouterr ().out
518+ repl_log_new = get_replication_log (act_db_main )
502519
503520 drop_db_objects (act_db_main , act_db_repl , capsys )
504521 # Must be EMPTY:
@@ -508,7 +525,7 @@ def test_1(act_db_main: Action, act_db_repl: Action, tmp_oltp_build_sql: Path,
508525 # We have a problem either with DDL/DML or with dropping DB objects.
509526 # First, we have to RECREATE both master and slave databases
510527 # (otherwise further execution of this test or other replication-related tests most likely will fail):
511- out_reset = reset_replication (act_db_main , act_db_repl , db_info [act_db_main ,'db_full_path' ], db_info [act_db_repl ,'db_full_path' ])
528+ out_reset = reset_replication (act_db_main , act_db_repl , db_info [act_db_main ,'db_full_path' ], db_info [act_db_repl ,'db_full_path' ], cleanup_repl_dirs = True )
512529
513530 # Next, we display out_main, out_drop and out_reset:
514531 #
@@ -522,4 +539,10 @@ def test_1(act_db_main: Action, act_db_repl: Action, tmp_oltp_build_sql: Path,
522539 if out_reset .strip ():
523540 print ('out_reset:\n ' , out_reset )
524541
542+ # Finally, we have to show content of replication.log afte this test started:
543+ print ('Lines that did appear in replication.log during test run:' )
544+ for line in unified_diff (repl_log_old , repl_log_new ):
545+ if line .startswith ('+' ) and line [2 :].strip ():
546+ print (line .strip ())
547+
525548 assert '' == capsys .readouterr ().out
0 commit comments