mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 16:12:01 +00:00
Merge pull request #17614 from TCeason/add_mysql_killed_test_for_materializemysql
add integration test: MySQL killed while insert for MaterializeMySQL ENGINE
This commit is contained in:
commit
b25546ea50
@ -652,6 +652,45 @@ def mysql_kill_sync_thread_restore_test(clickhouse_node, mysql_node, service_nam
|
|||||||
mysql_node.query("DROP DATABASE test_database")
|
mysql_node.query("DROP DATABASE test_database")
|
||||||
|
|
||||||
|
|
||||||
|
def mysql_killed_while_insert(clickhouse_node, mysql_node, service_name):
|
||||||
|
mysql_node.query("CREATE DATABASE kill_mysql_while_insert")
|
||||||
|
mysql_node.query("CREATE TABLE kill_mysql_while_insert.test ( `id` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB;")
|
||||||
|
clickhouse_node.query("CREATE DATABASE kill_mysql_while_insert ENGINE = MaterializeMySQL('{}:3306', 'kill_mysql_while_insert', 'root', 'clickhouse')".format(service_name))
|
||||||
|
check_query(clickhouse_node, "SHOW TABLES FROM kill_mysql_while_insert FORMAT TSV", 'test\n')
|
||||||
|
|
||||||
|
try:
|
||||||
|
def insert(num):
|
||||||
|
for i in range(num):
|
||||||
|
query = "INSERT INTO kill_mysql_while_insert.test VALUES({v});".format( v = i + 1 )
|
||||||
|
mysql_node.query(query)
|
||||||
|
|
||||||
|
t = threading.Thread(target=insert, args=(10000,))
|
||||||
|
t.start()
|
||||||
|
|
||||||
|
subprocess.check_call(
|
||||||
|
['docker-compose', '-p', mysql_node.project_name, '-f', mysql_node.docker_compose, 'stop'])
|
||||||
|
finally:
|
||||||
|
with pytest.raises(QueryRuntimeException) as execption:
|
||||||
|
time.sleep(5)
|
||||||
|
clickhouse_node.query("SELECT count() FROM kill_mysql_while_insert.test")
|
||||||
|
assert "Master maybe lost." in str(execption.value)
|
||||||
|
|
||||||
|
subprocess.check_call(
|
||||||
|
['docker-compose', '-p', mysql_node.project_name, '-f', mysql_node.docker_compose, 'start'])
|
||||||
|
mysql_node.wait_mysql_to_start(120)
|
||||||
|
|
||||||
|
clickhouse_node.query("DETACH DATABASE kill_mysql_while_insert")
|
||||||
|
clickhouse_node.query("ATTACH DATABASE kill_mysql_while_insert")
|
||||||
|
|
||||||
|
result = mysql_node.query_and_get_data("SELECT COUNT(1) FROM kill_mysql_while_insert.test")
|
||||||
|
for row in result:
|
||||||
|
res = str(row[0]) + '\n'
|
||||||
|
check_query(clickhouse_node, "SELECT count() FROM kill_mysql_while_insert.test", res)
|
||||||
|
|
||||||
|
mysql_node.query("DROP DATABASE kill_mysql_while_insert")
|
||||||
|
clickhouse_node.query("DROP DATABASE kill_mysql_while_insert")
|
||||||
|
|
||||||
|
|
||||||
def clickhouse_killed_while_insert(clickhouse_node, mysql_node, service_name):
|
def clickhouse_killed_while_insert(clickhouse_node, mysql_node, service_name):
|
||||||
mysql_node.query("CREATE DATABASE kill_clickhouse_while_insert")
|
mysql_node.query("CREATE DATABASE kill_clickhouse_while_insert")
|
||||||
mysql_node.query("CREATE TABLE kill_clickhouse_while_insert.test ( `id` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB;")
|
mysql_node.query("CREATE TABLE kill_clickhouse_while_insert.test ( `id` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB;")
|
||||||
|
@ -212,9 +212,15 @@ def test_mysql_kill_sync_thread_restore_8_0(started_cluster, started_mysql_8_0):
|
|||||||
materialize_with_ddl.mysql_kill_sync_thread_restore_test(clickhouse_node, started_mysql_8_0, "mysql8_0")
|
materialize_with_ddl.mysql_kill_sync_thread_restore_test(clickhouse_node, started_mysql_8_0, "mysql8_0")
|
||||||
|
|
||||||
|
|
||||||
|
def test_mysql_killed_while_insert_5_7(started_cluster, started_mysql_5_7):
|
||||||
|
materialize_with_ddl.mysql_killed_while_insert(clickhouse_node, started_mysql_5_7, "mysql1")
|
||||||
|
|
||||||
|
def test_mysql_killed_while_insert_8_0(started_cluster, started_mysql_8_0):
|
||||||
|
materialize_with_ddl.mysql_killed_while_insert(clickhouse_node, started_mysql_8_0, "mysql8_0")
|
||||||
|
|
||||||
|
|
||||||
def test_clickhouse_killed_while_insert_5_7(started_cluster, started_mysql_5_7):
|
def test_clickhouse_killed_while_insert_5_7(started_cluster, started_mysql_5_7):
|
||||||
materialize_with_ddl.clickhouse_killed_while_insert(clickhouse_node, started_mysql_5_7, "mysql1")
|
materialize_with_ddl.clickhouse_killed_while_insert(clickhouse_node, started_mysql_5_7, "mysql1")
|
||||||
|
|
||||||
def test_clickhouse_killed_while_insert_8_0(started_cluster, started_mysql_8_0):
|
def test_clickhouse_killed_while_insert_8_0(started_cluster, started_mysql_8_0):
|
||||||
materialize_with_ddl.clickhouse_killed_while_insert(clickhouse_node, started_mysql_8_0, "mysql8_0")
|
materialize_with_ddl.clickhouse_killed_while_insert(clickhouse_node, started_mysql_8_0, "mysql8_0")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user