Add stupid retries in clickhouse-test health check.

This commit is contained in:
Nikolai Kochetov 2023-03-02 19:03:17 +00:00
parent ecc6ff707b
commit e91cdb4f8d

View File

@ -94,7 +94,7 @@ class HTTPError(Exception):
# Helpers to execute queries via HTTP interface. # Helpers to execute queries via HTTP interface.
def clickhouse_execute_http( def clickhouse_execute_http(
base_args, query, timeout=30, settings=None, default_format=None, max_http_retries=5 base_args, query, timeout=30, settings=None, default_format=None, max_http_retries=5, retry_error_codes=False
): ):
if args.secure: if args.secure:
client = http.client.HTTPSConnection( client = http.client.HTTPSConnection(
@ -131,7 +131,8 @@ def clickhouse_execute_http(
) )
res = client.getresponse() res = client.getresponse()
data = res.read() data = res.read()
break if res.status == 200 or (not retry_error_codes):
break
except Exception as ex: except Exception as ex:
if i == max_http_retries - 1: if i == max_http_retries - 1:
raise ex raise ex
@ -143,8 +144,8 @@ def clickhouse_execute_http(
return data return data
def clickhouse_execute(base_args, query, timeout=30, settings=None, max_http_retries=5): def clickhouse_execute(base_args, query, timeout=30, settings=None, max_http_retries=5, retry_error_codes=False):
return clickhouse_execute_http(base_args, query, timeout, settings, max_http_retries=max_http_retries).strip() return clickhouse_execute_http(base_args, query, timeout, settings, max_http_retries=max_http_retries, retry_error_codes=retry_error_codes).strip()
def clickhouse_execute_json(base_args, query, timeout=60, settings=None, max_http_retries=5): def clickhouse_execute_json(base_args, query, timeout=60, settings=None, max_http_retries=5):
@ -1078,7 +1079,7 @@ class TestCase:
@staticmethod @staticmethod
def send_test_name_failed(suite: str, case: str): def send_test_name_failed(suite: str, case: str):
pid = os.getpid() pid = os.getpid()
clickhouse_execute(args, f"SELECT 'Running test {suite}/{case} from pid={pid}'") clickhouse_execute(args, f"SELECT 'Running test {suite}/{case} from pid={pid}'", retry_error_codes=True)
def run_single_test( def run_single_test(
self, server_logs_level, client_options self, server_logs_level, client_options