Skip to content

Commit b294c83

Browse files
committed
Try fix tests #2
1 parent 7e2fcb0 commit b294c83

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

mysql_ch_replicator/binlog_replicator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ class BinlogReplicator:
340340
SAVE_UPDATE_INTERVAL = 60
341341
BINLOG_CLEAN_INTERVAL = 5 * 60
342342
BINLOG_RETENTION_PERIOD = 12 * 60 * 60
343-
READ_LOG_INTERVAL = 1
343+
READ_LOG_INTERVAL = 0.3
344344

345345
def __init__(self, settings: Settings):
346346
self.settings = settings

mysql_ch_replicator/db_replicator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class DbReplicator:
103103
DATA_DUMP_INTERVAL = 1
104104
DATA_DUMP_BATCH_SIZE = 100000
105105

106-
READ_LOG_INTERVAL = 1
106+
READ_LOG_INTERVAL = 0.3
107107

108108
def __init__(self, config: Settings, database: str, target_database: str = None, initial_only: bool = False):
109109
self.config = config

test_mysql_ch_replicator.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ def test_e2e_regular(config_file):
207207
mysql.execute(f'DROP TABLE {TEST_TABLE_NAME_3}')
208208
assert_wait(lambda: TEST_TABLE_NAME_3 not in ch.get_tables())
209209

210+
db_replicator_runner.stop()
211+
210212

211213
def test_e2e_multistatement():
212214
cfg = config.Settings()
@@ -272,6 +274,9 @@ def test_e2e_multistatement():
272274

273275
assert_wait(lambda: TEST_TABLE_NAME_2 in ch.get_tables())
274276

277+
db_replicator_runner.stop()
278+
binlog_replicator_runner.stop()
279+
275280

276281
def get_binlog_replicator_pid(cfg: config.Settings):
277282
path = os.path.join(
@@ -516,11 +521,15 @@ def test_initial_only():
516521

517522
ch.execute_command(f'DROP DATABASE {TEST_DB_NAME}')
518523

524+
db_replicator_runner.stop()
525+
519526
db_replicator_runner = DbReplicatorRunner(TEST_DB_NAME, additional_arguments='--initial_only=True')
520527
db_replicator_runner.run()
521528
db_replicator_runner.wait_complete()
522529
assert TEST_DB_NAME in ch.get_databases()
523530

531+
db_replicator_runner.stop()
532+
524533

525534
def test_database_tables_filtering():
526535
cfg = config.Settings()
@@ -677,6 +686,9 @@ def test_datetime_exception():
677686
assert_wait(lambda: str(ch.select(TEST_TABLE_NAME, where="name='Alex'")[0]['test_date']) == '2015-06-02')
678687
assert_wait(lambda: str(ch.select(TEST_TABLE_NAME, where="name='Ivan'")[0]['test_date']) == '2015-05-28')
679688

689+
db_replicator_runner.stop()
690+
binlog_replicator_runner.stop()
691+
680692

681693
def test_different_types_1():
682694
cfg = config.Settings()
@@ -760,6 +772,8 @@ def test_different_types_1():
760772
)
761773
assert_wait(lambda: len(ch.select(TEST_TABLE_NAME)) == 3)
762774

775+
db_replicator_runner.stop()
776+
binlog_replicator_runner.stop()
763777

764778
def test_numeric_types_and_limits():
765779
cfg = config.Settings()
@@ -826,6 +840,9 @@ def test_numeric_types_and_limits():
826840
assert_wait(lambda: len(ch.select(TEST_TABLE_NAME, 'test6=4294967280')) == 1)
827841
assert_wait(lambda: len(ch.select(TEST_TABLE_NAME, 'test7=18446744073709551586')) == 2)
828842

843+
db_replicator_runner.stop()
844+
binlog_replicator_runner.stop()
845+
829846

830847
def test_different_types_2():
831848
cfg = config.Settings()
@@ -892,6 +909,9 @@ def test_different_types_2():
892909
)
893910
assert_wait(lambda: len(ch.select(TEST_TABLE_NAME)) == 3)
894911

912+
db_replicator_runner.stop()
913+
binlog_replicator_runner.stop()
914+
895915

896916
def test_json():
897917
cfg = config.Settings()
@@ -948,6 +968,9 @@ def test_json():
948968
assert json.loads(ch.select(TEST_TABLE_NAME, "name='Ivan'")[0]['data'])['c'] == [1, 2, 3]
949969
assert json.loads(ch.select(TEST_TABLE_NAME, "name='Peter'")[0]['data'])['c'] == [3, 2, 1]
950970

971+
db_replicator_runner.stop()
972+
binlog_replicator_runner.stop()
973+
951974

952975
def test_string_primary_key(monkeypatch):
953976
monkeypatch.setattr(DbReplicator, 'INITIAL_REPLICATION_BATCH_SIZE', 1)
@@ -1007,6 +1030,9 @@ def test_string_primary_key(monkeypatch):
10071030
)
10081031
assert_wait(lambda: len(ch.select(TEST_TABLE_NAME)) == 3)
10091032

1033+
db_replicator_runner.stop()
1034+
binlog_replicator_runner.stop()
1035+
10101036

10111037
def test_parse_mysql_table_structure():
10121038
query = "CREATE TABLE IF NOT EXISTS user_preferences_portal (\n\t\t\tid char(36) NOT NULL,\n\t\t\tcategory varchar(50) DEFAULT NULL,\n\t\t\tdeleted tinyint(1) DEFAULT 0,\n\t\t\tdate_entered datetime DEFAULT NULL,\n\t\t\tdate_modified datetime DEFAULT NULL,\n\t\t\tassigned_user_id char(36) DEFAULT NULL,\n\t\t\tcontents longtext DEFAULT NULL\n\t\t ) ENGINE=InnoDB DEFAULT CHARSET=utf8"

0 commit comments

Comments
 (0)