Skip to content

test(journaling): cover legacy recovery contracts - #10959

Merged
ReubenBond merged 4 commits into
dotnet:mainfrom
ReubenBond:rb-issue-10863-test-state-coverage
Sep 2, 2026
Merged

test(journaling): cover legacy recovery contracts#10959
ReubenBond merged 4 commits into
dotnet:mainfrom
ReubenBond:rb-issue-10863-test-state-coverage

Conversation

@ReubenBond

@ReubenBond ReubenBond commented Sep 2, 2026

Copy link
Copy Markdown
Member

Part of #10863.

Adds deterministic contracts for legacy binary journal replay and state-manager recovery sequencing. The tests verify physical command order, malformed and unsupported record behavior, unchanged input/state after failures, append/delete fencing, post-delete snapshot recovery, and retry behavior after snapshot and recovery failures.

The canonical Orleans.Journaling.Tests coverage moved from 3,522/4,311 lines (81.67%) to 3,531/4,311 (81.88%) and from 662/930 branches (71.18%) to 665/930 (71.51%). OrleansBinaryV0JournalReader.ReadEntryHeader now reaches 31/31 lines and 6/6 branches (100%/100%), reducing its CRAP score from 6.88 to 6.00.

Microsoft Reviewers: Open in CodeFlow

Copilot AI lite review requested due to automatic review settings September 2, 2026 05:48

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.

Copilot review overview

🟡 Changes recommended

A newly introduced helper writes an incorrect legacy record length for stream ids requiring multi-byte varint encoding, which can produce malformed test data if reused beyond the current call site.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review tier: Lite
Findings: 1 Medium severity

New issues introduced by this change (1)
Severity Finding
Medium severity test/​Orleans.Journaling.Tests/​StateManagerTests.csCreateUnsupportedLegacyCommandVersionRecord hard-codes the legacy body length to 2, but the body…
What changed in this PR

Adds new deterministic tests for Orleans journaling legacy-binary replay and state-manager recovery/work-loop sequencing, supporting the broader coverage push in #10863 by asserting specific ordering, failure, and retry contracts.

Changes:

  • Expanded StateManagerTests with new contracts around snapshot/replace retry behavior, append/delete fencing, post-delete recovery, and unsupported legacy record retry-after-repair.
  • Added binary journal format replay tests to validate legacy (V0) framing parsing, mixed V0/V1 physical order, and “do not consume input on failure” behavior for malformed/unsupported records.
File Description
test/​Orleans.Journaling.Tests/​StateManagerTests.cs Adds additional state-manager recovery/work-loop sequencing tests and enhances in-test storage fakes for deterministic verification.
test/​Orleans.Journaling.Tests/​OrleansBinaryJournalBufferWriterTests.cs Adds new replay tests covering concatenated legacy records, mixed legacy/current records, and malformed/unsupported legacy record handling.

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

Comment thread test/Orleans.Journaling.Tests/StateManagerTests.cs Outdated
Copilot AI review requested due to automatic review settings September 2, 2026 06:34
@ReubenBond

Copy link
Copy Markdown
Member Author

@copilot review

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.

Copilot review overview

🔵 Needs a closer look

A couple of test/helper updates introduce avoidable overhead and a potential assertion gap that could let a fencing regression slip through undetected.

Review tier: Lite
Findings: None

Issues resolved since last review (1)
Severity Finding
Medium severity test/​Orleans.Journaling.Tests/​StateManagerTests.csCreateUnsupportedLegacyCommandVersionRecord hard-codes the legacy body length to 2, but the body… View resolved comment
Suppressed comments (2)

Previously missed (2) — in code that hasn't changed since the last review.

test/Orleans.Journaling.Tests/StateManagerTests.cs:1460

  • This test only checks deleteEntered.IsCompleted immediately after queuing the delete. If DeleteStateAsync were able to enter storage slightly later (while the append is still blocked), the final assertions could still pass and the fencing regression would be missed. Consider yielding a small scheduling window and re-checking that DeleteEntered is still not completed before releasing the append.
    test/Orleans.Journaling.Tests/StateManagerTests.cs:2121
  • CapturingStorage.ReplaceAsync now materializes value.ToArray() unconditionally (via attemptedBytes), adding an extra allocation on every successful replace. Since FailedReplaceAttempts is only used when throwing, defer ToArray() into the failure branch so the success path only materializes once (as it did before).

Copilot AI review requested due to automatic review settings September 2, 2026 07:35
@ReubenBond

Copy link
Copy Markdown
Member Author

@copilot review

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.

Copilot review overview

🟢 Approval recommended

The changes are test-focused, align with the stated coverage goals, and no functional/runtime code paths are modified (only a minor optional test-double thread-safety improvement was noted).

Review tier: Lite
Findings: 1 Medium severity

New issues introduced by this change (1)
Severity Finding
Medium severity test/​Orleans.Journaling.Tests/​StateManagerTests.csOperationLog/Appends/Replaces/FailedReplaceAttempts and _segments are all List<T> and…

Comment thread test/Orleans.Journaling.Tests/StateManagerTests.cs
Copilot AI review requested due to automatic review settings September 2, 2026 08:33
@ReubenBond

Copy link
Copy Markdown
Member Author

@copilot review

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.

Copilot review overview

🟢 Approval recommended

Changes are isolated to tests and test doubles, with deterministic assertions and verified legacy framing assumptions aligning with the repository’s varint encoding implementation.

Review tier: Lite
Findings: None

Issues resolved since last review (1)
Severity Finding
Medium severity test/​Orleans.Journaling.Tests/​StateManagerTests.csOperationLog/Appends/Replaces/FailedReplaceAttempts and _segments are all List<T> and… View resolved comment

@ReubenBond
ReubenBond merged commit 835b432 into dotnet:main Sep 2, 2026
74 checks passed
@ReubenBond
ReubenBond deleted the rb-issue-10863-test-state-coverage branch September 2, 2026 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants