mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Coverage for non-server tools
This commit is contained in:
parent
e13ca48bce
commit
e49cfbef08
@ -12,6 +12,7 @@ import itertools
|
||||
import sys
|
||||
import os
|
||||
import os.path
|
||||
import glob
|
||||
import platform
|
||||
import signal
|
||||
import re
|
||||
@ -74,6 +75,10 @@ def stringhash(s):
|
||||
# only during process invocation https://stackoverflow.com/a/42089311
|
||||
return zlib.crc32(s.encode("utf-8"))
|
||||
|
||||
def read_file_as_binary_string(file_path):
|
||||
with open(file_path, 'rb') as file:
|
||||
binary_data = file.read()
|
||||
return binary_data
|
||||
|
||||
# First and last lines of the log
|
||||
def trim_for_log(s):
|
||||
@ -101,6 +106,7 @@ class HTTPError(Exception):
|
||||
def clickhouse_execute_http(
|
||||
base_args,
|
||||
query,
|
||||
body=None,
|
||||
timeout=30,
|
||||
settings=None,
|
||||
default_format=None,
|
||||
@ -140,6 +146,7 @@ def clickhouse_execute_http(
|
||||
client.request(
|
||||
"POST",
|
||||
f"/?{base_args.client_options_query_str}{urllib.parse.urlencode(params)}",
|
||||
body=body
|
||||
)
|
||||
res = client.getresponse()
|
||||
data = res.read()
|
||||
@ -160,6 +167,7 @@ def clickhouse_execute_http(
|
||||
def clickhouse_execute(
|
||||
base_args,
|
||||
query,
|
||||
body=None,
|
||||
timeout=30,
|
||||
settings=None,
|
||||
max_http_retries=5,
|
||||
@ -168,6 +176,7 @@ def clickhouse_execute(
|
||||
return clickhouse_execute_http(
|
||||
base_args,
|
||||
query,
|
||||
body,
|
||||
timeout,
|
||||
settings,
|
||||
max_http_retries=max_http_retries,
|
||||
@ -181,6 +190,7 @@ def clickhouse_execute_json(
|
||||
data = clickhouse_execute_http(
|
||||
base_args,
|
||||
query,
|
||||
None,
|
||||
timeout,
|
||||
settings,
|
||||
"JSONEachRow",
|
||||
@ -1253,6 +1263,19 @@ class TestCase:
|
||||
retry_error_codes=True,
|
||||
)
|
||||
|
||||
# Check for dumped coverage files
|
||||
file_pattern = "coverage.*"
|
||||
matching_files = glob.glob(file_pattern)
|
||||
for file_path in matching_files:
|
||||
body = read_file_as_binary_string(file_path)
|
||||
clickhouse_execute(
|
||||
args,
|
||||
f"INSERT INTO system.coverage_log SELECT now(), '{self.case}', groupArray(data) FROM input('data UInt64') FORMAT RowBinary",
|
||||
body=body,
|
||||
retry_error_codes=True,
|
||||
)
|
||||
os.remove(file_path)
|
||||
|
||||
coverage = clickhouse_execute(
|
||||
args,
|
||||
"SELECT length(coverageCurrent())",
|
||||
|
@ -4,6 +4,10 @@
|
||||
# Don't check for ODR violation, since we may test shared build with ASAN
|
||||
export ASAN_OPTIONS=detect_odr_violation=0
|
||||
|
||||
# If ClickHouse was built with coverage - dump the coverage information at exit
|
||||
# (in other cases this environment variable has no effect)
|
||||
export CLICKHOUSE_WRITE_COVERAGE="coverage"
|
||||
|
||||
export CLICKHOUSE_DATABASE=${CLICKHOUSE_DATABASE:="test"}
|
||||
export CLICKHOUSE_CLIENT_SERVER_LOGS_LEVEL=${CLICKHOUSE_CLIENT_SERVER_LOGS_LEVEL:="warning"}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user