mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Merge pull request #40647 from ClickHouse/high-level-coverage
Report high-level function and data types test coverage
This commit is contained in:
commit
7bd1142f63
@ -88,13 +88,15 @@ sleep 5
|
||||
function run_tests()
|
||||
{
|
||||
set -x
|
||||
# We can have several additional options so we path them as array because it's
|
||||
# more idiologically correct.
|
||||
# We can have several additional options so we pass them as array because it is more ideologically correct.
|
||||
read -ra ADDITIONAL_OPTIONS <<< "${ADDITIONAL_OPTIONS:-}"
|
||||
|
||||
HIGH_LEVEL_COVERAGE=YES
|
||||
|
||||
# Use random order in flaky check
|
||||
if [ "$NUM_TRIES" -gt "1" ]; then
|
||||
ADDITIONAL_OPTIONS+=('--order=random')
|
||||
HIGH_LEVEL_COVERAGE=NO
|
||||
fi
|
||||
|
||||
if [[ -n "$USE_S3_STORAGE_FOR_MERGE_TREE" ]] && [[ "$USE_S3_STORAGE_FOR_MERGE_TREE" -eq 1 ]]; then
|
||||
@ -117,12 +119,17 @@ function run_tests()
|
||||
ADDITIONAL_OPTIONS+=("$RUN_BY_HASH_NUM")
|
||||
ADDITIONAL_OPTIONS+=('--run-by-hash-total')
|
||||
ADDITIONAL_OPTIONS+=("$RUN_BY_HASH_TOTAL")
|
||||
HIGH_LEVEL_COVERAGE=NO
|
||||
fi
|
||||
|
||||
if [[ -n "$USE_DATABASE_ORDINARY" ]] && [[ "$USE_DATABASE_ORDINARY" -eq 1 ]]; then
|
||||
ADDITIONAL_OPTIONS+=('--db-engine=Ordinary')
|
||||
fi
|
||||
|
||||
if [[ "${HIGH_LEVEL_COVERAGE}" = "YES" ]]; then
|
||||
ADDITIONAL_OPTIONS+=('--report-coverage')
|
||||
fi
|
||||
|
||||
set +e
|
||||
clickhouse-test --testname --shard --zookeeper --check-zookeeper-session --hung-check --print-time \
|
||||
--test-runs "$NUM_TRIES" "${ADDITIONAL_OPTIONS[@]}" 2>&1 \
|
||||
|
@ -1714,6 +1714,75 @@ def removesuffix(text, *suffixes):
|
||||
return text
|
||||
|
||||
|
||||
def reportCoverageFor(args, what, query, permissive = False):
|
||||
value = clickhouse_execute(args, query).decode()
|
||||
|
||||
if value != "":
|
||||
print(f"\nThe following {what} were not covered by tests:\n")
|
||||
print(value)
|
||||
print("\n")
|
||||
return permissive
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def reportCoverage(args):
|
||||
return reportCoverageFor(
|
||||
args,
|
||||
"functions",
|
||||
"""
|
||||
SELECT name
|
||||
FROM system.functions
|
||||
WHERE NOT is_aggregate AND origin = 'System' AND alias_to = ''
|
||||
AND name NOT IN
|
||||
(
|
||||
SELECT arrayJoin(used_functions) FROM system.query_log WHERE event_date >= yesterday()
|
||||
)
|
||||
ORDER BY name
|
||||
""",
|
||||
True
|
||||
) and reportCoverageFor(
|
||||
args,
|
||||
"aggregate functions",
|
||||
"""
|
||||
SELECT name
|
||||
FROM system.functions
|
||||
WHERE is_aggregate AND origin = 'System' AND alias_to = ''
|
||||
AND name NOT IN
|
||||
(
|
||||
SELECT arrayJoin(used_aggregate_functions) FROM system.query_log WHERE event_date >= yesterday()
|
||||
)
|
||||
ORDER BY name
|
||||
"""
|
||||
) and reportCoverageFor(
|
||||
args,
|
||||
"aggregate function combinators",
|
||||
"""
|
||||
SELECT name
|
||||
FROM system.aggregate_function_combinators
|
||||
WHERE NOT is_internal
|
||||
AND name NOT IN
|
||||
(
|
||||
SELECT arrayJoin(used_aggregate_function_combinators) FROM system.query_log WHERE event_date >= yesterday()
|
||||
)
|
||||
ORDER BY name
|
||||
"""
|
||||
) and reportCoverageFor(
|
||||
args,
|
||||
"data type families",
|
||||
"""
|
||||
SELECT name
|
||||
FROM system.data_type_families
|
||||
WHERE alias_to = '' AND name NOT LIKE 'Interval%'
|
||||
AND name NOT IN
|
||||
(
|
||||
SELECT arrayJoin(used_data_type_families) FROM system.query_log WHERE event_date >= yesterday()
|
||||
)
|
||||
ORDER BY name
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
def main(args):
|
||||
global server_died
|
||||
global stop_time
|
||||
@ -1845,6 +1914,9 @@ def main(args):
|
||||
else:
|
||||
print("All tests have finished.")
|
||||
|
||||
if args.report_coverage and not reportCoverage(args):
|
||||
exit_code.value = 1
|
||||
|
||||
sys.exit(exit_code.value)
|
||||
|
||||
|
||||
@ -2125,6 +2197,12 @@ if __name__ == "__main__":
|
||||
type=int,
|
||||
help="Max number of failed tests in a row (stop tests if higher)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--report-coverage",
|
||||
action="store_true",
|
||||
default=False,
|
||||
help="Check what high-level server components were covered by tests",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.queries and not os.path.isdir(args.queries):
|
||||
|
Loading…
Reference in New Issue
Block a user