Skip to content

Add DurableStateBehaviorTestKit#3360

Merged
He-Pin merged 1 commit into
apache:mainfrom
He-Pin:feat/3236-durable-state-behavior-testkit
Jul 18, 2026
Merged

Add DurableStateBehaviorTestKit#3360
He-Pin merged 1 commit into
apache:mainfrom
He-Pin:feat/3236-durable-state-behavior-testkit

Conversation

@He-Pin

@He-Pin He-Pin commented Jul 17, 2026

Copy link
Copy Markdown
Member

Motivation

DurableStateBehavior does not have the high-level actor-based test API available for EventSourcedBehavior. Issue #3236 requests matching Scala and Java APIs for commands, replies, state inspection, serialization verification, restart recovery, and clearing state.

Modification

  • Add aligned Scala and Java DurableStateBehaviorTestKit APIs.
  • Execute commands against a real actor and return synchronous command, reply, state, and restart results.
  • Add configurable command, state, and reply serialization checks.
  • Isolate the in-memory durable state store between test-kit instances and expose per-behavior clear().
  • Retrieve the persistence ID through an internal protocol message so catch-all user signal handlers remain supported.
  • Add a null-safe internal state response while retaining the existing internal message shape for binary compatibility.
  • Use sbt headerCreateAll generated standard Apache headers for all new files.
  • Add Scala and Java directional tests and persistence testing documentation.

The API structure follows the existing EventSourcedBehaviorTestKit, but the Durable State implementation is new. No external code was copied.

Result

Durable state behaviors can now be tested through a high-level API in both DSLs with isolated state, restart/clear support, and serialization verification.

Tests

  • Scala 2.13 focused suites — 17 passed.
  • Scala 3.3.8 focused suites — 17 passed.
  • sbt +mimaReportBinaryIssues — passed.
  • sbt docs/paradox — passed; only existing duplicate-anchor warnings were reported.
  • sbt checkCodeStyle — passed.
  • sbt headerCreateAll +headerCheckAll — passed.
  • JDK 17: sbt javafmtAll javafmtCheckAll — passed.
  • scalafmt --list --mode diff-ref=origin/main — passed with no files listed.
  • git diff --check — passed.
  • Qoder auditable stdout review — no must-fix findings.

References

Fixes #3236

@He-Pin
He-Pin marked this pull request as draft July 17, 2026 10:34
@He-Pin
He-Pin marked this pull request as ready for review July 17, 2026 11:56
@He-Pin He-Pin added this to the 2.0.0-M4 milestone Jul 17, 2026
@He-Pin
He-Pin requested a review from pjfanning July 17, 2026 11:57
@He-Pin
He-Pin marked this pull request as draft July 17, 2026 12:00
@He-Pin
He-Pin marked this pull request as ready for review July 17, 2026 12:07
@He-Pin
He-Pin force-pushed the feat/3236-durable-state-behavior-testkit branch from 0a22aa9 to db2a3bc Compare July 17, 2026 12:42
* The result contains the new state after the command has been processed.
* It also has support for verifying the reply to a command.
*
* Serialization of commands and state is verified automatically.

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.

Can you add @since 2.0.0 on new public API classes and functions?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Will do

Motivation:
DurableStateBehavior lacks the high-level actor-based test API available for EventSourcedBehavior.

Modification:
Add matching Scala and Java DurableStateBehaviorTestKit APIs for commands, replies, state inspection, serialization checks, restart, and clear. Isolate the in-memory store between test kits, make persistence-id discovery work with catch-all signal handlers, use generated Apache headers for new files, and add documentation and directional tests.

Result:
Durable state behaviors can be exercised through a synchronous high-level test API with isolated state and aligned Scala and Java DSLs.

Tests:
- Scala 2.13 and 3.3.8 focused DurableStateBehaviorTestKit suites (17 passed on each)
- sbt +mimaReportBinaryIssues
- sbt docs/paradox (passed with existing duplicate-anchor warnings)
- sbt checkCodeStyle
- sbt headerCreateAll +headerCheckAll
- JDK 17: sbt javafmtAll javafmtCheckAll
- scalafmt --list --mode diff-ref=origin/main
- git diff --check
- Qoder stdout review: No must-fix findings

References:
Fixes apache#3236
@He-Pin
He-Pin force-pushed the feat/3236-durable-state-behavior-testkit branch from db2a3bc to faf7f7f Compare July 18, 2026 14:02
@He-Pin
He-Pin requested a review from pjfanning July 18, 2026 14:05

@pjfanning pjfanning left a comment

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.

lgtm

@He-Pin
He-Pin merged commit 5379ab3 into apache:main Jul 18, 2026
10 checks passed
@He-Pin
He-Pin deleted the feat/3236-durable-state-behavior-testkit branch July 18, 2026 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing DurableStateBehaviorTestKit

2 participants