Repository navigation
test: add model-based storage conformance to the persistence test kit - #10513
Conversation
There was a problem hiding this comment.
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
ModelBasedtest category. - Adds the
Microsoft.Accordanttest 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 withRecordExists=false. To keep the harness aligned withIGrainState.RecordExistssemantics, propagate the storedRecordExistsvalue instead of dictionary membership.
RecordExists = records.ContainsKey(request.Key)
- Files reviewed: 6/6 changed files
- Comments generated: 2
- Review effort level: Lite
|
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 |
There was a problem hiding this comment.
Review details
Suppressed comments (1)
Directory.Packages.props:180
- This conditional
ItemGroupis redundant because the samePackageVersion Updateentries forSystem.Collections.Immutable,System.IO.Pipelines, andSystem.Text.Jsonare 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
There was a problem hiding this comment.
Review details
Suppressed comments (1)
test/Orleans.Runtime.Internal.Tests/StorageTests/ModelBased/GrainStorageModelBasedConformance.cs:541
GetExceptionTypeonly unwraps single-innerAggregateException. The PR description mentions supporting wrapped provider exceptions, but wrappers such asOrleansException(with an inner exception) will currently cause the harness to report the wrong exception type and failValidateInconsistentStateResulteven when the underlying exception isInconsistentStateException. Consider unwrapping a singleOrleansException.InnerException(while not unwrappingInconsistentStateExceptionitself).
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
a77cb92 to
a55bebb
Compare
a55bebb to
e0bbd93
Compare
There was a problem hiding this comment.
Review details
Suppressed comments (1)
src/Orleans.Persistence.TestKit/GrainStorageModelBasedTestRunner.cs:252
IncludeInconsistentETagCasesis documented as controlling generation of duplicate-write/stale-ETag scenarios, butCanApplycurrently allowsETagMode.Nulloperations 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 whenIncludeInconsistentETagCasesisfalse.
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
There was a problem hiding this comment.
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(seesrc/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
e0bbd93 to
7a005a4
Compare
There was a problem hiding this comment.
Review details
Suppressed comments (1)
test/Orleans.Persistence.TestKit.Tests/MemoryGrainStorageTests.cs:31
CreateStorageWithLatencysetsLatency = 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
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]>
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
7a005a4 to
9b634b4
Compare
There was a problem hiding this comment.
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 viaOrleans.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
Problem
The Orleans Persistence TestKit validates individual
IGrainStoragescenarios, 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
Orleans.Persistence.TestKit.RecordExists=falsewithout discarding caller ETags.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.