Merge pull request #22646 from azat/clickhouse-test-log-comment

Add log_comment setting for DROP/CREATE DATABASE in clickhouse-test
This commit is contained in:
alexey-milovidov 2021-04-06 14:48:04 +03:00 committed by GitHub
commit e1e2f534e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -116,6 +116,8 @@ def get_db_engine(args, database_name):
def run_single_test(args, ext, server_logs_level, client_options, case_file, stdout_file, stderr_file, suite_tmp_dir): def run_single_test(args, ext, server_logs_level, client_options, case_file, stdout_file, stderr_file, suite_tmp_dir):
# print(client_options) # print(client_options)
client = f"{args.client} --log_comment='{case_file}'"
start_time = datetime.now() start_time = datetime.now()
if args.database: if args.database:
database = args.database database = args.database
@ -130,7 +132,7 @@ def run_single_test(args, ext, server_logs_level, client_options, case_file, std
return ''.join(random.choice(alphabet) for _ in range(length)) return ''.join(random.choice(alphabet) for _ in range(length))
database = 'test_{suffix}'.format(suffix=random_str()) database = 'test_{suffix}'.format(suffix=random_str())
clickhouse_proc_create = Popen(shlex.split(args.client), stdin=PIPE, stdout=PIPE, stderr=PIPE, universal_newlines=True) clickhouse_proc_create = Popen(shlex.split(client), stdin=PIPE, stdout=PIPE, stderr=PIPE, universal_newlines=True)
try: try:
clickhouse_proc_create.communicate(("CREATE DATABASE " + database + get_db_engine(args, database)), timeout=args.timeout) clickhouse_proc_create.communicate(("CREATE DATABASE " + database + get_db_engine(args, database)), timeout=args.timeout)
except TimeoutExpired: except TimeoutExpired:
@ -149,7 +151,7 @@ def run_single_test(args, ext, server_logs_level, client_options, case_file, std
os.environ["CLICKHOUSE_LOG_COMMENT"] = case_file os.environ["CLICKHOUSE_LOG_COMMENT"] = case_file
params = { params = {
'client': args.client + ' --database=' + database, 'client': client + ' --database=' + database,
'logs_level': server_logs_level, 'logs_level': server_logs_level,
'options': client_options, 'options': client_options,
'test': case_file, 'test': case_file,
@ -160,7 +162,7 @@ def run_single_test(args, ext, server_logs_level, client_options, case_file, std
pattern = '{test} > {stdout} 2> {stderr}' pattern = '{test} > {stdout} 2> {stderr}'
if ext == '.sql': if ext == '.sql':
pattern = "{client} --send_logs_level={logs_level} --testmode --multiquery {options} --log_comment='{test}' < " + pattern pattern = "{client} --send_logs_level={logs_level} --testmode --multiquery {options} < " + pattern
command = pattern.format(**params) command = pattern.format(**params)
@ -177,7 +179,7 @@ def run_single_test(args, ext, server_logs_level, client_options, case_file, std
need_drop_database = not maybe_passed need_drop_database = not maybe_passed
if need_drop_database: if need_drop_database:
clickhouse_proc_create = Popen(shlex.split(args.client), stdin=PIPE, stdout=PIPE, stderr=PIPE, universal_newlines=True) clickhouse_proc_create = Popen(shlex.split(client), stdin=PIPE, stdout=PIPE, stderr=PIPE, universal_newlines=True)
seconds_left = max(args.timeout - (datetime.now() - start_time).total_seconds(), 20) seconds_left = max(args.timeout - (datetime.now() - start_time).total_seconds(), 20)
try: try:
drop_database_query = "DROP DATABASE " + database drop_database_query = "DROP DATABASE " + database