mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 15:42:02 +00:00
Fix test.
This commit is contained in:
parent
f9869b7d7e
commit
acb8cf1849
@ -7,5 +7,8 @@
|
||||
<stdout>/var/log/clickhouse-server/stdout.log</stdout>
|
||||
</logger>
|
||||
|
||||
<path>/var/lib/clickhouse/</path>
|
||||
|
||||
<mark_cache_size>5368709120</mark_cache_size>
|
||||
<users_config>users.xml</users_config>
|
||||
</yandex>
|
||||
|
@ -1,3 +1,23 @@
|
||||
<?xml version="1.0"?>
|
||||
<yandex>
|
||||
<profiles>
|
||||
<default>
|
||||
</default>
|
||||
</profiles>
|
||||
|
||||
<users>
|
||||
<default>
|
||||
<password></password>
|
||||
<networks incl="networks" replace="replace">
|
||||
<ip>::/0</ip>
|
||||
</networks>
|
||||
<profile>default</profile>
|
||||
<quota>default</quota>
|
||||
</default>
|
||||
</users>
|
||||
|
||||
<quotas>
|
||||
<default>
|
||||
</default>
|
||||
</quotas>
|
||||
</yandex>
|
||||
|
@ -1,3 +1,4 @@
|
||||
import docker
|
||||
import os
|
||||
import pwd
|
||||
import pytest
|
||||
@ -6,32 +7,36 @@ import re
|
||||
from helpers.cluster import ClickHouseCluster
|
||||
|
||||
|
||||
def expect_failure_with_message(config, expected_message):
|
||||
def expect_failure_with_message(expected_message):
|
||||
cluster = ClickHouseCluster(__file__)
|
||||
node = cluster.add_instance('node', main_configs=[config], with_zookeeper=False)
|
||||
node = cluster.add_instance('node', with_zookeeper=False)
|
||||
|
||||
with pytest.raises(Exception):
|
||||
cluster.start()
|
||||
|
||||
current_user_id = os.getuid()
|
||||
other_user_id = pwd.getpwnam('nobody').pw_uid
|
||||
|
||||
docker_api = docker.from_env().api
|
||||
container = node.get_docker_handle()
|
||||
container.start()
|
||||
container.exec_run('chown {0} /var/lib/clickhouse'.format(other_user_id), privileged=True)
|
||||
container.exec_run('clickhouse server --config-file=/etc/clickhouse-server/config.xml --log-file=/var/log/clickhouse-server/clickhouse-server.log --errorlog-file=/var/log/clickhouse-server/clickhouse-server.err.log', privileged=True)
|
||||
|
||||
cluster.shutdown() # cleanup
|
||||
|
||||
with open(os.path.join(node.path, 'logs/stderr.log')) as log:
|
||||
with open(os.path.join(node.path, 'logs/clickhouse-server.err.log')) as log:
|
||||
last_message = log.readlines()[-1].strip()
|
||||
if re.search(expected_message, last_message) is None:
|
||||
pytest.fail('Expected the server to fail with a message "{}", but the last message is "{}"'.format(expected_message, last_message))
|
||||
|
||||
|
||||
def test_no_such_directory():
|
||||
expect_failure_with_message('configs/no_such_directory.xml', 'Failed to stat.*no_such_directory')
|
||||
|
||||
|
||||
def test_different_user():
|
||||
current_user_id = os.getuid()
|
||||
|
||||
if current_user_id != 0:
|
||||
if current_user_id == 0:
|
||||
current_user_name = pwd.getpwuid(current_user_id).pw_name
|
||||
|
||||
expect_failure_with_message(
|
||||
'configs/owner_mismatch.xml',
|
||||
'Effective user of the process \(({}|{})\) does not match the owner of the data \((0|root)\)'.format(current_user_id, current_user_name),
|
||||
'Effective user of the process \(.*\) does not match the owner of the data \(.*\)',
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user