Skip to content

Add DurableStateStore TCK to persistence-tck module#2833

Draft
pjfanning wants to merge 2 commits intoapache:mainfrom
pjfanning:copilot/add-durable-state-store-support
Draft

Add DurableStateStore TCK to persistence-tck module#2833
pjfanning wants to merge 2 commits intoapache:mainfrom
pjfanning:copilot/add-durable-state-store-support

Conversation

@pjfanning
Copy link
Copy Markdown
Member

Summary

See #2831

Adds a standardised Technology Compatibility Kit (TCK) for DurableStateStore implementations to the persistence-tck module. This allows plugin authors (such as those working on pekko-persistence-jdbc, pekko-persistence-r2dbc, and pekko-persistence-cassandra) to include a consistent test suite in their projects.

Changes

persistence-tck/src/main/scala/org/apache/pekko/persistence/CapabilityFlags.scala

  • Added DurableStateStoreCapabilityFlags trait with a supportsDeleteWithRevisionCheck capability flag, following the same pattern as JournalCapabilityFlags and SnapshotStoreCapabilityFlags.

persistence-tck/src/main/scala/org/apache/pekko/persistence/state/DurableStateStoreSpec.scala (new)

Scala TCK spec that plugin authors extend. Tests:

  • getObject on a non-existing persistence ID returns None
  • upsertObject followed by getObject returns the stored value and correct revision
  • Upserting twice updates the state (last write wins)
  • deleteObject(persistenceId, revision) makes the state unavailable
  • Different persistence IDs are independent of one another
  • Optional (supportsDeleteWithRevisionCheck): deleting with a mismatched revision fails and leaves the original state intact

persistence-tck/src/main/scala/org/apache/pekko/persistence/japi/state/JavaDurableStateStoreSpec.scala (new)

Java/JUnit-consumable wrapper around DurableStateStoreSpec, following the same pattern as JavaJournalSpec and JavaSnapshotStoreSpec.

persistence-testkit/src/test/scala/…/PersistenceTestKitDurableStateStoreTCKSpec.scala (new)

Reference test implementation that exercises the new TCK using the existing in-memory PersistenceTestKitDurableStateStore, verifying the TCK itself works correctly.

Usage by plugin authors

class MyPluginDurableStateStoreSpec
    extends DurableStateStoreSpec(
      ConfigFactory.parseString("""
        pekko.persistence.state.plugin = "my.plugin.durable-state"
        my.plugin.durable-state.class = "com.example.MyDurableStateStoreProvider"
      """)
    ) {
  override protected def supportsDeleteWithRevisionCheck: CapabilityFlag = CapabilityFlag.on()
}

Agent-Logs-Url: https://github.com/pjfanning/incubator-pekko/sessions/77803e79-3631-4111-98a8-4a1cf6f7beca

@pjfanning pjfanning marked this pull request as draft April 3, 2026 10:46
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.

2 participants