mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
One more attempt to fix retries in clickhouse-test
This commit is contained in:
parent
0ccc31f6ef
commit
21b751217d
@ -128,7 +128,7 @@ def get_db_engine(args, database_name):
|
||||
return " ENGINE=" + args.db_engine
|
||||
return "" # Will use default engine
|
||||
|
||||
def configure_testcase_args(args, case_file, suite_tmp_dir):
|
||||
def configure_testcase_args(args, case_file, suite_tmp_dir, stderr_file):
|
||||
testcase_args = copy.deepcopy(args)
|
||||
|
||||
testcase_args.testcase_start_time = datetime.now()
|
||||
@ -147,12 +147,13 @@ def configure_testcase_args(args, case_file, suite_tmp_dir):
|
||||
return ''.join(random.choice(alphabet) for _ in range(length))
|
||||
database = 'test_{suffix}'.format(suffix=random_str())
|
||||
|
||||
clickhouse_proc_create = Popen(shlex.split(testcase_args.testcase_client), stdin=PIPE, stdout=PIPE, stderr=None, universal_newlines=True)
|
||||
try:
|
||||
clickhouse_proc_create.communicate(("CREATE DATABASE " + database + get_db_engine(testcase_args, database)), timeout=testcase_args.timeout)
|
||||
except TimeoutExpired:
|
||||
total_time = (datetime.now() - testcase_args.testcase_start_time).total_seconds()
|
||||
return clickhouse_proc_create, "", "Timeout creating database {} before test".format(database), total_time
|
||||
with open(stderr_file, 'w') as stderr:
|
||||
clickhouse_proc_create = Popen(shlex.split(testcase_args.testcase_client), stdin=PIPE, stdout=PIPE, stderr=stderr, universal_newlines=True)
|
||||
try:
|
||||
clickhouse_proc_create.communicate(("CREATE DATABASE " + database + get_db_engine(testcase_args, database)), timeout=testcase_args.timeout)
|
||||
except TimeoutExpired:
|
||||
total_time = (datetime.now() - testcase_args.testcase_start_time).total_seconds()
|
||||
return clickhouse_proc_create, "", "Timeout creating database {} before test".format(database), total_time
|
||||
|
||||
os.environ["CLICKHOUSE_DATABASE"] = database
|
||||
# Set temporary directory to match the randomly generated database,
|
||||
@ -183,15 +184,17 @@ def run_single_test(args, ext, server_logs_level, client_options, case_file, std
|
||||
'stderr': stderr_file,
|
||||
}
|
||||
|
||||
pattern = '{test} > {stdout} 2> {stderr}'
|
||||
# >> append to stdout and stderr, because there are also output of per test database creation
|
||||
if not args.database:
|
||||
pattern = '{test} >> {stdout} 2>> {stderr}'
|
||||
else:
|
||||
pattern = '{test} > {stdout} 2> {stderr}'
|
||||
|
||||
if ext == '.sql':
|
||||
pattern = "{client} --send_logs_level={logs_level} --testmode --multiquery {options} < " + pattern
|
||||
|
||||
command = pattern.format(**params)
|
||||
|
||||
# print(command)
|
||||
|
||||
proc = Popen(command, shell=True, env=os.environ)
|
||||
|
||||
while (datetime.now() - start_time).total_seconds() < args.timeout and proc.poll() is None:
|
||||
@ -203,7 +206,8 @@ def run_single_test(args, ext, server_logs_level, client_options, case_file, std
|
||||
need_drop_database = not maybe_passed
|
||||
|
||||
if need_drop_database:
|
||||
clickhouse_proc_create = Popen(shlex.split(client), stdin=PIPE, stdout=PIPE, stderr=None, universal_newlines=True)
|
||||
with open(stderr_file, 'a') as stderr:
|
||||
clickhouse_proc_create = Popen(shlex.split(client), stdin=PIPE, stdout=PIPE, stderr=stderr, universal_newlines=True)
|
||||
seconds_left = max(args.timeout - (datetime.now() - start_time).total_seconds(), 20)
|
||||
try:
|
||||
drop_database_query = "DROP DATABASE " + database
|
||||
@ -419,8 +423,7 @@ def run_tests_array(all_tests_with_params):
|
||||
stderr_file = os.path.join(suite_tmp_dir, name) + file_suffix + '.stderr'
|
||||
|
||||
|
||||
testcase_args = configure_testcase_args(args, case_file, suite_tmp_dir)
|
||||
|
||||
testcase_args = configure_testcase_args(args, case_file, suite_tmp_dir, stderr_file)
|
||||
proc, stdout, stderr, total_time = run_single_test(testcase_args, ext, server_logs_level, client_options, case_file, stdout_file, stderr_file)
|
||||
|
||||
if proc.returncode is None:
|
||||
@ -440,7 +443,7 @@ def run_tests_array(all_tests_with_params):
|
||||
else:
|
||||
counter = 1
|
||||
while need_retry(stderr):
|
||||
testcase_args = configure_testcase_args(args, case_file, suite_tmp_dir)
|
||||
testcase_args = configure_testcase_args(args, case_file, suite_tmp_dir, stderr_file)
|
||||
proc, stdout, stderr, total_time = run_single_test(testcase_args, ext, server_logs_level, client_options, case_file, stdout_file, stderr_file)
|
||||
sleep(2**counter)
|
||||
counter += 1
|
||||
|
Loading…
Reference in New Issue
Block a user