From dd99468e7bbc11b0c72230bd29ebb1cc6bf66b91 Mon Sep 17 00:00:00 2001 From: Mikhail Korotov Date: Mon, 4 Nov 2019 20:13:49 +0300 Subject: [PATCH] Created integration test for part_log table --- .../test_part_log_table/__init__.py | 0 .../config_with_non_standard_part_log.xml | 6 +++ .../configs/config_with_standard_part_log.xml | 4 ++ .../integration/test_part_log_table/test.py | 42 +++++++++++++++++++ 4 files changed, 52 insertions(+) create mode 100644 dbms/tests/integration/test_part_log_table/__init__.py create mode 100644 dbms/tests/integration/test_part_log_table/configs/config_with_non_standard_part_log.xml create mode 100644 dbms/tests/integration/test_part_log_table/configs/config_with_standard_part_log.xml create mode 100644 dbms/tests/integration/test_part_log_table/test.py diff --git a/dbms/tests/integration/test_part_log_table/__init__.py b/dbms/tests/integration/test_part_log_table/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/dbms/tests/integration/test_part_log_table/configs/config_with_non_standard_part_log.xml b/dbms/tests/integration/test_part_log_table/configs/config_with_non_standard_part_log.xml new file mode 100644 index 00000000000..2a8655de830 --- /dev/null +++ b/dbms/tests/integration/test_part_log_table/configs/config_with_non_standard_part_log.xml @@ -0,0 +1,6 @@ + + + database_name + table_name
+
+
diff --git a/dbms/tests/integration/test_part_log_table/configs/config_with_standard_part_log.xml b/dbms/tests/integration/test_part_log_table/configs/config_with_standard_part_log.xml new file mode 100644 index 00000000000..1e640a9e0b0 --- /dev/null +++ b/dbms/tests/integration/test_part_log_table/configs/config_with_standard_part_log.xml @@ -0,0 +1,4 @@ + + + + diff --git a/dbms/tests/integration/test_part_log_table/test.py b/dbms/tests/integration/test_part_log_table/test.py new file mode 100644 index 00000000000..7beef43a33e --- /dev/null +++ b/dbms/tests/integration/test_part_log_table/test.py @@ -0,0 +1,42 @@ +import time +import pytest + +from helpers.cluster import ClickHouseCluster + +cluster = ClickHouseCluster(__file__) +node1 = cluster.add_instance("node1") +node2 = cluster.add_instance("node2", main_configs=["configs/config_with_standard_part_log.xml"]) +node3 = cluster.add_instance("node3", main_configs=["configs/config_with_non_standard_part_log.xml"]) + +@pytest.fixture(scope="module") +def start_cluster(): + try: + cluster.start() + yield cluster + finally: + cluster.shutdown() + +def test_config_without_part_log(start_cluster): + assert "Table system.part_log doesn't exist" in node1.query_and_get_error("SELECT * FROM system.part_log") + node1.query("CREATE TABLE test_table(word String, value UInt64) ENGINE=MergeTree() ORDER BY value") + assert "Table system.part_log doesn't exist" in node1.query_and_get_error("SELECT * FROM system.part_log") + node1.query("INSERT INTO test_table VALUES ('name', 1)") + assert "Table system.part_log doesn't exist" in node1.query_and_get_error("SELECT * FROM system.part_log") + +def test_config_with_standard_part_log(start_cluster): + assert "Table system.part_log doesn't exist" in node2.query_and_get_error("SELECT * FROM system.part_log") + node2.query("CREATE TABLE test_table(word String, value UInt64) ENGINE=MergeTree() Order by value") + assert "Table system.part_log doesn't exist" in node2.query_and_get_error("SELECT * FROM system.part_log") + node2.query("INSERT INTO test_table VALUES ('name', 1)") + time.sleep(10) + assert node2.query("SELECT * FROM system.part_log") != "" + +def test_config_with_non_standard_part_log(start_cluster): + node3.query("CREATE DATABASE database_name") + assert "table_name" not in node3.query("SHOW TABLES FROM database_name") + node3.query("CREATE TABLE test_table(word String, value UInt64) ENGINE=MergeTree() ORDER BY value") + assert "table_name" not in node3.query("SHOW TABLES FROM database_name") + node3.query("INSERT INTO test_table VALUES ('name', 1)") + time.sleep(10) + assert "table_name" in node3.query("SHOW TABLES FROM database_name") +