未验证 提交 8663d04b 编写于 作者: A Alexander Kuzmenkov 提交者: GitHub

Merge pull request #19298 from ClickHouse/aku/parallel-tests

Avoid mixing output from parallel test runs
......@@ -274,7 +274,9 @@ def run_tests_array(all_tests_with_params):
def print_test_time(test_time):
if args.print_time:
print(" {0:.2f} sec.".format(test_time), end='')
return " {0:.2f} sec.".format(test_time)
else:
return ''
if len(all_tests):
print("\nRunning {} {} tests.".format(len(all_tests), suite) + "\n")
......@@ -291,36 +293,43 @@ def run_tests_array(all_tests_with_params):
(name, ext) = os.path.splitext(case)
try:
status = ''
is_concurrent = multiprocessing.current_process().name != "MainProcess";
if not is_concurrent:
sys.stdout.flush()
sys.stdout.write("{0:72}".format(name + ": "))
# This flush is needed so you can see the test name of the long running test before it will finish.
# This flush is needed so you can see the test name of the long
# running test before it will finish. But don't do it in parallel
# mode, so that the lines don't mix.
sys.stdout.flush()
else:
status = "{0:72}".format(name + ": ");
if args.skip and any(s in name for s in args.skip):
print(MSG_SKIPPED + " - skip")
status += MSG_SKIPPED + " - skip\n"
skipped_total += 1
elif not args.zookeeper and ('zookeeper' in name
or 'replica' in name):
print(MSG_SKIPPED + " - no zookeeper")
status += MSG_SKIPPED + " - no zookeeper\n"
skipped_total += 1
elif not args.shard and ('shard' in name
or 'distributed' in name
or 'global' in name):
print(MSG_SKIPPED + " - no shard")
status += MSG_SKIPPED + " - no shard\n"
skipped_total += 1
elif not args.no_long and ('long' in name
# Tests for races and deadlocks usually are runned in loop
# for significant amount of time
or 'deadlock' in name
or 'race' in name):
print(MSG_SKIPPED + " - no long")
status += MSG_SKIPPED + " - no long\n"
skipped_total += 1
else:
disabled_file = os.path.join(suite_dir, name) + '.disabled'
if os.path.exists(disabled_file) and not args.disabled:
message = open(disabled_file, 'r').read()
print(MSG_SKIPPED + " - " + message)
status += MSG_SKIPPED + " - " + message + "\n"
else:
if args.testname:
......@@ -347,11 +356,11 @@ def run_tests_array(all_tests_with_params):
raise
failures += 1
print(MSG_FAIL, end='')
print_test_time(total_time)
print(" - Timeout!")
status += MSG_FAIL
status += print_test_time(total_time)
status += " - Timeout!\n"
if stderr:
print(stderr)
status += stderr
else:
counter = 1
while proc.returncode != 0 and need_retry(stderr):
......@@ -364,12 +373,12 @@ def run_tests_array(all_tests_with_params):
if proc.returncode != 0:
failures += 1
failures_chain += 1
print(MSG_FAIL, end='')
print_test_time(total_time)
print(" - return code {}".format(proc.returncode))
status += MSG_FAIL
status += print_test_time(total_time)
status += ' - return code {}\n'.format(proc.returncode)
if stderr:
print(stderr)
status += stderr
# Stop on fatal errors like segmentation fault. They are sent to client via logs.
if ' <Fatal> ' in stderr:
......@@ -379,46 +388,51 @@ def run_tests_array(all_tests_with_params):
SERVER_DIED = True
if os.path.isfile(stdout_file):
print(", result:\n")
print('\n'.join(open(stdout_file).read().split('\n')[:100]))
status += ", result:\n\n"
status += '\n'.join(
open(stdout_file).read().split('\n')[:100])
status += '\n';
elif stderr:
failures += 1
failures_chain += 1
print(MSG_FAIL, end='')
print_test_time(total_time)
print(" - having stderror:\n{}".format(
'\n'.join(stderr.split('\n')[:100])))
status += MSG_FAIL
status += print_test_time(total_time)
status += " - having stderror:\n{}\n".format(
'\n'.join(stderr.split('\n')[:100]))
elif 'Exception' in stdout:
failures += 1
failures_chain += 1
print(MSG_FAIL, end='')
print_test_time(total_time)
print(" - having exception:\n{}".format(
'\n'.join(stdout.split('\n')[:100])))
status += MSG_FAIL
status += print_test_time(total_time)
status += " - having exception:\n{}\n".format(
'\n'.join(stdout.split('\n')[:100]))
elif not os.path.isfile(reference_file):
print(MSG_UNKNOWN, end='')
print_test_time(total_time)
print(" - no reference file")
status += MSG_UNKNOWN
status += print_test_time(total_time)
status += " - no reference file\n"
else:
result_is_different = subprocess.call(['diff', '-q', reference_file, stdout_file], stdout=PIPE)
if result_is_different:
diff = Popen(['diff', '-U', str(args.unified), reference_file, stdout_file], stdout=PIPE, universal_newlines=True).communicate()[0]
failures += 1
print(MSG_FAIL, end='')
print_test_time(total_time)
print(" - result differs with reference:\n{}".format(diff))
status += MSG_FAIL
status += print_test_time(total_time)
status += " - result differs with reference:\n{}\n".format(diff)
else:
passed_total += 1
failures_chain = 0
print(MSG_OK, end='')
print_test_time(total_time)
print()
status += MSG_OK
status += print_test_time(total_time)
status += "\n"
if os.path.exists(stdout_file):
os.remove(stdout_file)
if os.path.exists(stderr_file):
os.remove(stderr_file)
sys.stdout.write(status)
sys.stdout.flush()
except KeyboardInterrupt as e:
print(colored("Break tests execution", args, "red"))
raise e
......
122
Table dictdb.dict_invalidate doesn\'t exist
Table dictdb_01041_01040.dict_invalidate doesn\'t exist
133
......@@ -5,12 +5,12 @@ CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
. "$CURDIR"/../shell_config.sh
$CLICKHOUSE_CLIENT --query "DROP DATABASE IF EXISTS dictdb"
$CLICKHOUSE_CLIENT --query "DROP DATABASE IF EXISTS dictdb_01041_01040"
$CLICKHOUSE_CLIENT --query "CREATE DATABASE dictdb"
$CLICKHOUSE_CLIENT --query "CREATE DATABASE dictdb_01041_01040"
$CLICKHOUSE_CLIENT --query "
CREATE TABLE dictdb.dict_invalidate
CREATE TABLE dictdb_01041_01040.dict_invalidate
ENGINE = Memory AS
SELECT
122 as dummy,
......@@ -19,31 +19,31 @@ FROM system.one"
$CLICKHOUSE_CLIENT --query "
CREATE DICTIONARY dictdb.invalidate
CREATE DICTIONARY dictdb_01041_01040.invalidate
(
dummy UInt64,
two UInt8 EXPRESSION dummy
)
PRIMARY KEY dummy
SOURCE(CLICKHOUSE(HOST 'localhost' PORT tcpPort() USER 'default' TABLE 'dict_invalidate' DB 'dictdb' INVALIDATE_QUERY 'select max(last_time) from dictdb.dict_invalidate'))
SOURCE(CLICKHOUSE(HOST 'localhost' PORT tcpPort() USER 'default' TABLE 'dict_invalidate' DB 'dictdb_01041_01040' INVALIDATE_QUERY 'select max(last_time) from dictdb_01041_01040.dict_invalidate'))
LIFETIME(MIN 0 MAX 1)
LAYOUT(FLAT())"
$CLICKHOUSE_CLIENT --query "SELECT dictGetUInt8('dictdb.invalidate', 'two', toUInt64(122))"
$CLICKHOUSE_CLIENT --query "SELECT dictGetUInt8('dictdb_01041_01040.invalidate', 'two', toUInt64(122))"
# No exception happened
$CLICKHOUSE_CLIENT --query "SELECT last_exception FROM system.dictionaries WHERE database = 'dictdb' AND name = 'invalidate'"
$CLICKHOUSE_CLIENT --query "SELECT last_exception FROM system.dictionaries WHERE database = 'dictdb_01041_01040' AND name = 'invalidate'"
$CLICKHOUSE_CLIENT --query "DROP TABLE dictdb.dict_invalidate"
$CLICKHOUSE_CLIENT --query "DROP TABLE dictdb_01041_01040.dict_invalidate"
function check_exception_detected()
{
query_result=$($CLICKHOUSE_CLIENT --query "SELECT last_exception FROM system.dictionaries WHERE database = 'dictdb' AND name = 'invalidate'" 2>&1)
query_result=$($CLICKHOUSE_CLIENT --query "SELECT last_exception FROM system.dictionaries WHERE database = 'dictdb_01041_01040' AND name = 'invalidate'" 2>&1)
while [ -z "$query_result" ]
do
query_result=$($CLICKHOUSE_CLIENT --query "SELECT last_exception FROM system.dictionaries WHERE database = 'dictdb' AND name = 'invalidate'" 2>&1)
query_result=$($CLICKHOUSE_CLIENT --query "SELECT last_exception FROM system.dictionaries WHERE database = 'dictdb_01041_01040' AND name = 'invalidate'" 2>&1)
sleep 0.1
done
}
......@@ -52,10 +52,10 @@ function check_exception_detected()
export -f check_exception_detected;
timeout 30 bash -c check_exception_detected 2> /dev/null
$CLICKHOUSE_CLIENT --query "SELECT last_exception FROM system.dictionaries WHERE database = 'dictdb' AND name = 'invalidate'" 2>&1 | grep -Eo "Table dictdb.dict_invalidate .* exist"
$CLICKHOUSE_CLIENT --query "SELECT last_exception FROM system.dictionaries WHERE database = 'dictdb_01041_01040' AND name = 'invalidate'" 2>&1 | grep -Eo "Table dictdb_01041_01040.dict_invalidate .* exist"
$CLICKHOUSE_CLIENT --query "
CREATE TABLE dictdb.dict_invalidate
CREATE TABLE dictdb_01041_01040.dict_invalidate
ENGINE = Memory AS
SELECT
133 as dummy,
......@@ -64,11 +64,11 @@ FROM system.one"
function check_exception_fixed()
{
query_result=$($CLICKHOUSE_CLIENT --query "SELECT last_exception FROM system.dictionaries WHERE database = 'dictdb' AND name = 'invalidate'" 2>&1)
query_result=$($CLICKHOUSE_CLIENT --query "SELECT last_exception FROM system.dictionaries WHERE database = 'dictdb_01041_01040' AND name = 'invalidate'" 2>&1)
while [ "$query_result" ]
do
query_result=$($CLICKHOUSE_CLIENT --query "SELECT last_exception FROM system.dictionaries WHERE database = 'dictdb' AND name = 'invalidate'" 2>&1)
query_result=$($CLICKHOUSE_CLIENT --query "SELECT last_exception FROM system.dictionaries WHERE database = 'dictdb_01041_01040' AND name = 'invalidate'" 2>&1)
sleep 0.1
done
}
......@@ -77,7 +77,7 @@ export -f check_exception_fixed;
# it may take a while until dictionary reloads
timeout 60 bash -c check_exception_fixed 2> /dev/null
$CLICKHOUSE_CLIENT --query "SELECT last_exception FROM system.dictionaries WHERE database = 'dictdb' AND name = 'invalidate'" 2>&1
$CLICKHOUSE_CLIENT --query "SELECT dictGetUInt8('dictdb.invalidate', 'two', toUInt64(133))"
$CLICKHOUSE_CLIENT --query "SELECT last_exception FROM system.dictionaries WHERE database = 'dictdb_01041_01040' AND name = 'invalidate'" 2>&1
$CLICKHOUSE_CLIENT --query "SELECT dictGetUInt8('dictdb_01041_01040.invalidate', 'two', toUInt64(133))"
$CLICKHOUSE_CLIENT --query "DROP DATABASE IF EXISTS dictdb"
$CLICKHOUSE_CLIENT --query "DROP DATABASE IF EXISTS dictdb_01041_01040"
......@@ -8,40 +8,40 @@ set -e -o pipefail
# Run the client.
$CLICKHOUSE_CLIENT --multiquery <<'EOF'
DROP DATABASE IF EXISTS dictdb;
CREATE DATABASE dictdb;
CREATE TABLE dictdb.table(x Int64, y Int64, insert_time DateTime) ENGINE = MergeTree ORDER BY tuple();
INSERT INTO dictdb.table VALUES (12, 102, now());
DROP DATABASE IF EXISTS dictdb_01042;
CREATE DATABASE dictdb_01042;
CREATE TABLE dictdb_01042.table(x Int64, y Int64, insert_time DateTime) ENGINE = MergeTree ORDER BY tuple();
INSERT INTO dictdb_01042.table VALUES (12, 102, now());
CREATE DICTIONARY dictdb.dict
CREATE DICTIONARY dictdb_01042.dict
(
x Int64 DEFAULT -1,
y Int64 DEFAULT -1,
insert_time DateTime
)
PRIMARY KEY x
SOURCE(CLICKHOUSE(HOST 'localhost' PORT tcpPort() USER 'default' TABLE 'table' DB 'dictdb' UPDATE_FIELD 'insert_time'))
SOURCE(CLICKHOUSE(HOST 'localhost' PORT tcpPort() USER 'default' TABLE 'table' DB 'dictdb_01042' UPDATE_FIELD 'insert_time'))
LAYOUT(FLAT())
LIFETIME(1);
EOF
$CLICKHOUSE_CLIENT --query "SELECT '12 -> ', dictGetInt64('dictdb.dict', 'y', toUInt64(12))"
$CLICKHOUSE_CLIENT --query "SELECT '12 -> ', dictGetInt64('dictdb_01042.dict', 'y', toUInt64(12))"
$CLICKHOUSE_CLIENT --query "INSERT INTO dictdb.table VALUES (13, 103, now())"
$CLICKHOUSE_CLIENT --query "INSERT INTO dictdb.table VALUES (14, 104, now() - INTERVAL 1 DAY)"
$CLICKHOUSE_CLIENT --query "INSERT INTO dictdb_01042.table VALUES (13, 103, now())"
$CLICKHOUSE_CLIENT --query "INSERT INTO dictdb_01042.table VALUES (14, 104, now() - INTERVAL 1 DAY)"
while [ "$(${CLICKHOUSE_CLIENT} --query "SELECT dictGetInt64('dictdb.dict', 'y', toUInt64(13))")" = -1 ]
while [ "$(${CLICKHOUSE_CLIENT} --query "SELECT dictGetInt64('dictdb_01042.dict', 'y', toUInt64(13))")" = -1 ]
do
sleep 0.5
done
$CLICKHOUSE_CLIENT --query "SELECT '13 -> ', dictGetInt64('dictdb.dict', 'y', toUInt64(13))"
$CLICKHOUSE_CLIENT --query "SELECT '14 -> ', dictGetInt64('dictdb.dict', 'y', toUInt64(14))"
$CLICKHOUSE_CLIENT --query "SELECT '13 -> ', dictGetInt64('dictdb_01042.dict', 'y', toUInt64(13))"
$CLICKHOUSE_CLIENT --query "SELECT '14 -> ', dictGetInt64('dictdb_01042.dict', 'y', toUInt64(14))"
$CLICKHOUSE_CLIENT --query "SYSTEM RELOAD DICTIONARY 'dictdb.dict'"
$CLICKHOUSE_CLIENT --query "SYSTEM RELOAD DICTIONARY 'dictdb_01042.dict'"
$CLICKHOUSE_CLIENT --query "SELECT '12(r) -> ', dictGetInt64('dictdb.dict', 'y', toUInt64(12))"
$CLICKHOUSE_CLIENT --query "SELECT '13(r) -> ', dictGetInt64('dictdb.dict', 'y', toUInt64(13))"
$CLICKHOUSE_CLIENT --query "SELECT '14(r) -> ', dictGetInt64('dictdb.dict', 'y', toUInt64(14))"
$CLICKHOUSE_CLIENT --query "SELECT '12(r) -> ', dictGetInt64('dictdb_01042.dict', 'y', toUInt64(12))"
$CLICKHOUSE_CLIENT --query "SELECT '13(r) -> ', dictGetInt64('dictdb_01042.dict', 'y', toUInt64(13))"
$CLICKHOUSE_CLIENT --query "SELECT '14(r) -> ', dictGetInt64('dictdb_01042.dict', 'y', toUInt64(14))"
$CLICKHOUSE_CLIENT --query "DROP DATABASE IF EXISTS dictdb"
$CLICKHOUSE_CLIENT --query "DROP DATABASE IF EXISTS dictdb_01042"
DROP DATABASE IF EXISTS dictdb;
CREATE DATABASE dictdb;
DROP DATABASE IF EXISTS dictdb_01043;
CREATE DATABASE dictdb_01043;
CREATE TABLE dictdb.dicttbl(key Int64, value_default String, value_expression String) ENGINE = MergeTree ORDER BY tuple();
INSERT INTO dictdb.dicttbl VALUES (12, 'hello', '55:66:77');
CREATE TABLE dictdb_01043.dicttbl(key Int64, value_default String, value_expression String) ENGINE = MergeTree ORDER BY tuple();
INSERT INTO dictdb_01043.dicttbl VALUES (12, 'hello', '55:66:77');
CREATE DICTIONARY dictdb.dict
CREATE DICTIONARY dictdb_01043.dict
(
key Int64 DEFAULT -1,
value_default String DEFAULT 'world',
......@@ -13,15 +13,15 @@ CREATE DICTIONARY dictdb.dict
)
PRIMARY KEY key
SOURCE(CLICKHOUSE(HOST 'localhost' PORT tcpPort() USER 'default' TABLE 'dicttbl' DB 'dictdb'))
SOURCE(CLICKHOUSE(HOST 'localhost' PORT tcpPort() USER 'default' TABLE 'dicttbl' DB 'dictdb_01043'))
LAYOUT(FLAT())
LIFETIME(1);
SELECT dictGetString('dictdb.dict', 'value_default', toUInt64(12));
SELECT dictGetString('dictdb.dict', 'value_default', toUInt64(14));
SELECT dictGetString('dictdb_01043.dict', 'value_default', toUInt64(12));
SELECT dictGetString('dictdb_01043.dict', 'value_default', toUInt64(14));
SELECT dictGetString('dictdb.dict', 'value_expression', toUInt64(12));
SELECT dictGetString('dictdb.dict', 'value_expression', toUInt64(14));
SELECT dictGetString('dictdb_01043.dict', 'value_expression', toUInt64(12));
SELECT dictGetString('dictdb_01043.dict', 'value_expression', toUInt64(14));
DROP DATABASE IF EXISTS dictdb;
DROP DATABASE IF EXISTS dictdb_01043;
DROP DATABASE IF EXISTS dictdb;
DROP DATABASE IF EXISTS dictdb_01045;
CREATE DATABASE dictdb;
CREATE DATABASE dictdb_01045;
CREATE DICTIONARY dictdb.restricted_dict (
CREATE DICTIONARY dictdb_01045.restricted_dict (
key UInt64,
value String
)
......@@ -12,10 +12,10 @@ LIFETIME(MIN 0 MAX 1)
LAYOUT(CACHE(SIZE_IN_CELLS 10));
-- because of lazy load we can check only in dictGet query
select dictGetString('dictdb.restricted_dict', 'value', toUInt64(1)); -- {serverError 482}
select dictGetString('dictdb_01045.restricted_dict', 'value', toUInt64(1)); -- {serverError 482}
select 'Ok.';
DROP DICTIONARY IF EXISTS dictdb.restricted_dict;
DROP DICTIONARY IF EXISTS dictdb_01045.restricted_dict;
DROP DATABASE IF EXISTS dictdb;
DROP DATABASE IF EXISTS dictdb_01045;
DROP TABLE IF EXISTS mt;
DROP TABLE IF EXISTS mt_01451;
CREATE TABLE mt (v UInt8) ENGINE = MergeTree() order by tuple();
SYSTEM STOP MERGES mt;
CREATE TABLE mt_01451 (v UInt8) ENGINE = MergeTree() order by tuple();
SYSTEM STOP MERGES mt_01451;
INSERT INTO mt VALUES (0);
INSERT INTO mt VALUES (1);
INSERT INTO mt VALUES (2);
INSERT INTO mt_01451 VALUES (0);
INSERT INTO mt_01451 VALUES (1);
INSERT INTO mt_01451 VALUES (2);
SELECT v FROM mt ORDER BY v;
SELECT v FROM mt_01451 ORDER BY v;
ALTER TABLE mt DETACH PART 'all_100_100_0'; -- { serverError 232 }
ALTER TABLE mt_01451 DETACH PART 'all_100_100_0'; -- { serverError 232 }
ALTER TABLE mt DETACH PART 'all_2_2_0';
ALTER TABLE mt_01451 DETACH PART 'all_2_2_0';
SELECT v FROM mt ORDER BY v;
SELECT v FROM mt_01451 ORDER BY v;
SELECT name FROM system.detached_parts WHERE table = 'mt';
SELECT name FROM system.detached_parts WHERE table = 'mt_01451';
ALTER TABLE mt ATTACH PART 'all_2_2_0';
ALTER TABLE mt_01451 ATTACH PART 'all_2_2_0';
SELECT v FROM mt ORDER BY v;
SELECT v FROM mt_01451 ORDER BY v;
SELECT name FROM system.detached_parts WHERE table = 'mt';
SELECT name FROM system.detached_parts WHERE table = 'mt_01451';
SELECT '-- drop part --';
ALTER TABLE mt DROP PART 'all_4_4_0';
ALTER TABLE mt_01451 DROP PART 'all_4_4_0';
ALTER TABLE mt ATTACH PART 'all_4_4_0'; -- { serverError 233 }
ALTER TABLE mt_01451 ATTACH PART 'all_4_4_0'; -- { serverError 233 }
SELECT v FROM mt ORDER BY v;
SELECT v FROM mt_01451 ORDER BY v;
SELECT '-- resume merges --';
SYSTEM START MERGES mt;
OPTIMIZE TABLE mt FINAL;
SYSTEM START MERGES mt_01451;
OPTIMIZE TABLE mt_01451 FINAL;
SELECT v FROM mt ORDER BY v;
SELECT v FROM mt_01451 ORDER BY v;
SELECT name FROM system.parts WHERE table = 'mt' AND active;
SELECT name FROM system.parts WHERE table = 'mt_01451' AND active;
DROP TABLE mt;
DROP TABLE mt_01451;
......@@ -473,12 +473,15 @@
"01494_storage_join_persistency",
"01516_drop_table_stress",
"01541_max_memory_usage_for_user",
"01646_system_restart_replicas_smoke", // system restart replicas is a global query
"01600_count_of_parts_metrics", // tests global system metrics
"attach",
"ddl_dictionaries",
"dictionary",
"limit_memory",
"live_view",
"memory_leak",
"memory_limit"
"memory_limit",
"polygon_dicts" // they use an explicitly specified database
]
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册