From f7ad885725909a8f7a572508c9d7a963bd3ffef1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Mar=C3=ADn?= Date: Mon, 29 Apr 2024 21:38:45 +0200 Subject: [PATCH 1/3] Try to fix coverage tests --- tests/clickhouse-test | 10 ++++++---- .../02992_all_columns_should_have_comment.sql | 2 +- .../0_stateless/03096_order_by_system_tables.sql | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/clickhouse-test b/tests/clickhouse-test index e31b9a0bdc7..63d2fbc1b68 100755 --- a/tests/clickhouse-test +++ b/tests/clickhouse-test @@ -734,9 +734,9 @@ def get_localzone(): class SettingsRandomizer: settings = { - "max_insert_threads": lambda: 0 - if random.random() < 0.5 - else random.randint(1, 16), + "max_insert_threads": lambda: ( + 0 if random.random() < 0.5 else random.randint(1, 16) + ), "group_by_two_level_threshold": threshold_generator(0.2, 0.2, 1, 1000000), "group_by_two_level_threshold_bytes": threshold_generator( 0.2, 0.2, 1, 50000000 @@ -1484,7 +1484,7 @@ class TestCase: 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", + f"INSERT INTO system.coverage_log SETTINGS async_insert=1, wait_for_async_insert=0 SELECT now(), '{self.case}', groupArray(data) FROM input('data UInt64') FORMAT RowBinary", body=body, retry_error_codes=True, ) @@ -1493,6 +1493,8 @@ class TestCase: # Remove the file even in case of exception to avoid accumulation and quadratic complexity. os.remove(file_path) + _ = clickhouse_execute(args, "SYSTEM FLUSH ASYNC INSERT QUEUE") + coverage = clickhouse_execute( args, "SELECT length(coverageCurrent())", diff --git a/tests/queries/0_stateless/02992_all_columns_should_have_comment.sql b/tests/queries/0_stateless/02992_all_columns_should_have_comment.sql index e233f08cc79..127c6fee07d 100644 --- a/tests/queries/0_stateless/02992_all_columns_should_have_comment.sql +++ b/tests/queries/0_stateless/02992_all_columns_should_have_comment.sql @@ -1,4 +1,4 @@ SYSTEM FLUSH LOGS; SELECT 'Column ' || name || ' from table ' || concat(database, '.', table) || ' should have a comment' FROM system.columns -WHERE (database = 'system') AND (comment = '') AND (table NOT ILIKE '%_log_%') AND (table NOT IN ('numbers', 'numbers_mt', 'one', 'generate_series', 'generateSeries')) AND (default_kind != 'ALIAS'); +WHERE (database = 'system') AND (comment = '') AND (table NOT ILIKE '%_log_%') AND (table NOT IN ('numbers', 'numbers_mt', 'one', 'generate_series', 'generateSeries', 'coverage_log')) AND (default_kind != 'ALIAS'); diff --git a/tests/queries/0_stateless/03096_order_by_system_tables.sql b/tests/queries/0_stateless/03096_order_by_system_tables.sql index 37124ad239d..b9e6d5b3c8c 100644 --- a/tests/queries/0_stateless/03096_order_by_system_tables.sql +++ b/tests/queries/0_stateless/03096_order_by_system_tables.sql @@ -2,7 +2,7 @@ SYSTEM FLUSH LOGS; -- Check for system tables which have non-default sorting key WITH - ['asynchronous_metric_log', 'asynchronous_insert_log', 'opentelemetry_span_log'] AS known_tables, + ['asynchronous_metric_log', 'asynchronous_insert_log', 'opentelemetry_span_log', 'coverage_log'] AS known_tables, 'event_date, event_time' as default_sorting_key SELECT 'Table ' || name || ' has non-default sorting key: ' || sorting_key From 9c3775b7c61512bca7e438db10b0703c9a2dc627 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Mar=C3=ADn?= Date: Tue, 30 Apr 2024 14:32:32 +0200 Subject: [PATCH 2/3] More fixes --- tests/clickhouse-test | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/clickhouse-test b/tests/clickhouse-test index 63d2fbc1b68..2324fa0b396 100755 --- a/tests/clickhouse-test +++ b/tests/clickhouse-test @@ -1470,11 +1470,14 @@ class TestCase: args.collect_per_test_coverage and BuildFlags.SANITIZE_COVERAGE in args.build_flags ): - clickhouse_execute( - args, - f"INSERT INTO system.coverage_log SELECT now(), '{self.case}', coverageCurrent()", - retry_error_codes=True, - ) + try: + clickhouse_execute( + args, + f"INSERT INTO system.coverage_log SELECT now(), '{self.case}', coverageCurrent()", + retry_error_codes=True, + ) + except Exception as e: + print("Cannot insert coverage data: ", str(e)) # Check for dumped coverage files file_pattern = "coverage.*" @@ -1484,7 +1487,7 @@ class TestCase: body = read_file_as_binary_string(file_path) clickhouse_execute( args, - f"INSERT INTO system.coverage_log SETTINGS async_insert=1, wait_for_async_insert=0 SELECT now(), '{self.case}', groupArray(data) FROM input('data UInt64') FORMAT RowBinary", + f"INSERT INTO system.coverage_log SETTINGS async_insert=1, wait_for_async_insert=0, async_insert_busy_timeout_min_ms=200, async_insert_busy_timeout_max_ms=1000 SELECT now(), '{self.case}', groupArray(data) FROM input('data UInt64') FORMAT RowBinary", body=body, retry_error_codes=True, ) From e79860aa0a4394507e57bafc4bd293a6ec9cee15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Mar=C3=ADn?= Date: Tue, 30 Apr 2024 22:24:46 +0200 Subject: [PATCH 3/3] Fix linter --- tests/clickhouse-test | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/clickhouse-test b/tests/clickhouse-test index 2324fa0b396..56556050717 100755 --- a/tests/clickhouse-test +++ b/tests/clickhouse-test @@ -1487,7 +1487,9 @@ class TestCase: body = read_file_as_binary_string(file_path) clickhouse_execute( args, - f"INSERT INTO system.coverage_log SETTINGS async_insert=1, wait_for_async_insert=0, async_insert_busy_timeout_min_ms=200, async_insert_busy_timeout_max_ms=1000 SELECT now(), '{self.case}', groupArray(data) FROM input('data UInt64') FORMAT RowBinary", + "INSERT INTO system.coverage_log " + "SETTINGS async_insert=1, wait_for_async_insert=0, async_insert_busy_timeout_min_ms=200, async_insert_busy_timeout_max_ms=1000 " + f"SELECT now(), '{self.case}', groupArray(data) FROM input('data UInt64') FORMAT RowBinary", body=body, retry_error_codes=True, )