Remove the strict audit-history assertion from test support - #956
Open
davidfrigolet wants to merge 1 commit into
Open
Remove the strict audit-history assertion from test support#956davidfrigolet wants to merge 1 commit into
davidfrigolet wants to merge 1 commit into
Conversation
…e alternative The audit log is moving to one record per change (its current state), with the history of transitions moving to the journal (`Features.JOURNAL_EVENTS`). `AuditTestHelper#verifyAuditSequenceStrict` / `AuditTestSupport#THEN_VerifyAuditSequenceStrict` assert an ordered audit *history* (`STARTED, APPLIED, ...`), which no longer describes what the audit log holds. **API changes** (`utils/test-util`, published artifact — kept backward compatible, no hard removal): - Added `AuditTestHelper#verifyAuditFinalStateSequence` / `AuditTestSupport#THEN_VerifyAuditFinalStateSequence`, asserting the final state per change (same exclusion rules as `core/flamingock-test-support`'s `AuditFinalStateSequenceValidator`: drops `STARTED`, system changes, and legacy `_before` snapshots). - Deprecated the old strict-sequence methods instead of deleting them — they still work exactly as before for any existing caller, with a Javadoc pointer to the replacement. Actual removal deferred to a future major version. - `thenExpectAuditFinalStateSequence` / `AuditEntryDefinition` in `core/flamingock-test-support` are untouched. **New: in-memory journal support** (`utils/test-util`), so the STARTED→ APPLIED/FAILED/ROLLED_BACK progression some tests exist specifically to prove isn't lost when migrated off the audit log: - `InternalInMemoryJournalEventStore` — in-memory `JournalEventStore`, mirrors the shape of `MongoDBSyncJournalEventStore` / `SqlJournalEventStore` / `DynamoDBJournalEventStore`. - `InternalInMemoryAuditStorage#upsertAuditEntry` — current-state upsert keyed by changeId, the in-memory counterpart to `MongoDBSyncAuditRepository#save`. - `InternalInMemoryTestAuditPersistence` / `InternalInMemoryTestAuditStore` / `InternalInMemoryTestKit` wire the two together, gated by `Features.JOURNAL_EVENTS`, exactly like the real audit stores. - `RecoveryE2ETest` gained a dedicated journal-based test proving the retry progression (FAILED → STARTED → APPLIED) survives in the journal even though the audit log now only shows the final state. **Migration of all internal call sites** (21+ files across 11 modules) off the deprecated API onto the new one: - "the change ended up applied/failed" → `verifyAuditFinalStateSequence`. - "the change went through this sequence of transitions" for the failure/rollback scenarios → either the journal (where the store supports it: MongoDB sync, DynamoDB, SQL, and the in-memory kit) or a final-state assertion covering just the outcome (MongoDB reactive, Couchbase, and the legacy Mongock importers — none of these have journal support yet). - `MongoDBSyncJournalFeatureFlagE2ETest` / `DynamoDBJournalFeatureFlagE2ETest` updated to use the final-state API for both the flag-on and flag-off cases. No test's coverage was silently weakened to "it ran" — failure/rollback progressions land on final-state assertions that still name every terminal status (e.g. `FAILED` + `ROLLED_BACK` both asserted), and the four stores that have journal support get an explicit journal-based test proving the dropped transition history is preserved there.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The audit log is becoming the change's current state — one record per change, updated in place — with the history of transitions moving to the journal (
Features.JOURNAL_EVENTS).verifyAuditSequenceStrictasserted an ordered audit history (STARTED, APPLIED, ...); under the new model those intermediate rows don't survive, so the assertion no longer describes what the audit log holds.What changed
New API, old API deprecated (not deleted)
test-utilandflamingock-test-supportare published artifacts, so nothing that currently usesverifyAuditSequenceStrict/THEN_VerifyAuditSequenceStrictbreaks — they're marked@Deprecatedwith a pointer to the replacement, still work exactly as before, and removal is deferred to a future major version.AuditTestHelper#verifyAuditFinalStateSequence/AuditTestSupport#THEN_VerifyAuditFinalStateSequence— asserts the final state per change instead of the full transition history. Same filtering rules as the existingthenExpectAuditFinalStateSequenceincore/flamingock-test-support(which is untouched).New: in-memory journal support
Some tests exist specifically to prove a change goes through STARTED → FAILED → ROLLED_BACK (or similar). That coverage is real and worth keeping, so where a store has journal support, it now has a test proving that progression lives in the journal instead of the audit log. That included building an in-memory
JournalEventStorefor the core in-memory test kit (utils/test-util), which didn't have one before — it mirrors the real stores' MongoDB/SQL/DynamoDB journal implementations.Migrated every internal usage (21+ files, 11 modules) off the deprecated API:
No coverage was silently dropped — failure/rollback checks still assert every terminal status, just not the STARTED steps in between.
Verification
./gradlew clean build— full green, including all Docker-gated store suites.Not done
Hard-deleting
verifyAuditSequenceStrict(as the original ticket's acceptance criteria asked for) — that's a breaking change to a published artifact, deferred instead of done outright. Flagging this explicitly since it's a deviation from the letter of the original ask.