From 81fceb38d9e4cf3fb4c9921fe0b79004f5f5375e Mon Sep 17 00:00:00 2001 From: Nikita Mikhaylov Date: Thu, 1 Apr 2021 17:14:54 +0300 Subject: [PATCH] add test --- .../test_cluster_copier/configs/users.xml | 8 +++ .../test_cluster_copier/task_self_copy.xml | 64 +++++++++++++++++++ tests/integration/test_cluster_copier/test.py | 30 +++++++++ 3 files changed, 102 insertions(+) create mode 100644 tests/integration/test_cluster_copier/task_self_copy.xml diff --git a/tests/integration/test_cluster_copier/configs/users.xml b/tests/integration/test_cluster_copier/configs/users.xml index e742d4f05a6..d27ca56eec7 100644 --- a/tests/integration/test_cluster_copier/configs/users.xml +++ b/tests/integration/test_cluster_copier/configs/users.xml @@ -17,6 +17,14 @@ default default + + 12345678 + + ::/0 + + default + default + diff --git a/tests/integration/test_cluster_copier/task_self_copy.xml b/tests/integration/test_cluster_copier/task_self_copy.xml new file mode 100644 index 00000000000..e0e35ccfe99 --- /dev/null +++ b/tests/integration/test_cluster_copier/task_self_copy.xml @@ -0,0 +1,64 @@ + + + 9440 + + + + false + + s0_0_0 + 9000 + dbuser + 12345678 + 0 + + + + + + + false + + s0_0_0 + 9000 + dbuser + 12345678 + 0 + + + + + + 2 + + + 1 + + + + 0 + + + + 3 + 1 + + + + + source_cluster + db1 + source_table + + destination_cluster + db2 + destination_table + + + ENGINE = MergeTree PARTITION BY a ORDER BY a SETTINGS index_granularity = 8192 + + + rand() + + + \ No newline at end of file diff --git a/tests/integration/test_cluster_copier/test.py b/tests/integration/test_cluster_copier/test.py index d87969630cd..57f9d150c8d 100644 --- a/tests/integration/test_cluster_copier/test.py +++ b/tests/integration/test_cluster_copier/test.py @@ -251,6 +251,31 @@ class Task_non_partitioned_table: instance = cluster.instances['s1_1_0'] instance.query("DROP TABLE copier_test1_1") +class Task_self_copy: + + def __init__(self, cluster): + self.cluster = cluster + self.zk_task_path = "/clickhouse-copier/task_self_copy" + self.copier_task_config = open(os.path.join(CURRENT_TEST_DIR, 'task_self_copy.xml'), 'r').read() + + def start(self): + instance = cluster.instances['s0_0_0'] + instance.query("CREATE DATABASE db1;") + instance.query( + "CREATE TABLE db1.source_table (`a` Int8, `b` String, `c` Int8) ENGINE = MergeTree PARTITION BY a ORDER BY a SETTINGS index_granularity = 8192") + instance.query("CREATE DATABASE db2;") + instance.query( + "CREATE TABLE db2.destination_table (`a` Int8, `b` String, `c` Int8) ENGINE = MergeTree PARTITION BY a ORDER BY a SETTINGS index_granularity = 8192") + instance.query("INSERT INTO db1.source_table VALUES (1, 'ClickHouse', 1);") + instance.query("INSERT INTO db1.source_table VALUES (2, 'Copier', 2);") + + def check(self): + instance = cluster.instances['s0_0_0'] + assert TSV(instance.query("SELECT * FROM db2.destination_table ORDER BY a")) == TSV(instance.query("SELECT * FROM db1.source_table ORDER BY a")) + instance = cluster.instances['s0_0_0'] + instance.query("DROP DATABASE db1 SYNC") + instance.query("DROP DATABASE db2 SYNC") + def execute_task(task, cmd_options): task.start() @@ -380,9 +405,14 @@ def test_no_index(started_cluster): def test_no_arg(started_cluster): execute_task(Task_no_arg(started_cluster), []) + def test_non_partitioned_table(started_cluster): execute_task(Task_non_partitioned_table(started_cluster), []) + +def test_self_copy(started_cluster): + execute_task(Task_self_copy(started_cluster), []) + if __name__ == '__main__': with contextmanager(started_cluster)() as cluster: for name, instance in list(cluster.instances.items()):