From 5ef4b1947159b58998cd56f17a9e0a0e18581440 Mon Sep 17 00:00:00 2001 From: Vitaly Baranov Date: Tue, 4 Aug 2020 01:48:29 +0300 Subject: [PATCH] Add test for custom settings in users.xml --- .../helpers/0_common_instance_config.xml | 1 + .../test_custom_settings/__init__.py | 0 .../configs/config.d/text_log.xml | 3 ++ .../configs/users.d/custom_settings.xml | 18 ++++++++ .../integration/test_custom_settings/test.py | 41 +++++++++++++++++++ 5 files changed, 63 insertions(+) create mode 100644 tests/integration/test_custom_settings/__init__.py create mode 100644 tests/integration/test_custom_settings/configs/config.d/text_log.xml create mode 100644 tests/integration/test_custom_settings/configs/users.d/custom_settings.xml create mode 100644 tests/integration/test_custom_settings/test.py diff --git a/tests/integration/helpers/0_common_instance_config.xml b/tests/integration/helpers/0_common_instance_config.xml index 73ab595ab6..5377efbc24 100644 --- a/tests/integration/helpers/0_common_instance_config.xml +++ b/tests/integration/helpers/0_common_instance_config.xml @@ -1,6 +1,7 @@ Europe/Moscow 0.0.0.0 + custom_ /var/lib/clickhouse/ /var/lib/clickhouse/tmp/ diff --git a/tests/integration/test_custom_settings/__init__.py b/tests/integration/test_custom_settings/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/integration/test_custom_settings/configs/config.d/text_log.xml b/tests/integration/test_custom_settings/configs/config.d/text_log.xml new file mode 100644 index 0000000000..f386249f17 --- /dev/null +++ b/tests/integration/test_custom_settings/configs/config.d/text_log.xml @@ -0,0 +1,3 @@ + + + diff --git a/tests/integration/test_custom_settings/configs/users.d/custom_settings.xml b/tests/integration/test_custom_settings/configs/users.d/custom_settings.xml new file mode 100644 index 0000000000..f32d0f3626 --- /dev/null +++ b/tests/integration/test_custom_settings/configs/users.d/custom_settings.xml @@ -0,0 +1,18 @@ + + + + Int64_-5 + UInt64_10000000000 + Float64_-43.25e-1 + 'some text' + + + + 1 + + + + 1 + + + diff --git a/tests/integration/test_custom_settings/test.py b/tests/integration/test_custom_settings/test.py new file mode 100644 index 0000000000..444a4d2188 --- /dev/null +++ b/tests/integration/test_custom_settings/test.py @@ -0,0 +1,41 @@ +import pytest +from helpers.cluster import ClickHouseCluster + +cluster = ClickHouseCluster(__file__) +node = cluster.add_instance('node', config_dir='configs') + + +@pytest.fixture(scope="module", autouse=True) +def started_cluster(): + try: + cluster.start() + yield cluster + + finally: + cluster.shutdown() + + +def test(): + assert node.query("SELECT getSetting('custom_a')") == "-5\n" + assert node.query("SELECT getSetting('custom_b')") == "10000000000\n" + assert node.query("SELECT getSetting('custom_c')") == "-4.325\n" + assert node.query("SELECT getSetting('custom_d')") == "some text\n" + + assert "custom_a = -5, custom_b = 10000000000, custom_c = -4.325, custom_d = \\'some text\\'" \ + in node.query("SHOW CREATE SETTINGS PROFILE default") + + assert "no settings profile" in node.query_and_get_error("SHOW CREATE SETTINGS PROFILE profile_with_unknown_setting") + assert "no settings profile" in node.query_and_get_error("SHOW CREATE SETTINGS PROFILE profile_illformed_setting") + + +def test_invalid_settings(): + node.query("SYSTEM RELOAD CONFIG") + node.query("SYSTEM FLUSH LOGS") + + assert node.query("SELECT COUNT() FROM system.text_log WHERE" + " message LIKE '%Could not parse profile `profile_illformed_setting`%'" + " AND message LIKE '%Couldn\\'t restore Field from dump%'") == "1\n" + + assert node.query("SELECT COUNT() FROM system.text_log WHERE" + " message LIKE '%Could not parse profile `profile_with_unknown_setting`%'" + " AND message LIKE '%Setting x is neither a builtin setting nor started with the prefix \\'custom_\\'%'") == "1\n" -- GitLab