From b541b5eca35b12b7419ffd27c6494cd4d473961d Mon Sep 17 00:00:00 2001 From: Amos Bird Date: Mon, 2 Aug 2021 21:51:33 +0800 Subject: [PATCH] Normalize hostname in CI --- tests/clickhouse-test | 4 ++++ tests/queries/0_stateless/02001_hostname_test.reference | 2 ++ tests/queries/0_stateless/02001_hostname_test.sql | 2 ++ 3 files changed, 8 insertions(+) create mode 100644 tests/queries/0_stateless/02001_hostname_test.reference create mode 100644 tests/queries/0_stateless/02001_hostname_test.sql diff --git a/tests/clickhouse-test b/tests/clickhouse-test index 362d1d225d9..d83b3f08c42 100755 --- a/tests/clickhouse-test +++ b/tests/clickhouse-test @@ -27,6 +27,7 @@ except ImportError: import random import string import multiprocessing +import socket from contextlib import closing USE_JINJA = True @@ -267,6 +268,9 @@ def run_single_test(args, ext, server_logs_level, client_options, case_file, std os.system("LC_ALL=C sed -i -e 's|/auto_{{shard}}||g' {file}".format(file=stdout_file)) os.system("LC_ALL=C sed -i -e 's|auto_{{replica}}||g' {file}".format(file=stdout_file)) + # Normalize hostname in stdout file. + os.system("LC_ALL=C sed -i -e 's/{hostname}/localhost/g' {file}".format(hostname=socket.gethostname(), file=stdout_file)) + stdout = open(stdout_file, 'rb').read() if os.path.exists(stdout_file) else b'' stdout = str(stdout, errors='replace', encoding='utf-8') stderr = open(stderr_file, 'rb').read() if os.path.exists(stderr_file) else b'' diff --git a/tests/queries/0_stateless/02001_hostname_test.reference b/tests/queries/0_stateless/02001_hostname_test.reference new file mode 100644 index 00000000000..da8a2d07eab --- /dev/null +++ b/tests/queries/0_stateless/02001_hostname_test.reference @@ -0,0 +1,2 @@ +localhost +localhost 2 diff --git a/tests/queries/0_stateless/02001_hostname_test.sql b/tests/queries/0_stateless/02001_hostname_test.sql new file mode 100644 index 00000000000..a8c7a8dab0c --- /dev/null +++ b/tests/queries/0_stateless/02001_hostname_test.sql @@ -0,0 +1,2 @@ +select hostname(); +select hostName() h, count() from cluster(test_cluster_two_shards, system.one) group by h;