mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Fix tests.
This commit is contained in:
parent
41b0ba98dd
commit
902d7860da
@ -2,6 +2,7 @@ import pytest
|
||||
import os
|
||||
import time
|
||||
from helpers.cluster import ClickHouseCluster
|
||||
from helpers.client import QueryTimeoutExceedException
|
||||
from helpers.test_tools import assert_eq_with_retry
|
||||
|
||||
SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
|
||||
@ -53,8 +54,9 @@ def test_reload_while_loading(started_cluster):
|
||||
assert get_status('slow') == "NOT_LOADED"
|
||||
assert get_loading_duration('slow') == 0
|
||||
|
||||
# It's not possible to get a value from the dictionary within 1.0 second, so the following query fails by timeout.
|
||||
assert query("SELECT dictGetInt32('slow', 'a', toUInt64(5))", timeout = 1, ignore_error = True) == ""
|
||||
# It's not possible to get a value from the dictionary within 0.5 second, so the following query fails by timeout.
|
||||
with pytest.raises(QueryTimeoutExceedException):
|
||||
query("SELECT dictGetInt32('slow', 'a', toUInt64(5))", timeout = 0.5)
|
||||
|
||||
# The dictionary is now loading.
|
||||
assert get_status('slow') == "LOADING"
|
||||
@ -69,7 +71,8 @@ def test_reload_while_loading(started_cluster):
|
||||
assert duration >= prev_duration
|
||||
|
||||
# SYSTEM RELOAD DICTIONARY should restart loading.
|
||||
query("SYSTEM RELOAD DICTIONARY 'slow'")
|
||||
with pytest.raises(QueryTimeoutExceedException):
|
||||
query("SYSTEM RELOAD DICTIONARY 'slow'", timeout = 0.5)
|
||||
assert get_status('slow') == "LOADING"
|
||||
prev_start_time, prev_duration = start_time, duration
|
||||
start_time, duration = get_loading_start_time('slow'), get_loading_duration('slow')
|
||||
@ -83,15 +86,7 @@ def test_reload_while_loading(started_cluster):
|
||||
assert start_time == prev_start_time
|
||||
assert duration >= prev_duration
|
||||
|
||||
# SYSTEM RELOAD DICTIONARIES should restart loading again.
|
||||
query("SYSTEM RELOAD DICTIONARIES")
|
||||
assert get_status('slow') == "LOADING"
|
||||
prev_start_time, prev_duration = start_time, duration
|
||||
start_time, duration = get_loading_start_time('slow'), get_loading_duration('slow')
|
||||
assert start_time > prev_start_time
|
||||
assert duration < prev_duration
|
||||
|
||||
# Changing the configuration file should restart loading one more time.
|
||||
# Changing the configuration file should restart loading again.
|
||||
replace_in_file_in_container('/etc/clickhouse-server/config.d/slow.xml', 'sleep 100', 'sleep 0')
|
||||
time.sleep(5) # Configuration files are reloaded once in 5 seconds.
|
||||
|
||||
@ -141,13 +136,13 @@ def test_reload_after_fail_by_system_reload(started_cluster):
|
||||
assert get_status("no_file") == "NOT_LOADED"
|
||||
|
||||
# We expect an error because the file source doesn't exist.
|
||||
expected_error = "No such file"
|
||||
assert expected_error in instance.query_and_get_error("SELECT dictGetInt32('no_file', 'a', toUInt64(9))")
|
||||
no_such_file_error = "No such file"
|
||||
assert no_such_file_error in instance.query_and_get_error("SELECT dictGetInt32('no_file', 'a', toUInt64(9))")
|
||||
assert get_status("no_file") == "FAILED"
|
||||
|
||||
# SYSTEM RELOAD should not change anything now, the status is still FAILED.
|
||||
query("SYSTEM RELOAD DICTIONARY 'no_file'")
|
||||
assert expected_error in instance.query_and_get_error("SELECT dictGetInt32('no_file', 'a', toUInt64(9))")
|
||||
assert no_such_file_error in instance.query_and_get_error("SYSTEM RELOAD DICTIONARY 'no_file'")
|
||||
assert no_such_file_error in instance.query_and_get_error("SELECT dictGetInt32('no_file', 'a', toUInt64(9))")
|
||||
assert get_status("no_file") == "FAILED"
|
||||
|
||||
# Creating the file source makes the dictionary able to load.
|
||||
@ -158,7 +153,7 @@ def test_reload_after_fail_by_system_reload(started_cluster):
|
||||
|
||||
# Removing the file source should not spoil the loaded dictionary.
|
||||
instance.exec_in_container("rm /etc/clickhouse-server/config.d/no_file.txt")
|
||||
query("SYSTEM RELOAD DICTIONARY 'no_file'")
|
||||
assert no_such_file_error in instance.query_and_get_error("SYSTEM RELOAD DICTIONARY 'no_file'")
|
||||
query("SELECT dictGetInt32('no_file', 'a', toUInt64(9))") == "10\n"
|
||||
assert get_status("no_file") == "LOADED"
|
||||
|
||||
|
@ -66,8 +66,6 @@ SELECT '==DROP DICTIONARY';
|
||||
|
||||
DROP DICTIONARY IF EXISTS ordinary_db.dict1;
|
||||
|
||||
SYSTEM RELOAD DICTIONARY 'ordinary_db.dict1'; -- due to lazy_load at can persist for some time
|
||||
|
||||
SHOW DICTIONARIES FROM ordinary_db LIKE 'dict1';
|
||||
|
||||
EXISTS DICTIONARY ordinary_db.dict1;
|
||||
|
@ -41,8 +41,6 @@ SELECT count(distinct(dictGetUInt8('database_for_dict.dict1', 'second_column', t
|
||||
|
||||
DETACH DICTIONARY database_for_dict.dict1;
|
||||
|
||||
SYSTEM RELOAD DICTIONARY 'database_for_dict.dict1';
|
||||
|
||||
SELECT dictGetUInt8('database_for_dict.dict1', 'second_column', toUInt64(11)); -- {serverError 36}
|
||||
|
||||
ATTACH DICTIONARY database_for_dict.dict1;
|
||||
@ -51,8 +49,6 @@ SELECT dictGetUInt8('database_for_dict.dict1', 'second_column', toUInt64(11));
|
||||
|
||||
DROP DICTIONARY database_for_dict.dict1;
|
||||
|
||||
SYSTEM RELOAD DICTIONARY 'database_for_dict.dict1';
|
||||
|
||||
SELECT dictGetUInt8('database_for_dict.dict1', 'second_column', toUInt64(11)); -- {serverError 36}
|
||||
|
||||
CREATE DICTIONARY database_for_dict.dict1
|
||||
@ -111,7 +107,7 @@ SELECT dictGetString('database_for_dict.dict3', 'some_column', toUInt64(12));
|
||||
|
||||
DROP TABLE database_for_dict.table_for_dict;
|
||||
|
||||
SYSTEM RELOAD DICTIONARIES;
|
||||
SYSTEM RELOAD DICTIONARIES; -- {serverError 60}
|
||||
|
||||
SELECT dictGetString('database_for_dict.dict3', 'some_column', toUInt64(12));
|
||||
|
||||
|
@ -3,7 +3,6 @@
|
||||
1
|
||||
SYSTEM RELOAD DICTIONARY
|
||||
0
|
||||
0
|
||||
10
|
||||
1
|
||||
CREATE DATABASE
|
||||
|
@ -17,8 +17,7 @@ SELECT dictGetUInt64('dict_db_01036.dict', 'val', toUInt64(0));
|
||||
SELECT query_count FROM system.dictionaries WHERE database = 'dict_db_01036' AND name = 'dict';
|
||||
|
||||
SELECT 'SYSTEM RELOAD DICTIONARY';
|
||||
SYSTEM RELOAD DICTIONARY 'dict_db_01036.dict';
|
||||
SELECT sleep(0.3);
|
||||
SYSTEM RELOAD DICTIONARY dict_db_01036.dict;
|
||||
SELECT query_count FROM system.dictionaries WHERE database = 'dict_db_01036' AND name = 'dict';
|
||||
SELECT dictGetUInt64('dict_db_01036.dict', 'val', toUInt64(0));
|
||||
SELECT query_count FROM system.dictionaries WHERE database = 'dict_db_01036' AND name = 'dict';
|
||||
|
@ -3,7 +3,6 @@
|
||||
1
|
||||
SYSTEM RELOAD DICTIONARY
|
||||
0
|
||||
0
|
||||
10
|
||||
1
|
||||
CREATE DATABASE
|
||||
|
@ -17,8 +17,7 @@ SELECT dictGetUInt64('foo 1234.dict', 'val', toUInt64(0));
|
||||
SELECT query_count FROM system.dictionaries WHERE database = 'foo 1234' AND name = 'dict';
|
||||
|
||||
SELECT 'SYSTEM RELOAD DICTIONARY';
|
||||
SYSTEM RELOAD DICTIONARY 'foo 1234.dict';
|
||||
SELECT sleep(0.3);
|
||||
SYSTEM RELOAD DICTIONARY `foo 1234`.dict;
|
||||
SELECT query_count FROM system.dictionaries WHERE database = 'foo 1234' AND name = 'dict';
|
||||
SELECT dictGetUInt64('foo 1234.dict', 'val', toUInt64(0));
|
||||
SELECT query_count FROM system.dictionaries WHERE database = 'foo 1234' AND name = 'dict';
|
||||
|
Loading…
Reference in New Issue
Block a user