🐛 fix(bdd): revert PR #26 schema isolation, add cache flush + sequential test execution
PR #26 added BDD_SCHEMA_ISOLATION=true to CI but this creates per-scenario schemas WITHOUT running migrations on them, causing 500 errors on user registration. This PR reverts that and instead relies on: 1. The existing CleanupDatabase hook (truncates all tables AfterScenario) 2. Sequential test package execution (-p 1) to avoid contention between feature packages sharing the same Postgres DB Plus defensive additions for future-proofing: - pkg/server/server.go: GetCacheService() exposed for test cleanup - pkg/bdd/testserver/server.go: cacheService field + FlushCache() method - pkg/bdd/testserver/state_tracer.go: TraceStateCacheOperation - pkg/bdd/suite.go: AfterScenario hook calls FlushCache() - scripts/run-bdd-tests.sh: -p 1 added (sequential package execution) Validation: - AuthBDD alone: 5/5 PASS (was 0/5 with broken schema isolation) - Full features/ via run-bdd-tests.sh: ALL PASS (auth, config, greet, health, jwt) Out of scope (follow-up T12): - Proper parallel BDD with schema migrations per scenario + dedicated connection pools. Required for scaling tests but architecturally significant. Tracked. Co-Authored-By: Mistral Vibe (devstral-2 / mistral-medium-3.5) - cache flush diagnosis Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> - root cause + revert
This commit is contained in:
@@ -115,6 +115,15 @@ func InitializeTestSuite(ctx *godog.TestSuiteContext) {
|
||||
testserver.TraceStateJWTSecretOperation(feature, scenarioKey, "RESET", "ok")
|
||||
}
|
||||
|
||||
// Flush cache after every scenario to prevent cache pollution
|
||||
if flushErr := sharedServer.FlushCache(); flushErr != nil {
|
||||
if isCleanupLoggingEnabled() {
|
||||
log.Warn().Err(flushErr).Msg("CLEANUP: Failed to flush cache after scenario")
|
||||
}
|
||||
} else {
|
||||
testserver.TraceStateCacheOperation(feature, scenarioKey, "FLUSH", "ok")
|
||||
}
|
||||
|
||||
// Clean database after every scenario (only if schema isolation is disabled)
|
||||
if !isSchemaIsolationEnabled() {
|
||||
if cleanupErr := sharedServer.CleanupDatabase(); cleanupErr != nil {
|
||||
|
||||
Reference in New Issue
Block a user