mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
print stats in tests
This commit is contained in:
parent
93509395fb
commit
f2b177880f
@ -128,6 +128,7 @@ function run_tests()
|
||||
|
||||
if [[ "${HIGH_LEVEL_COVERAGE}" = "YES" ]]; then
|
||||
ADDITIONAL_OPTIONS+=('--report-coverage')
|
||||
ADDITIONAL_OPTIONS+=('--report-logs-stats')
|
||||
fi
|
||||
|
||||
set +e
|
||||
|
@ -292,6 +292,7 @@ if __name__ == "__main__":
|
||||
"--database=system",
|
||||
"--hung-check",
|
||||
"--stress",
|
||||
"--report-logs-stats",
|
||||
"00001_select_1",
|
||||
]
|
||||
)
|
||||
|
@ -1792,6 +1792,56 @@ def reportCoverage(args):
|
||||
"""
|
||||
)
|
||||
|
||||
def reportLogPatterns(args):
|
||||
query = """
|
||||
WITH
|
||||
120 AS mins,
|
||||
(
|
||||
SELECT (count(), sum(length(message)))
|
||||
FROM system.text_log
|
||||
WHERE (now() - toIntervalMinute(mins)) < event_time
|
||||
) AS total
|
||||
SELECT
|
||||
count() AS count,
|
||||
round(count / (total.1), 3) AS `count_%`,
|
||||
formatReadableSize(sum(length(message))) AS size,
|
||||
round(sum(length(message)) / (total.2), 3) AS `size_%`,
|
||||
countDistinct(logger_name) AS uniq_loggers,
|
||||
countDistinct(thread_id) AS uniq_threads,
|
||||
groupArrayDistinct(toString(level)) AS levels,
|
||||
round(sum(query_id = '') / count, 3) AS `background_%`,
|
||||
message_format_string
|
||||
FROM system.text_log
|
||||
WHERE (now() - toIntervalMinute(mins)) < event_time
|
||||
GROUP BY message_format_string
|
||||
ORDER BY count DESC
|
||||
LIMIT 100
|
||||
FORMAT TSVWithNamesAndTypes
|
||||
"""
|
||||
value = clickhouse_execute(args, query).decode()
|
||||
print(f"\nTop patterns of log messages:\n")
|
||||
print(value)
|
||||
print("\n")
|
||||
|
||||
query = """
|
||||
WITH
|
||||
120 AS mins
|
||||
SELECT
|
||||
count() AS count,
|
||||
substr(replaceRegexpAll(message, '[^A-Za-z]+', ''), 1, 32) AS pattern,
|
||||
substr(any(message), 1, 256) as runtime_message
|
||||
FROM system.text_log
|
||||
WHERE (now() - toIntervalMinute(mins)) < event_time AND message_format_string = ''
|
||||
GROUP BY pattern
|
||||
ORDER BY count DESC
|
||||
LIMIT 50
|
||||
FORMAT TSVWithNamesAndTypes
|
||||
"""
|
||||
value = clickhouse_execute(args, query).decode()
|
||||
print(f"\nTop runtime messages:\n")
|
||||
print(value)
|
||||
print("\n")
|
||||
|
||||
|
||||
def main(args):
|
||||
global server_died
|
||||
@ -1927,6 +1977,9 @@ def main(args):
|
||||
else:
|
||||
print("All tests have finished.")
|
||||
|
||||
if args.report_logs_stats:
|
||||
reportLogPatterns(args)
|
||||
|
||||
if args.report_coverage and not reportCoverage(args):
|
||||
exit_code.value = 1
|
||||
|
||||
@ -2216,6 +2269,12 @@ if __name__ == "__main__":
|
||||
default=False,
|
||||
help="Check what high-level server components were covered by tests",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--report-logs-stats",
|
||||
action="store_true",
|
||||
default=False,
|
||||
help="Report statistics about log messages",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.queries and not os.path.isdir(args.queries):
|
||||
|
Loading…
Reference in New Issue
Block a user