Skip to content

Commit

Permalink
Merge pull request #51991 from ClickHouse/test-cleanup
Browse files Browse the repository at this point in the history
Check that functional tests cleanup their tables
  • Loading branch information
alexey-milovidov committed Jul 16, 2023
2 parents 09b300c + 71d6206 commit 60908ac
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
24 changes: 23 additions & 1 deletion tests/clickhouse-test
Original file line number Diff line number Diff line change
Expand Up @@ -1212,7 +1212,29 @@ class TestCase:
seconds_left = max(
args.timeout - (datetime.now() - start_time).total_seconds(), 20
)
drop_database_query = "DROP DATABASE IF EXISTS " + database

# Check if the test does not cleanup its tables.
# Only for newly added tests. Please extend this check to the old tests as well.
if self.case_file >= "02800":
leftover_tables = (
clickhouse_execute(
args,
f"SHOW TABLES FROM {database}",
timeout=seconds_left,
settings={
"log_comment": args.testcase_basename,
},
)
.decode()
.replace("\n", ", ")
)

if len(leftover_tables) != 0:
raise Exception(
f"The test should cleanup its tables ({leftover_tables}), otherwise it is inconvenient for running it locally."
)

drop_database_query = f"DROP DATABASE IF EXISTS {database}"
if args.replicated_database:
drop_database_query += " ON CLUSTER test_cluster_database_replicated"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
DROP TABLE IF EXISTS session_events;
DROP TABLE IF EXISTS event_types;

CREATE TABLE session_events
(
clientId UInt64,
Expand Down Expand Up @@ -75,3 +78,6 @@ FROM
WHERE runningDifference(timestamp) >= 500
ORDER BY timestamp ASC
FORMAT Null;

DROP TABLE session_events;
DROP TABLE event_types;

0 comments on commit 60908ac

Please sign in to comment.