Add more tests and handle correctly missing include

This commit is contained in:
Nicolae Vartolomei 2021-05-24 13:34:39 +01:00
parent 4c3882f2f9
commit 700850a970
7 changed files with 41 additions and 7 deletions

View File

@ -318,8 +318,13 @@ void ConfigProcessor::doIncludesRecursive(
else if (throw_on_bad_incl)
throw Poco::Exception(error_msg + name);
else
{
if (node->nodeName() == "include")
node->parentNode()->removeChild(node);
LOG_WARNING(log, "{}{}", error_msg, name);
}
}
else
{
/// Replace the whole node not just contents.

View File

@ -10,5 +10,8 @@
<profile>default</profile>
<quota>default</quota>
</default>
<include incl="users_1" />
<include incl="users_2" />
</users>
</yandex>

View File

@ -1,5 +1,5 @@
<yandex>
<include_from>/etc/clickhouse-server/config.d/max_query_size.xml</include_from>
<include_from>/etc/clickhouse-server/config.d/include_from_source.xml</include_from>
<profiles>
<default>
<max_query_size incl="mqs" />
@ -11,5 +11,8 @@
<profile>default</profile>
<quota>default</quota>
</default>
<include incl="users_1" />
<include incl="users_2" />
</users>
</yandex>

View File

@ -11,5 +11,7 @@
<profile>default</profile>
<quota>default</quota>
</default>
<include incl="node_does_not_exist" />
</users>
</yandex>

View File

@ -0,0 +1,17 @@
<yandex>
<mqs>99999</mqs>
<users_1>
<user_1>
<password></password>
<profile>default</profile>
</user_1>
</users_1>
<users_2>
<user_2>
<password></password>
<profile>default</profile>
</user_2>
</users_2>
</yandex>

View File

@ -1,3 +0,0 @@
<yandex>
<mqs>99999</mqs>
</yandex>

View File

@ -8,11 +8,11 @@ node2 = cluster.add_instance('node2', user_configs=['configs/config_env.xml'],
env_variables={"MAX_QUERY_SIZE": "55555"})
node3 = cluster.add_instance('node3', user_configs=['configs/config_zk.xml'], with_zookeeper=True)
node4 = cluster.add_instance('node4', user_configs=['configs/config_incl.xml'],
main_configs=['configs/max_query_size.xml']) # include value 77777
main_configs=['configs/include_from_source.xml']) # include value 77777
node5 = cluster.add_instance('node5', user_configs=['configs/config_allow_databases.xml'])
node6 = cluster.add_instance('node6', user_configs=['configs/config_include_from_env.xml'],
env_variables={"INCLUDE_FROM_ENV": "/etc/clickhouse-server/config.d/max_query_size.xml"},
main_configs=['configs/max_query_size.xml'])
env_variables={"INCLUDE_FROM_ENV": "/etc/clickhouse-server/config.d/include_from_source.xml"},
main_configs=['configs/include_from_source.xml'])
@pytest.fixture(scope="module")
@ -40,6 +40,13 @@ def test_config(start_cluster):
def test_include_config(start_cluster):
# <include incl="source tag" />
assert node4.query("select 1")
assert node4.query("select 1", user="user_1")
assert node4.query("select 1", user="user_2")
# <include from_zk="zk path />
assert node3.query("select 1")
assert node3.query("select 1", user="user_1")
assert node3.query("select 1", user="user_2")