From 3c3d90c45b48341b44141c1de6fbdf79f7e259dc Mon Sep 17 00:00:00 2001 From: hsiegeln <37154749+hsiegeln@users.noreply.github.com> Date: Wed, 22 Apr 2026 16:45:28 +0200 Subject: [PATCH] test(alerting): align AlertEvaluatorJobIT CH cleanup with house style MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace async @AfterEach ALTER...DELETE with @BeforeEach TRUNCATE TABLE executions — matches the convention used in ClickHouseExecutionStoreIT and peers. Env-slug isolation was already preventing cross-test pollution; this change is about hygiene and determinism (TRUNCATE is synchronous). --- .../app/alerting/eval/AlertEvaluatorJobIT.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/cameleer-server-app/src/test/java/com/cameleer/server/app/alerting/eval/AlertEvaluatorJobIT.java b/cameleer-server-app/src/test/java/com/cameleer/server/app/alerting/eval/AlertEvaluatorJobIT.java index 5c78ec5e..9706fc08 100644 --- a/cameleer-server-app/src/test/java/com/cameleer/server/app/alerting/eval/AlertEvaluatorJobIT.java +++ b/cameleer-server-app/src/test/java/com/cameleer/server/app/alerting/eval/AlertEvaluatorJobIT.java @@ -54,6 +54,13 @@ class AlertEvaluatorJobIT extends AbstractPostgresIT { @BeforeEach void setup() { + // ClickHouse — purge any executions left over from prior tests in the + // shared CH instance. Matches the house-style used across the CH IT + // suite (see ClickHouseExecutionStoreIT, ClickHouseStatsStoreIT, etc.). + // TRUNCATE is synchronous, unlike ALTER ... DELETE (mutations_sync=0). + clickHouseJdbc.execute("TRUNCATE TABLE executions"); + clickHouseJdbc.execute("TRUNCATE TABLE processor_executions"); + // Default: empty registry — all evaluators return Clear when(agentRegistryService.findAll()).thenReturn(List.of()); @@ -91,13 +98,7 @@ class AlertEvaluatorJobIT extends AbstractPostgresIT { jdbcTemplate.update("DELETE FROM alert_rules WHERE environment_id = ?", envId); jdbcTemplate.update("DELETE FROM environments WHERE id = ?", envId); jdbcTemplate.update("DELETE FROM users WHERE user_id = ?", SYS_USER); - // ClickHouse — purge any executions seeded into this env. The shared CH instance - // persists across tests in the suite; scope the wipe to this test's env slug. - try { - if (envSlug != null) { - clickHouseJdbc.execute("ALTER TABLE executions DELETE WHERE environment = '" + envSlug + "'"); - } - } catch (Exception ignored) { /* best-effort; next setup uses a fresh env slug */ } + // ClickHouse `executions` is truncated in @BeforeEach (house style). } // -------------------------------------------------------------------------