elsa-core/test/unit/Elsa.UserTasks.Persistence.ConformanceTests
Sipke Schoorstra f6d2d38536
test(user-tasks): add a persistence conformance suite with fault injection (#7986)
Runs one suite unchanged against every implementation of IUserTaskRepository,
IUserTaskGuestSessionIssuer, and IUserTaskInvitationOutbox, plus a fault-injection
suite driving the real DefaultUserTaskManager and DefaultUserTaskInvitationService
against a real store. Gated providers report as skipped with a reason rather than
passing vacuously; ConformanceCoverageTests fails when a provider that must run is
unreachable or its variable is set but empty.

The suite found three defects, fixed here:

- VNextUserTaskRepository supplied no index values for WorkflowDefinitionId,
  WorkflowInstanceId, ActivityInstanceId, CreatedAt, or CompletedAt, all declared by
  its own schema provider, so every write through the VNext provider threw.
- The same provider resolved invitation token hashes by scanning on Status alone,
  which matched no declared index, so anonymous invitation verification always threw.
- EFCoreUserTaskInvitationOutbox persisted the delivery recipient but never read it
  back, so durably queued invitations reached the dispatcher with no address.

Also switches new ADRs to date-prefixed identifiers and generates doc/adr/toc.md via
scripts/adr/generate-toc.sh, with a --check mode and pull-request workflow so the
index is never hand-edited again.
2026-08-25 04:36:18 +02:00
..
Faults test(user-tasks): add a persistence conformance suite with fault injection (#7986) 2026-08-25 04:36:18 +02:00
Infrastructure test(user-tasks): add a persistence conformance suite with fault injection (#7986) 2026-08-25 04:36:18 +02:00
Providers test(user-tasks): add a persistence conformance suite with fault injection (#7986) 2026-08-25 04:36:18 +02:00
ConformanceCoverageTests.cs test(user-tasks): add a persistence conformance suite with fault injection (#7986) 2026-08-25 04:36:18 +02:00
Elsa.UserTasks.Persistence.ConformanceTests.csproj test(user-tasks): add a persistence conformance suite with fault injection (#7986) 2026-08-25 04:36:18 +02:00
ProviderConformanceSuites.cs test(user-tasks): add a persistence conformance suite with fault injection (#7986) 2026-08-25 04:36:18 +02:00
README.md test(user-tasks): add a persistence conformance suite with fault injection (#7986) 2026-08-25 04:36:18 +02:00
UserTaskConformanceTestBase.cs test(user-tasks): add a persistence conformance suite with fault injection (#7986) 2026-08-25 04:36:18 +02:00
UserTaskFaultInjectionConformanceTests.cs test(user-tasks): add a persistence conformance suite with fault injection (#7986) 2026-08-25 04:36:18 +02:00
UserTaskGuestSessionConformanceTests.cs test(user-tasks): add a persistence conformance suite with fault injection (#7986) 2026-08-25 04:36:18 +02:00
UserTaskInvitationOutboxConformanceTests.cs test(user-tasks): add a persistence conformance suite with fault injection (#7986) 2026-08-25 04:36:18 +02:00
UserTaskRepositoryConformanceTests.cs test(user-tasks): add a persistence conformance suite with fault injection (#7986) 2026-08-25 04:36:18 +02:00

User Tasks persistence conformance suite

One suite, run unchanged against every implementation of the User Tasks persistence contracts. It exists because the User Tasks build shipped four P1 defects that a single-threaded, happy-path, in-memory test suite could not see — every one of them was found by injecting a failure against a real store.

What it covers

Contract Suite Implementations
IUserTaskRepository UserTaskRepositoryConformanceTests InMemory, EF Core, VNext
IUserTaskGuestSessionIssuer UserTaskGuestSessionConformanceTests InMemory, EF Core
IUserTaskInvitationOutbox UserTaskInvitationOutboxConformanceTests InMemory, EF Core
The services above them UserTaskFaultInjectionConformanceTests InMemory, EF Core

UserTaskFaultInjectionConformanceTests runs the real DefaultUserTaskManager and DefaultUserTaskInvitationService against a real store and breaks the seams between them with the decorators in Faults/. A cross-store operation must either commit fully or leave the caller able to retry, and the retry must converge.

Providers

Availability is resolved once per run by ConformanceProviders, and nothing is ever skipped quietly:

  • Always run: in-memory, EF Core over SQLite, VNext over the SQLite document store.
  • Opt in with a connection string: SQL Server, PostgreSQL, Oracle. Each test reports as skipped, with the reason, when the variable is unset — not as passed.
  • Not coverable: MySQL. Pomelo.EntityFrameworkCore.MySql 9.0.0 caps Microsoft.EntityFrameworkCore.Relational at 9.0.x while this repository targets 10.0.9, so Elsa.UserTasks.Persistence.EFCore.MySql cannot be referenced from a test project at all (NU1107).
ELSA_USERTASKS_TEST_POSTGRES="Host=localhost;Database=elsa_conformance;Username=elsa;Password=elsa" dotnet test test/unit/Elsa.UserTasks.Persistence.ConformanceTests

The remaining variables are ELSA_USERTASKS_TEST_SQLSERVER and ELSA_USERTASKS_TEST_ORACLE.

Point them at a disposable database. The suite migrates the schema and isolates each test with its own tenant, but it never drops the database — that is deliberate, so it can never delete something an operator cared about.

ConformanceCoverageTests always runs. It fails if a provider that must run is unreachable, fails if a variable is set but empty (configured on the CI job, gating nothing), and writes the full matrix to the test output and to user-task-conformance-coverage.md in the output directory.

Adding a provider

  1. Add a ConformanceProvider entry to ConformanceProviders.All.
  2. Add a fixture under Providers/.
  3. Add a collection and one concrete class per contract in ProviderConformanceSuites.cs, each carrying [ConformanceProvider(...)].

A conformance class without [ConformanceProvider] is skipped with a wiring error rather than counted as coverage — the suite refuses to guess which provider a class exercised.