Durable Store testing
After changing Durable storage, recovery, or worker behavior, identify tests for the affected scenarios, run the relevant database suites, and verify their reports. This page gives PostgreSQL and MySQL commands, then explains the shared tests, database-specific tests, and release reports.
These tests clear or recreate databases. Use disposable infrastructure only. After Maven succeeds, check that the intended tests ran rather than being skipped because a database was unavailable.
Run the commands below from the repository root. Configure a supported JDK using Contributing, then check Maven’s actual JDK with ./mvnw -version. Replace /path/to/jdk-21 in the first example with your local JDK 21 path.
Run the database tests
Section titled “Run the database tests”PostgreSQL with Docker
Section titled “PostgreSQL with Docker”With Docker, the normal Maven suite runs
PostgresDurableStoreContractTest through Testcontainers:
JAVA_HOME=/path/to/jdk-21 ./mvnw test \ -pl :compileflow-durable-postgresql \ -amPostgreSQL with an existing test database
Section titled “PostgreSQL with an existing test database”Without Docker, supply a dedicated, disposable PostgreSQL test database and replace the sample username and password with your test credentials. Each test clears and reinitializes its public schema.
The wildcard below also runs the ACK-loss test. A child JVM uses fsync to persist a received WAIT_COMMITTED event, then is killed before acknowledging Outbox completion. Recovery must redeliver that same logical event before committing DELIVERED.
export COMPILEFLOW_DURABLE_POSTGRES_URL='jdbc:postgresql://127.0.0.1:5432/compileflow_test'export COMPILEFLOW_DURABLE_POSTGRES_USER='your-test-user'export COMPILEFLOW_DURABLE_POSTGRES_PASSWORD='your-test-password'
./mvnw test \ -pl :compileflow-durable-postgresql \ -am \ -Dtest='LocalPostgres*Test' \ -Dsurefire.failIfNoSpecifiedTests=falseNever run these tests against a database containing valuable data.
MySQL with Docker
Section titled “MySQL with Docker”MySQL 8.4 uses a separate Store implementation. Its contract tests run through Testcontainers:
./mvnw test \ -pl :compileflow-durable-mysql \ -amMySQL with an existing test database
Section titled “MySQL with an existing test database”For an existing disposable MySQL database, set COMPILEFLOW_DURABLE_MYSQL_URL, COMPILEFLOW_DURABLE_MYSQL_USER, and COMPILEFLOW_DURABLE_MYSQL_PASSWORD. Supply a separate migration account through COMPILEFLOW_DURABLE_MYSQL_MIGRATION_USER and COMPILEFLOW_DURABLE_MYSQL_MIGRATION_PASSWORD.
These suites clean and migrate the database. The Store contract deliberately uses non-UTC sessions. Never connect the tests to a database containing valuable data. The migration account runs DDL and creates triggers; the runtime account needs neither SUPER nor a change to global trust settings.
./mvnw test \ -pl :compileflow-durable-mysql \ -am \ -Dtest='LocalMySql*Test' \ -Dsurefire.failIfNoSpecifiedTests=falseThe wildcard includes the local Store contract, Effect fault, Wait backend, creation retry, and emission budget suites.
Confirm that the tests ran
Section titled “Confirm that the tests ran”Inspect target/surefire-reports in the selected Provider module. The intended test classes must have reports from this run, with no failures or errors and no skipped required cases. If a missing database caused tests to be skipped, BUILD SUCCESS does not verify Store behavior. See Check reports before release for the full release requirements.
Contract coverage
Section titled “Contract coverage”DurableStoreContract checks:
- immutable and idempotent Process registration;
- Store-level Start preserves the caller-supplied Run ID and rejects duplicate creation;
engine-level
DurableProcessEngine.start(...)retries are checked separately; - Wait commit, token-based completion, resume, terminal commit, and rejection of stale Run leases;
- the separate behavior of Pause, Resume, and Cancel, including their interactions;
- committed Timer firings and Effect completions being available for recovery;
- unchanged Outbox event IDs, types, and payloads on retry, correct attempt counts, and rejection of stale lease tokens;
- bounded batch renewal for Run, Effect, and Outbox leases, partial lease loss, whole-millisecond duration checks, and crash recovery;
- correct operator-review revisions after new DISPATCH attempts, restored attempt counts when an implementation is unavailable, retries, reconciliation, and lease loss;
- Effect and Outbox revision checks, terminal retention, and the Run-first lock order under races and deadlock tests.
Runtime renewal tests check that Run, Effect, and Outbox leases renew independently, processing continues across bounded batches, unexpected Store failures are retried, and blocked calls are detected. They also check how failures and recovery affect worker health.
Spring tests check the shutdown sequence: stop claiming tasks, request interruption when the wait limit expires, and release resources or invoke completion callbacks only after the calls actually exit.
Each provider must also verify migration constraints, query plans and indexes, high contention, least-privilege accounts, backup and restore, and every supported PostgreSQL/MySQL version.
Each first-party Provider contract test calls createEmptyStore(); test methods never share state.
Requirements for Store implementations
Section titled “Requirements for Store implementations”compileflow-durable-testkit tests the transaction behavior of the project’s DurableStore implementations. The shared Store contract depends on the public API types and compileflow-durable-spi, without a runtime implementation. Runtime integration helpers are packaged in the test JAR and also use compileflow-durable-runtime and the TBBPM/BPMN modules.
Each provider must implement the complete transactions and separately verify its migrations and physical schema. Passing these tests does not make a third-party Store a supported implementation. The SPI is not a general persistence framework.
Every provider must implement all state transitions in the shared transaction contract and pass the testkit. A default method throwing UnsupportedOperationException cannot substitute for a required implementation.
PostgreSQL additionally supports declared execution requirements, Run execution holds set through application transactions and managed separately from operator Pause/Resume, and stopping emission publication before a Run ends. MySQL must reject unsupported admission extensions before accessing JDBC, and reject an early seal in the fenced Turn transaction after giving previously committed termination intent precedence. Provider-specific tests verify both PostgreSQL support and MySQL rejection, so requests cannot be silently ignored or partially applied.
Recovery regression coverage
Section titled “Recovery regression coverage”Types, state, and result recovery
Section titled “Types, state, and result recovery”| Test suite | Main checks |
|---|---|
DurableValueSerializerTest |
POJO/record types and values survive round trips; lossy restoration is rejected; decimal scale, nulls, and list order are preserved. |
DurableBpmnProfileCoverageTest, DurableCompiledInterpretedDifferentialTest |
Compiled and interpreted backends retain the same sequential-loop state after repeated encoding and decoding with Turn budgets 1, 2, 3, and 1000. |
DurableEffectWorkerTest |
A returned result that fails mapping or encoding requires review; commit retries reuse the original bytes without repeating the Action; lease loss prevents new calls, while returned results are recorded under the original attempt. |
DurableStoreContract, DurableTerminationStoreContract |
An earlier investigation cannot resolve a later dispatch; identical decisions can be retried within the same review revision; restoring an attempt count does not decrease the revision; confirmed-not-executed results persist even when no dispatch attempts remain; the first termination request, audit records, and retention rules are preserved. |
DurableTypeNameDifferentialTest |
Business types named Map, same-name types in different packages, and valid variable names compile, execute, and restore from typed checkpoints on both backends. |
DurableProcessRuntimeManagerTest, DefaultDurableProcessEngineTest |
Terminal results remain queryable without the implementation needed to execute scripts; the value-schema cache is bounded and released on close. |
Workers and failure recovery
Section titled “Workers and failure recovery”| Test suite | Main checks |
|---|---|
DurableWorkerCoordinatorTest, DurableWorkerClaimAdmissionTest |
After startup or an idle period, workers add parallel tasks as they find queued work; new tasks are discovered while earlier tasks block; stopping, rejected submissions, and cancelled probes do not cause excess claims. |
DurableEffectCapacityTest |
Every recovery policy can run when dispatch slots are full; neither lane borrows capacity; shutdown preserves limits and lease renewal until callbacks actually exit. |
DurableEffectFaultContract |
Both real databases and both backends: blocked HTTP dispatches renew leases, maintenance reclaims lost attempts, and reserved recovery slots run MANUAL, RETRY, and RECONCILE; an independently persisted complete result survives lost ACKs, duplicate delivery, and Run cleanup. |
Database schema and integration behavior
Section titled “Database schema and integration behavior”| Test suite | Main checks |
|---|---|
DurablePostgresPhysicalSchemaTest, DurableMySqlPhysicalSchemaTest |
Real migration and startup checks fail on missing tables, columns, defaults, constraints, or triggers even with intact Flyway history; MySQL validates with DML privileges and EXECUTE on the restricted metadata procedure alone. |
DurablePostgresSpringLifecycleTest |
With real Spring configuration, Effect tasks reach the configured capacity; shutdown waits for callbacks to exit before completing; and an unconfirmed call becomes UNKNOWN and recovers after its lease actually expires. Exceeding the shutdown wait limit does not by itself expire a lease. |
LocalPostgresDurablePublicationSealTest, DurableTurnWorkerTest, DurablePublicationSealValueTest, MySqlDurableStoreContract |
Publication records and the seal are checked against the original lease and commit or roll back with the Turn; the first seal remains unchanged as the Run continues; concurrent inserts, direct SQL, terminal handling, and startup checks enforce the same rules; worker snapshots and values are validated, and MySQL rejects unsupported early seals without accepting the proposed Turn, while preserving stale-lease and termination precedence. |
Physical-schema tests use the providers’ local database environment variables when available, otherwise Testcontainers. Each test creates and drops an isolated database, so the migration test account needs database-creation privileges. MySQL’s least-privilege test also creates and drops a temporary account. These extra privileges are needed only for test setup.
Schema checks verify required tables, columns, constraints, and triggers. They do not prove that rewritten CHECK expressions or trigger bodies behave like the originals.
The PostgreSQL publication suite initializes the complete schema and checks that startup fails if required seal columns are missing or the insertion guard no longer uses ENABLE ALWAYS. Its class name matches LocalPostgres*Test, so it runs in the PostgreSQL version matrix. Release verification requires every designated test method to run without skips.
Shared fixtures and database setup
Section titled “Shared fixtures and database setup”DurableJdbcWaitContract checks deadline enforcement after lock waits, handling of a successful commit with a lost acknowledgment, and preservation of an already-completed Wait’s identity. Runtime fixtures are shared with test scope through the Testkit test JAR:
DurableEffectFaultContractchecks both backends for result-commit ACK loss, committed or uncommitted review, SIGKILL after an independent HTTP tool persists its result, stale workers, reconciliation during termination, and shutdown after calls actually exit.DurableWaitBackendContractchecks both frontends and both backends on each real Store: absolute deadlines, immediate timeout without token delivery, and repeated and concurrent child invocations across restarts and backend switches.
Durable supports Process calls inside concurrent gateway scopes. Each child invocation retains its own occurrence identity across recovery; the Store contract also checks invocation-qualified frontiers directly. Process calls inside parallel-foreach iterations remain unsupported.
Development and acceptance tests use isolated, fresh disposable databases initialized from the current V1 baseline. Verify the migration checksums and physical schema against the packaged baseline. Runtime startup must reject unknown or mismatched schemas; do not use Flyway repair or automatic data clearing to bypass validation.
Required race coverage
Section titled “Required race coverage”Supported Provider verification must cover at least:
- two workers claiming the same Run/Effect/Outbox row;
- lease expiry followed by replacement claim and late old-token completion;
- Wait completion versus Cancel;
- Pause versus an in-flight Turn or Effect;
- Timer firing versus Cancel;
- Effect completion versus operator resolution;
- Outbox completion versus retry/abandon;
- concurrent Start requests using distinct valid Run IDs;
- external durable acceptance followed by process
SIGKILLbefore Outbox completion, then exact-event replay.
When competing transitions for the same task have mutually exclusive outcomes, at most one decision may commit. Independent Starts with different Run IDs may all succeed. Database transactions and lease tokens decide whether a commit is accepted; which worker returns first is insufficient.
Verify uncommitted changes
Section titled “Verify uncommitted changes”When verifying uncommitted changes, test the actual worktree, including untracked source. record_durable_source.py copies it to a new directory and records SHA-256 hashes and executable flags. A later check detects changed, missing, or added inputs. It does not modify the Git index or original build directory. The snapshot excludes build output, ignored files, and files matching local secret-file patterns. Configure external dependencies separately and record the versions actually resolved.
EVIDENCE_DIR=$(mktemp -d)python3 scripts/record_durable_source.py --root "$PWD" \ --manifest "$EVIDENCE_DIR/source.json" --snapshot "$EVIDENCE_DIR/source"# Run the selected Maven/Workbench suites in the new snapshot. Record Unix start time,# exact command, JDK/Maven/database versions, and copy raw reports before another clean.python3 scripts/record_durable_source.py --root "$EVIDENCE_DIR/source" \ --manifest "$EVIDENCE_DIR/source.json" --checkUse scripts/verify_durable_test_evidence.py for local snapshot evidence. To bind a snapshot, provide paired --source-root and --source-manifest arguments; the verifier checks the source inventory before recording metadata.source-sha256. A caller-supplied digest requires the same source check and must match it. Use --reports-not-before in Unix seconds to reject older reports. For each real database contract, also provide --metadata build-start-epoch=..., the full set of required testcase IDs, and --reject-skips.
Run in a new snapshot without old target directories, retain the execution logs, and recheck source hashes afterward. A recent report modification time does not by itself identify the code that produced the report.
Tests of uncommitted local changes supplement the clean-commit release matrix. They cover only the database versions and scenarios actually tested and do not replace production recovery drills.
Check reports before release
Section titled “Check reports before release”scripts/verify_durable_release_evidence.py defines the testcases and passing criteria required for release. CI calls its suite subcommand to produce each suite manifest. Callers provide report locations and release metadata, but cannot override required cases, report counts, minimum pass counts, or skip rules.
The suite command and aggregation share one closed metadata contract: every suite requires commit and java; PostgreSQL and MySQL contracts additionally require their respective postgres or mysql version and declared-image. Missing or extra fields are rejected before suite writes a manifest. Local snapshot options --source-root and --source-manifest, and source-sha256 metadata, belong to the generic verifier above and cannot enter the release matrix. The release suite command still accepts --reports-not-before to check report freshness.
Release aggregation reparses the retained raw JUnit XML and checks these rules, report digests, and the commit and environment identities recorded by the workflow. Source attribution depends on the controlled workflow that runs the build and retains its evidence; a commit string, a matching source digest, or a clean worktree does not authenticate an untrusted runner. The verifier does not trust summary counts alone or derive the required case list from whichever tests happened to run. Its tests include the complete suite-to-aggregate command path, snapshot/release separation, missing required cases, skips, failures, flaky reruns, duplicate testcase identities, weakened manifests, and attempts to override release policy.
Verification records
Section titled “Verification records”The production-drill record schema applies to PostgreSQL and requires its database system and timeline IDs. Passing MySQL contract tests still leaves MySQL-specific failover, restore, and production capacity to be verified.
Verification records include:
- Maven and exact database Provider/version;
- migration checksum and schema-contract result;
- inherited Kernel Store contract result;
- race/stress duration and seed;
- PITR drill result;
- query-plan evidence for claim and operator indexes;
- evidence that an expired lease cannot authorize new calls or Turn commits, and that late Effect results must match the original started attempt;
- process-level ACK-loss evidence preserving Outbox event ID, type, and logical payload across replay.
See the Durable architecture.
Out of scope
Section titled “Out of scope”The Store contract does not promise:
- Alias resolution or rollout;
- generated program/bytecode persistence;
- custom persisted codecs;
- exactly-once remote effects;
- exactly-once generic external Outbox side effects.
Test Alias routing through the Deploy contract. Verify remote idempotency and delivery durability against the application’s actual adapters and external services.