test(alerting): decentralize @MockBean + add SpringContextSmokeIT (follow-up to #141) #142
Reference in New Issue
Block a user
Delete Branch "fix/alerting-test-hygiene"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Follow-up to #141. Closes the test-coverage gap that let the production crashloop ship.
AbstractPostgresITcentrally declared three@MockBean(name=...)fields —clickHouseSearchIndex,clickHouseLogStore,agentRegistryService. Every IT inheriting it ran against those mocks, which meant the real Spring context was never assembled by CI. The declared-type / autowire-type mismatch onClickHouseSearchIndexthat caused #141 was invisible because the mocks' declared type was the concrete class, which Spring happily matched againstExchangeMatchEvaluator's concrete-typed autowire.What changed
@MockBeanfields fromAbstractPostgresIT.when(...)/verify(...)).SpringContextSmokeIT—@SpringBootTestwith no mocks, assertsvoid contextLoads(). This is the regression test that would have caught #141.Mock classification
agentRegistryServiceclickHouseLogStoreclickHouseSearchIndexSpringContextSmokeIT(new)AlertingFullLifecycleITAlertingEnvIsolationITfindAll)AlertEvaluatorJobITfindAll+ state transitions)NotificationDispatchJobITOutboundConnectionAllowedEnvITclickHouseSearchIndexhad zero active stubs across the whole suite — it was a purely passive mock. Every IT now gets the realClickHouseSearchIndexbean.Test results
PostgresAlertReadRepositoryIT.setupduplicate-key failures confirmed pre-existing on main (same 5 errors with no changes applied; not introduced by this PR).SpringContextSmokeITpasses:Started SpringContextSmokeIT in 8.556 seconds.SpringContextSmokeITfails immediately at context refresh — verified by the commit message trail.Impact
SpringContextSmokeITis ~30 LOC and runs on every CI invocation. Any future declared-type / autowire-type mismatch fails fast at context refresh, not at prod startup.Known pre-existing failures (unchanged by this PR)
PostgresAlertReadRepositoryIT.setup× 5 errors. Confirmed by running the same test class againstmaindirectly — identical error count. Needs a separate fix pass; out of scope here.