Skip to content

test: add model-based storage conformance to the persistence test kit - #10513

Merged
ReubenBond merged 7 commits into
dotnet:mainfrom
ReubenBond:model-based-storage-tests
Aug 14, 2026
Merged

ReubenBond merged 7 commits into
dotnet:mainfrom
ReubenBond:model-based-storage-tests

Conversation

@ReubenBond

@ReubenBond ReubenBond commented Aug 11, 2026 •

Copy link
Copy Markdown
Member

Problem

The Orleans Persistence TestKit validates individual IGrainStorage scenarios, but fixed examples can miss failures which only appear across sequences of reads, writes, clears, and optimistic-concurrency conflicts. Orleans-owned providers need one behavioral specification rather than provider-specific switches which permit divergent observable behavior.

Solution

  • Add a public model-based conformance runner to Orleans.Persistence.TestKit.
  • Generate bounded operation sequences covering state transitions, record isolation, and null, current, and stale ETags.
  • Always exercise duplicate writes and stale-ETag writes and clears; there are no behavioral opt-outs.
  • Discover whether a provider physically deletes or retains cleared records using an isolated key, while enforcing the same observable state and concurrency contract for both representations.
  • Fix ADO.NET tombstone reads and stale-clear handling so cleared rows report RecordExists=false without discarding caller ETags.
  • Fix DynamoDB tombstone and delete clear paths to condition operations on the caller's ETag.
  • Exercise the runner against memory, memory-with-latency, Azure Blob and Table storage, Redis, Cosmos DB, DynamoDB, Firestore, SQLite, MySQL, PostgreSQL, and SQL Server.

Rationale

Keeping the behavioral model in the Persistence TestKit gives Orleans providers and third-party implementations one shared conformance surface. Generated transition coverage complements the TestKit's direct scenario tests and turns provider differences into actionable failures instead of configuration knobs.

Copilot AI lite review requested due to automatic review settings August 11, 2026 21:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a reusable, model-based conformance harness for IGrainStorage implementations and integrates it into several existing provider test suites to validate ETag and clear-state semantics.

Changes:

  • Introduces a new Accordant-based generator/executor which produces read/write/clear sequences and validates outcomes (including ETag evolution and inconsistent/stale ETag failures).
  • Wires the harness into Memory, Redis, and Azure Blob storage tests under a new ModelBased test category.
  • Adds the Microsoft.Accordant test dependency and centrally versions it.
Show a summary per file
File Description
test/Orleans.Runtime.Internal.Tests/StorageTests/ModelBased/GrainStorageModelBasedConformance.cs Adds the model-based IGrainStorage conformance spec, runner, and execution adapter.
test/Orleans.Runtime.Internal.Tests/Orleans.Runtime.Internal.Tests.csproj Adds Microsoft.Accordant package reference for the internal runtime test project.
test/Orleans.Runtime.Internal.Tests/MemoryGrainStorageTests.cs Adds a model-based conformance test which runs against the keyed Memory storage provider.
test/Extensions/Orleans.Redis.Tests/Persistence/RedisStorageTests.cs Adds a model-based conformance test for Redis storage with provider-specific clear semantics.
test/Extensions/Orleans.Azure.Tests/Persistence/AzureBlobGrainStorageTests.cs Adds a model-based conformance test for Azure Blob grain storage and routes xUnit output into the harness.
Directory.Packages.props Adds central version for Microsoft.Accordant (and introduces a redundant conditional pin block).

Review details

Tip

Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Suppressed comments (1)

test/Orleans.Runtime.Internal.Tests/StorageTests/ModelBased/GrainStorageModelBasedConformance.cs:382

  • RecordExists = records.ContainsKey(...) will report true even when the last observed state for that key was a cleared/tombstoned record with RecordExists=false. To keep the harness aligned with IGrainState.RecordExists semantics, propagate the stored RecordExists value instead of dictionary membership.
                RecordExists = records.ContainsKey(request.Key)
  • Files reviewed: 6/6 changed files
  • Comments generated: 2
  • Review effort level: Lite

Comment thread Directory.Packages.props Resolved
Copilot AI review requested due to automatic review settings August 11, 2026 22:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review details

  • Files reviewed: 6/6 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review details

  • Files reviewed: 16/16 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings August 12, 2026 04:35
@ReubenBond

Copy link
Copy Markdown
Member Author

The repeatable Google Cloud failures were PR-specific: Firestore preserves its update-time ETag for idempotent writes/clears, while the new model required every successful operation to rotate the ETag. That also caused the stale-ETag path to reuse the current token.

Fixed in 25bb5929c by making stable ETags for no-op operations an explicit provider capability and retaining the last genuinely superseded ETag. The two Firestore model-conformance tests now pass against the Firestore emulator on both net8.0 and net10.0.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review details

Suppressed comments (1)

Directory.Packages.props:180

  • This conditional ItemGroup is redundant because the same PackageVersion Update entries for System.Collections.Immutable, System.IO.Pipelines, and System.Text.Json are already specified unconditionally immediately above. Keeping both increases the chance of drift without changing restore behavior.
  <ItemGroup Condition=" '$(MSBuildProjectName)' == 'Orleans.Runtime.Internal.Tests' and '$(TargetFramework)' == 'net8.0' ">
    <PackageVersion Update="System.Collections.Immutable" Version="10.0.0" />
    <PackageVersion Update="System.IO.Pipelines" Version="10.0.5" />
    <PackageVersion Update="System.Text.Json" Version="10.0.5" />
  </ItemGroup>
  • Files reviewed: 16/16 changed files
  • Comments generated: 1
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings August 12, 2026 14:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review details

Suppressed comments (1)

test/Orleans.Runtime.Internal.Tests/StorageTests/ModelBased/GrainStorageModelBasedConformance.cs:541

  • GetExceptionType only unwraps single-inner AggregateException. The PR description mentions supporting wrapped provider exceptions, but wrappers such as OrleansException (with an inner exception) will currently cause the harness to report the wrong exception type and fail ValidateInconsistentStateResult even when the underlying exception is InconsistentStateException. Consider unwrapping a single OrleansException.InnerException (while not unwrapping InconsistentStateException itself).
    private static Type GetExceptionType(Exception exception)
    {
        return exception is AggregateException { InnerExceptions.Count: 1 } aggregateException
            ? aggregateException.InnerExceptions[0].GetType()
            : exception.GetType();
  • Files reviewed: 16/16 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings August 12, 2026 17:00
@ReubenBond
ReubenBond force-pushed the model-based-storage-tests branch from a77cb92 to a55bebb Compare August 12, 2026 17:00
@ReubenBond ReubenBond changed the title test: add model-based storage conformance test: add model-based storage conformance to the persistence test kit Aug 12, 2026
@ReubenBond
ReubenBond force-pushed the model-based-storage-tests branch from a55bebb to e0bbd93 Compare August 12, 2026 17:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review details

Suppressed comments (1)

src/Orleans.Persistence.TestKit/GrainStorageModelBasedTestRunner.cs:252

  • IncludeInconsistentETagCases is documented as controlling generation of duplicate-write/stale-ETag scenarios, but CanApply currently allows ETagMode.Null operations in all states (ETagMode.Null => true). That means the base "Write ... with null ETag" inputs can still be re-applied after a record exists, causing duplicate-write (null ETag) cases to be generated even when IncludeInconsistentETagCases is false.
            var hasRecord = state.Records.TryGetValue(request.Key, out var record);
            return request.ETagMode switch
            {
                ETagMode.Null => true,
                ETagMode.Current => hasRecord && record is not null && ChangesState(request, record),
                ETagMode.Stale => hasRecord && record is not null && !string.IsNullOrEmpty(record.PreviousETag),
                _ => false
  • Files reviewed: 25/25 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings August 12, 2026 17:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review details

Suppressed comments (1)

src/Orleans.Persistence.TestKit/GrainStorageModelBasedTestRunner.cs:75

  • Private fields in this new file use names without the established underscore prefix (e.g., storage, options, output). In this repo, private fields are consistently _camelCase (see src/Orleans.Persistence.TestKit/GrainStorageTestFixture.cs:19-21). Please rename these fields (and other private fields in this file) to match the convention (e.g., _storage, _options, _output) to keep style consistent and avoid analyzer/style drift.
    private readonly IGrainStorage storage;
    private readonly GrainStorageModelBasedConformanceOptions options;
    private readonly Action<string>? output;
  • Files reviewed: 25/25 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings August 12, 2026 18:17
@ReubenBond
ReubenBond force-pushed the model-based-storage-tests branch from e0bbd93 to 7a005a4 Compare August 12, 2026 18:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review details

Suppressed comments (1)

test/Orleans.Persistence.TestKit.Tests/MemoryGrainStorageTests.cs:31

  • CreateStorageWithLatency sets Latency = TimeSpan.Zero, which makes the “with latency” configuration depend on implementation details (the provider always adds an internal fudge delay) and may result in effectively no additional latency when the underlying call takes longer than that fudge window. Setting an explicit small non-zero latency makes the intent clearer and ensures the model-based tests actually exercise the latency wrapper.
        return new MemoryGrainStorageWithLatency(
            "MemoryStoreWithLatency",
            new MemoryStorageWithLatencyOptions { Latency = TimeSpan.Zero },
            services.GetRequiredService<ILoggerFactory>(),
            services.GetRequiredService<IGrainFactory>(),
  • Files reviewed: 27/27 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

ReubenBond and others added 7 commits August 12, 2026 11:56
Add a reusable model-based grain storage conformance harness and wire it into memory, Redis, and Azure Blob storage tests.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 3f6887af-bd23-4fdc-be05-c22b67a39fba
Forward the last observed RecordExists value when invoking provider operations and scope test-only package pins to net8.0.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 3f6887af-bd23-4fdc-be05-c22b67a39fba
Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 3f6887af-bd23-4fdc-be05-c22b67a39fba
Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 3f6887af-bd23-4fdc-be05-c22b67a39fba
Move the generated storage conformance runner into Orleans.Persistence.TestKit and reference it directly from provider tests.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 3f6887af-bd23-4fdc-be05-c22b67a39fba
Always exercise optimistic-concurrency cases in the persistence test kit, discover clear representation automatically, and fix ADO.NET and DynamoDB clear semantics.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 3f6887af-bd23-4fdc-be05-c22b67a39fba
@ReubenBond
ReubenBond force-pushed the model-based-storage-tests branch from 7a005a4 to 9b634b4 Compare August 12, 2026 19:02
Copilot AI review requested due to automatic review settings August 12, 2026 19:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review details

Suppressed comments (1)

test/Orleans.Persistence.TestKit.Tests/MemoryGrainStorageTests.cs:7

  • using Orleans.Serialization.Serializers; appears unused in this file (types used here are resolved via Orleans.Storage, Orleans.Runtime, and DI). With code-style enforcement/warnings-as-errors, this can break the build; please remove the unused using.
using Orleans.Hosting;
using Orleans.Persistence.TestKit;
using Orleans.Runtime;
using Orleans.Serialization.Serializers;
using Orleans.Storage;
  • Files reviewed: 27/27 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@ReubenBond
ReubenBond merged commit 4cd47f4 into dotnet:main Aug 14, 2026
135 of 137 checks passed
@ReubenBond
ReubenBond deleted the model-based-storage-tests branch August 14, 2026 21:01
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 14, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants