From 735acf27d87afa546c5e3b0265941280678adce8 Mon Sep 17 00:00:00 2001 From: Alexander Tokmakov Date: Tue, 16 Mar 2021 19:39:31 +0300 Subject: [PATCH] try run stateful tests --- docker/test/stateful/run.sh | 64 +++++++++++++------ docker/test/stateless/clusters2.xml | 22 ------- docker/test/stateless/enable_test_keeper1.xml | 38 ----------- .../process_functional_tests_result.py | 12 +++- docker/test/stateless/run.sh | 15 ++--- docker/test/stateless/use_test_keeper.xml | 16 ----- tests/clickhouse-test | 2 + tests/queries/skip_list.json | 4 +- 8 files changed, 68 insertions(+), 105 deletions(-) delete mode 100644 docker/test/stateless/clusters2.xml delete mode 100644 docker/test/stateless/enable_test_keeper1.xml delete mode 100644 docker/test/stateless/use_test_keeper.xml diff --git a/docker/test/stateful/run.sh b/docker/test/stateful/run.sh index 195cfbfa3d3..e2edb4a0238 100755 --- a/docker/test/stateful/run.sh +++ b/docker/test/stateful/run.sh @@ -14,14 +14,17 @@ dpkg -i package_folder/clickhouse-test_*.deb function start() { if [[ -n "$USE_DATABASE_REPLICATED" ]] && [[ "$USE_DATABASE_REPLICATED" -eq 1 ]]; then - sudo -E -u clickhouse /usr/bin/clickhouse-server --config /etc/clickhouse-server2/config.xml --daemon \ + # NOTE We run "clickhouse server" instead of "clickhouse-server" + # to make "pidof clickhouse-server" return single pid of the main instance. + # We wil run main instance using "service clickhouse-server start" + sudo -E -u clickhouse /usr/bin/clickhouse server --config /etc/clickhouse-server2/config.xml --daemon \ -- --path /var/lib/clickhouse2/ --logger.stderr /var/log/clickhouse-server/stderr2.log \ --logger.log /var/log/clickhouse-server/clickhouse-server2.log --logger.errorlog /var/log/clickhouse-server/clickhouse-server2.err.log \ --tcp_port 19000 --tcp_port_secure 19440 --http_port 18123 --https_port 18443 --interserver_http_port 19009 --tcp_with_proxy_port 19010 \ --mysql_port 19004 \ --test_keeper_server.tcp_port 19181 --test_keeper_server.server_id 2 - sudo -E -u clickhouse /usr/bin/clickhouse-server --config /etc/clickhouse-server3/config.xml --daemon \ + sudo -E -u clickhouse /usr/bin/clickhouse server --config /etc/clickhouse-server3/config.xml --daemon \ -- --path /var/lib/clickhouse3/ --logger.stderr /var/log/clickhouse-server/stderr3.log \ --logger.log /var/log/clickhouse-server/clickhouse-server3.log --logger.errorlog /var/log/clickhouse-server/clickhouse-server3.err.log \ --tcp_port 29000 --tcp_port_secure 29440 --http_port 28123 --https_port 28443 --interserver_http_port 29009 --tcp_with_proxy_port 29010 \ @@ -51,9 +54,8 @@ start /s3downloader --dataset-names $DATASETS chmod 777 -R /var/lib/clickhouse clickhouse-client --query "SHOW DATABASES" -clickhouse-client --query "ATTACH DATABASE datasets ENGINE = Ordinary" -clickhouse-client --query "CREATE DATABASE test" +clickhouse-client --query "ATTACH DATABASE datasets ENGINE = Ordinary" service clickhouse-server restart # Wait for server to start accepting connections @@ -63,24 +65,50 @@ for _ in {1..120}; do done clickhouse-client --query "SHOW TABLES FROM datasets" -clickhouse-client --query "SHOW TABLES FROM test" -clickhouse-client --query "RENAME TABLE datasets.hits_v1 TO test.hits" -clickhouse-client --query "RENAME TABLE datasets.visits_v1 TO test.visits" -clickhouse-client --query "SHOW TABLES FROM test" - -if grep -q -- "--use-skip-list" /usr/bin/clickhouse-test ; then - SKIP_LIST_OPT="--use-skip-list" -fi - -# We can have several additional options so we path them as array because it's -# more idiologically correct. -read -ra ADDITIONAL_OPTIONS <<< "${ADDITIONAL_OPTIONS:-}" if [[ -n "$USE_DATABASE_REPLICATED" ]] && [[ "$USE_DATABASE_REPLICATED" -eq 1 ]]; then - ADDITIONAL_OPTIONS+=('--replicated-database') + clickhouse-client --query "CREATE DATABASE test ON CLUSTER 'test_cluster_database_replicated' + ENGINE=Replicated('/test/clickhouse/db/test', '{shard}', '{replica}')" + + clickhouse-client --query "CREATE TABLE test.hits AS datasets.hits_v1" + clickhouse-client --query "CREATE TABLE test.visits AS datasets.visits_v1" + + clickhouse-client --query "INSERT INTO test.hits SELECT * FROM datasets.hits_v1" + clickhouse-client --query "INSERT INTO test.visits SELECT * FROM datasets.visits_v1" + + clickhouse-client --query "DROP TABLE datasets.hits_v1" + clickhouse-client --query "DROP TABLE datasets.visits_v1" + + MAX_RUN_TIME=$((MAX_RUN_TIME < 9000 ? MAX_RUN_TIME : 9000)) # min(MAX_RUN_TIME, 2.5 hours) + MAX_RUN_TIME=$((MAX_RUN_TIME != 0 ? MAX_RUN_TIME : 9000)) # set to 2.5 hours if 0 (unlimited) +else + clickhouse-client --query "CREATE DATABASE test" + clickhouse-client --query "SHOW TABLES FROM test" + clickhouse-client --query "RENAME TABLE datasets.hits_v1 TO test.hits" + clickhouse-client --query "RENAME TABLE datasets.visits_v1 TO test.visits" fi -clickhouse-test --testname --shard --zookeeper --no-stateless --hung-check --print-time "$SKIP_LIST_OPT" "${ADDITIONAL_OPTIONS[@]}" "$SKIP_TESTS_OPTION" 2>&1 | ts '%Y-%m-%d %H:%M:%S' | tee test_output/test_result.txt +clickhouse-client --query "SHOW TABLES FROM test" +clickhouse-client --query "SELECT count() FROM test.hits" +clickhouse-client --query "SELECT count() FROM test.visits" + +function run_tests() +{ + set -x + # We can have several additional options so we path them as array because it's + # more idiologically correct. + read -ra ADDITIONAL_OPTIONS <<< "${ADDITIONAL_OPTIONS:-}" + + if [[ -n "$USE_DATABASE_REPLICATED" ]] && [[ "$USE_DATABASE_REPLICATED" -eq 1 ]]; then + ADDITIONAL_OPTIONS+=('--replicated-database') + fi + + clickhouse-test --testname --shard --zookeeper --no-stateless --hung-check --print-time "${ADDITIONAL_OPTIONS[@]}" \ + "$SKIP_TESTS_OPTION" 2>&1 | ts '%Y-%m-%d %H:%M:%S' | tee test_output/test_result.txt +} + +export -f run_tests +timeout "$MAX_RUN_TIME" bash -c run_tests ||: ./process_functional_tests_result.py || echo -e "failure\tCannot parse results" > /test_output/check_status.tsv diff --git a/docker/test/stateless/clusters2.xml b/docker/test/stateless/clusters2.xml deleted file mode 100644 index 73b6274df12..00000000000 --- a/docker/test/stateless/clusters2.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - localhost - 9000 - - - localhost - 19000 - - - - - localhost - 29000 - - - - - diff --git a/docker/test/stateless/enable_test_keeper1.xml b/docker/test/stateless/enable_test_keeper1.xml deleted file mode 100644 index 6c9669a42fd..00000000000 --- a/docker/test/stateless/enable_test_keeper1.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - 9181 - 1 - - - 5000 - 10000 - trace - - - - - 1 - localhost - 44444 - true - 3 - - - 2 - localhost - 44445 - true - true - 2 - - - 3 - localhost - 44446 - true - true - 1 - - - - diff --git a/docker/test/stateless/process_functional_tests_result.py b/docker/test/stateless/process_functional_tests_result.py index 27210ef9b80..02adf108212 100755 --- a/docker/test/stateless/process_functional_tests_result.py +++ b/docker/test/stateless/process_functional_tests_result.py @@ -12,6 +12,8 @@ UNKNOWN_SIGN = "[ UNKNOWN " SKIPPED_SIGN = "[ SKIPPED " HUNG_SIGN = "Found hung queries in processlist" +NO_TASK_TIMEOUT_SIGN = "All tests have finished" + def process_test_log(log_path): total = 0 skipped = 0 @@ -19,10 +21,13 @@ def process_test_log(log_path): failed = 0 success = 0 hung = False + task_timeout = True test_results = [] with open(log_path, 'r') as test_file: for line in test_file: line = line.strip() + if NO_TASK_TIMEOUT_SIGN in line: + task_timeout = False if HUNG_SIGN in line: hung = True if any(sign in line for sign in (OK_SIGN, FAIL_SING, UNKNOWN_SIGN, SKIPPED_SIGN)): @@ -52,7 +57,7 @@ def process_test_log(log_path): else: success += int(OK_SIGN in line) test_results.append((test_name, "OK", test_time)) - return total, skipped, unknown, failed, success, hung, test_results + return total, skipped, unknown, failed, success, hung, task_timeout, test_results def process_result(result_path): test_results = [] @@ -68,7 +73,7 @@ def process_result(result_path): state = "error" if result_path and os.path.exists(result_path): - total, skipped, unknown, failed, success, hung, test_results = process_test_log(result_path) + total, skipped, unknown, failed, success, hung, task_timeout, test_results = process_test_log(result_path) is_flacky_check = 1 < int(os.environ.get('NUM_TRIES', 1)) # If no tests were run (success == 0) it indicates an error (e.g. server did not start or crashed immediately) # But it's Ok for "flaky checks" - they can contain just one test for check which is marked as skipped. @@ -78,6 +83,9 @@ def process_result(result_path): if hung: description = "Some queries hung, " state = "failure" + elif task_timeout: + description = "Timeout, " + state = "failure" else: description = "" diff --git a/docker/test/stateless/run.sh b/docker/test/stateless/run.sh index dfa05e1a354..494be95b490 100755 --- a/docker/test/stateless/run.sh +++ b/docker/test/stateless/run.sh @@ -40,7 +40,7 @@ fi if [[ -n "$USE_DATABASE_REPLICATED" ]] && [[ "$USE_DATABASE_REPLICATED" -eq 1 ]]; then - sudo -E -u clickhouse /usr/bin/clickhouse-server --config /etc/clickhouse-server2/config.xml --daemon \ + sudo -E -u clickhouse /usr/bin/clickhouse server --config /etc/clickhouse-server2/config.xml --daemon \ -- --path /var/lib/clickhouse2/ --logger.stderr /var/log/clickhouse-server/stderr2.log \ --logger.log /var/log/clickhouse-server/clickhouse-server2.log --logger.errorlog /var/log/clickhouse-server/clickhouse-server2.err.log \ --tcp_port 19000 --tcp_port_secure 19440 --http_port 18123 --https_port 18443 --interserver_http_port 19009 --tcp_with_proxy_port 19010 \ @@ -48,23 +48,23 @@ if [[ -n "$USE_DATABASE_REPLICATED" ]] && [[ "$USE_DATABASE_REPLICATED" -eq 1 ]] --test_keeper_server.tcp_port 19181 --test_keeper_server.server_id 2 \ --macros.replica r2 # It doesn't work :( - sudo -E -u clickhouse /usr/bin/clickhouse-server --config /etc/clickhouse-server3/config.xml --daemon \ + sudo -E -u clickhouse /usr/bin/clickhouse server --config /etc/clickhouse-server3/config.xml --daemon \ -- --path /var/lib/clickhouse3/ --logger.stderr /var/log/clickhouse-server/stderr3.log \ --logger.log /var/log/clickhouse-server/clickhouse-server3.log --logger.errorlog /var/log/clickhouse-server/clickhouse-server3.err.log \ --tcp_port 29000 --tcp_port_secure 29440 --http_port 28123 --https_port 28443 --interserver_http_port 29009 --tcp_with_proxy_port 29010 \ --mysql_port 29004 \ --test_keeper_server.tcp_port 29181 --test_keeper_server.server_id 3 \ --macros.shard s2 # It doesn't work :( + + MAX_RUN_TIME=$((MAX_RUN_TIME < 9000 ? MAX_RUN_TIME : 9000)) # min(MAX_RUN_TIME, 2.5 hours) + MAX_RUN_TIME=$((MAX_RUN_TIME != 0 ? MAX_RUN_TIME : 9000)) # set to 2.5 hours if 0 (unlimited) fi sleep 5 -if grep -q -- "--use-skip-list" /usr/bin/clickhouse-test; then - SKIP_LIST_OPT="--use-skip-list" -fi - function run_tests() { + set -x # We can have several additional options so we path them as array because it's # more idiologically correct. read -ra ADDITIONAL_OPTIONS <<< "${ADDITIONAL_OPTIONS:-}" @@ -82,8 +82,7 @@ function run_tests() fi clickhouse-test --testname --shard --zookeeper --hung-check --print-time \ - --test-runs "$NUM_TRIES" \ - "$SKIP_LIST_OPT" "${ADDITIONAL_OPTIONS[@]}" 2>&1 \ + --test-runs "$NUM_TRIES" "${ADDITIONAL_OPTIONS[@]}" 2>&1 \ | ts '%Y-%m-%d %H:%M:%S' \ | tee -a test_output/test_result.txt } diff --git a/docker/test/stateless/use_test_keeper.xml b/docker/test/stateless/use_test_keeper.xml deleted file mode 100644 index 26ec47e50e8..00000000000 --- a/docker/test/stateless/use_test_keeper.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - localhost - 9181 - - - localhost - 19181 - - - localhost - 29181 - - - diff --git a/tests/clickhouse-test b/tests/clickhouse-test index fce8fe65f30..56e311a5e11 100755 --- a/tests/clickhouse-test +++ b/tests/clickhouse-test @@ -843,6 +843,8 @@ def main(args): if total_tests_run == 0: print("No tests were run.") sys.exit(1) + else: + print("All tests have finished.") sys.exit(exit_code) diff --git a/tests/queries/skip_list.json b/tests/queries/skip_list.json index 957108cc9cc..4b613369cc2 100644 --- a/tests/queries/skip_list.json +++ b/tests/queries/skip_list.json @@ -135,6 +135,7 @@ "00626_replace_partition_from_table_zookeeper", "00626_replace_partition_from_table", "00152_insert_different_granularity", + "00054_merge_tree_partitions", /// Old syntax is not allowed "01062_alter_on_mutataion_zookeeper", "00925_zookeeper_empty_replicated_merge_tree_optimize_final", @@ -150,7 +151,8 @@ "00083_create_merge_tree_zookeeper", "00062_replicated_merge_tree_alter_zookeeper", /// Does not support renaming of multiple tables in single query - "00634_rename_view" + "00634_rename_view", + "00140_rename" ], "polymorphic-parts": [ "01508_partition_pruning_long", /// bug, shoud be fixed