Skip to content

Enhance DurableStateStore TCK with OCC, serialization, and soft-delete tests#2917

Merged
pjfanning merged 5 commits intoapache:mainfrom
drse:feature/durable-state-tck-enhancements
Apr 27, 2026
Merged

Enhance DurableStateStore TCK with OCC, serialization, and soft-delete tests#2917
pjfanning merged 5 commits intoapache:mainfrom
drse:feature/durable-state-tck-enhancements

Conversation

@drse
Copy link
Copy Markdown
Contributor

@drse drse commented Apr 26, 2026

Summary

Enhances the AI-drafted DurableStateStore TCK from #2833 to address the gaps
discussed in #2831 — specifically optimistic-concurrency checks, serialization
roundtrip, and the deprecated soft-delete overload.

This PR supersedes #2833. The first three commits are @pjfanning's original
work cherry-picked unchanged; the fourth commit layers the enhancements on top.

Changes

Capability flags (CapabilityFlags.scala)

DurableStateStoreCapabilityFlags extended with three new flags:

  • supportsUpsertWithRevisionCheck — when on, asserts that an upsert with
    a stale revision is rejected and the prior state is preserved.
  • supportsSerialization — when on, asserts that values roundtrip through
    the configured Pekko serializer using the same TestPayload(probe.ref)
    pattern as JournalSpec. Defaults to on in DurableStateStoreSpec to
    match the JournalSpec convention; the in-memory testkit reference TCK
    explicitly overrides to off since the testkit holds raw refs.
  • supportsSoftDelete — when on, asserts the deprecated single-argument
    deleteObject(persistenceId) overload deletes regardless of revision.

Spec additions (DurableStateStoreSpec.scala)

  • New required test: "upsert again after a deletion" — ensures the store
    accepts a fresh upsert at a higher revision after a delete.
  • New optional tests behind each new capability flag.
  • New preparePersistenceId(pid: String) hook called from beforeEach,
    mirroring JournalSpec. Plugins backed by external state (JDBC, NATS, etc.)
    can override this to clean residual records between tests.
  • Test timeout promoted to protected so subclasses can override for slow
    stores.

Reference TCK (PersistenceTestKitDurableStateStoreTCKSpec.scala)

Added an explicit supportsSerialization = off override since the in-memory
testkit doesn't serialize values.

Docs (persistence-journals.md + doc-test files)

Added a brief subsection in the ## Plugin TCK section mirroring the
Journal/Snapshot pattern, with #durable-state-tck-scala and
#durable-state-tck-java snippet markers.

Deferred for follow-up

These ideas surfaced during this work but were deliberately scoped out:

  • Query-by-tag roundtrip — verify a tag passed to upsertObject is
    retrievable via DurableStateStoreQuery.changes(...). Requires extending the
    TCK to cover the read-side query SPI.
  • Get-after-delete revision contract — current tests assert value=None
    after delete but not what revision should be (impls differ; needs a
    committer decision).
  • Idempotent upsert — repeating upsertObject(pid, N, sameValue, tag) for
    replay safety.
  • Slice-based query roundtrip (DurableStateStoreBySliceQuery).
  • Paged persistence-ID enumeration (DurableStateStorePagedPersistenceIdsQuery).

Happy to open follow-up PRs once this lands.

Test plan

  • sbt scalafmtCheckAll — clean
  • sbt persistence-tck/Test/compile docs/Test/compile — clean
  • sbt "persistence-testkit/Test/testOnly *PersistenceTestKitDurableStateStoreTCKSpec"
    6/6 required tests pass; 4 optional skip as expected (testkit doesn't enforce
    OCC, doesn't serialize, has a no-op deleteObject(pid)).

Closes #2831.

Copilot AI and others added 4 commits April 26, 2026 12:09
…e tests

Builds on apache#2833 to address the gaps discussed in apache#2831:

- Optimistic concurrency check on upsert (supportsUpsertWithRevisionCheck)
- Roundtrip serialization via TestPayload (supportsSerialization, defaults on
  to match JournalSpec convention)
- Deprecated single-arg deleteObject(pid) overload (supportsSoftDelete)
- New required test: upsert again after deletion
- preparePersistenceId cleanup hook for stateful plugins
- Brief plugin-author docs subsection in persistence-journals.md mirroring
  the Journal/SnapshotStore TCK pattern

The reference TCK against PersistenceTestKitDurableStateStore passes 6/6
required tests; all 4 optional capability flags correctly skip when off.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@drse drse marked this pull request as ready for review April 26, 2026 20:14
*/

/*
* Copyright (C) 2014-2022 Lightbend Inc. <https://www.lightbend.com>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not 2023?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is copied from a file that has 2022 in it

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but IIRC akka will update the year every year

Copy link
Copy Markdown
Member

@pjfanning pjfanning Apr 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we shouldn't update the date if we don't grab newer akka code from 2023 - this PR does not grab any 2023 akka code

Copy link
Copy Markdown
Member

@He-Pin He-Pin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@pjfanning pjfanning merged commit 35a1e23 into apache:main Apr 27, 2026
9 checks passed
@pjfanning
Copy link
Copy Markdown
Member

Merged, thanks

Copilot AI added a commit to pjfanning/incubator-pekko-persistence-jdbc that referenced this pull request Apr 28, 2026
pjfanning added a commit to pjfanning/incubator-pekko-persistence-jdbc that referenced this pull request Apr 28, 2026
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.

Provide TCK for DurableStateStore

4 participants