2019-11-12 09:52:59 +00:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
from helpers.cluster import ClickHouseCluster
|
|
|
|
|
|
|
|
cluster = ClickHouseCluster(__file__)
|
2019-12-02 08:23:02 +00:00
|
|
|
node = cluster.add_instance('node', main_configs=['configs/config.xml'])
|
2019-11-12 09:52:59 +00:00
|
|
|
path_to_userfiles_from_defaut_config = "user_files"
|
|
|
|
|
2020-09-16 04:26:10 +00:00
|
|
|
|
2019-11-12 09:52:59 +00:00
|
|
|
@pytest.fixture(scope="module")
|
|
|
|
def start_cluster():
|
|
|
|
try:
|
|
|
|
cluster.start()
|
|
|
|
yield cluster
|
|
|
|
finally:
|
|
|
|
cluster.shutdown()
|
|
|
|
|
2020-09-16 04:26:10 +00:00
|
|
|
|
2019-11-12 09:52:59 +00:00
|
|
|
def test_filepath(start_cluster):
|
|
|
|
# 2 rows data
|
2019-11-29 07:05:48 +00:00
|
|
|
some_data = "Test\t111.222\nData\t333.444"
|
2019-11-12 09:52:59 +00:00
|
|
|
|
2019-12-02 08:23:02 +00:00
|
|
|
node.exec_in_container(['bash', '-c', 'mkdir -p {}'.format(
|
|
|
|
path_to_userfiles_from_defaut_config
|
|
|
|
)], privileged=True, user='root')
|
|
|
|
|
2019-11-29 07:05:48 +00:00
|
|
|
node.exec_in_container(['bash', '-c', 'echo "{}" > {}'.format(
|
2019-11-12 09:52:59 +00:00
|
|
|
some_data,
|
|
|
|
path_to_userfiles_from_defaut_config + "/relative_user_file_test"
|
|
|
|
)], privileged=True, user='root')
|
|
|
|
|
|
|
|
test_requests = [("relative_user_file_test", "2"),
|
2019-11-29 07:05:48 +00:00
|
|
|
("../" + path_to_userfiles_from_defaut_config + "/relative_user_file_test", "2")]
|
2019-11-12 09:52:59 +00:00
|
|
|
|
|
|
|
for pattern, value in test_requests:
|
|
|
|
assert node.query('''
|
2019-12-02 08:23:02 +00:00
|
|
|
select count() from file('{}', 'TSV', 'text String, number Float64')
|
2019-11-12 09:52:59 +00:00
|
|
|
'''.format(pattern)) == '{}\n'.format(value)
|