test(alerting): align AlertEvaluatorJobIT CH cleanup with house style
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).
This commit is contained in:
@@ -54,6 +54,13 @@ class AlertEvaluatorJobIT extends AbstractPostgresIT {
|
|||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void setup() {
|
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
|
// Default: empty registry — all evaluators return Clear
|
||||||
when(agentRegistryService.findAll()).thenReturn(List.of());
|
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 alert_rules WHERE environment_id = ?", envId);
|
||||||
jdbcTemplate.update("DELETE FROM environments WHERE id = ?", envId);
|
jdbcTemplate.update("DELETE FROM environments WHERE id = ?", envId);
|
||||||
jdbcTemplate.update("DELETE FROM users WHERE user_id = ?", SYS_USER);
|
jdbcTemplate.update("DELETE FROM users WHERE user_id = ?", SYS_USER);
|
||||||
// ClickHouse — purge any executions seeded into this env. The shared CH instance
|
// ClickHouse `executions` is truncated in @BeforeEach (house style).
|
||||||
// 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 */ }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user