Skip to content

Remove the strict audit-history assertion from test support - #956

Open
davidfrigolet wants to merge 1 commit into
masterfrom
remove-strict-audit-sequence-assertion
Open

Remove the strict audit-history assertion from test support#956
davidfrigolet wants to merge 1 commit into
masterfrom
remove-strict-audit-sequence-assertion

Conversation

@davidfrigolet

@davidfrigolet davidfrigolet commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

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). verifyAuditSequenceStrict asserted 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-util and flamingock-test-support are published artifacts, so nothing that currently uses verifyAuditSequenceStrict / THEN_VerifyAuditSequenceStrict breaks — they're marked @Deprecated with 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 existing thenExpectAuditFinalStateSequence in core/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 JournalEventStore for 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:

  • "ended up applied/failed" → final-state assertion.
  • "went through this sequence of transitions" → journal assertion (MongoDB sync, DynamoDB, SQL, in-memory) or final-state only where no journal support exists yet (MongoDB reactive, Couchbase, legacy Mongock importers).

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.

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant