test(streaming): cover subscription lifecycle - #10957
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The new lifecycle test file contains non-compiling mixed named/positional argument calls, and there is also a per-item allocation in a hot-path duplicate-delivery check which should be addressed.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review tier: Lite
Findings: 1
New issues introduced by this change (3)
| Severity | Finding |
|---|---|
test/Orleans.Streaming.Tests/StreamingTests/StreamConsumerLifecycleTests.cs — This SetObserver call mixes named and positional arguments (batchObserver: null followed by… |
|
src/Orleans.Streaming/Internal/StreamSubscriptionHandleImpl.cs — This duplicate-delivery check allocates a new DeliveryToken for every delivered item… |
|
test/Orleans.Streaming.Tests/StreamingTests/StreamSubscriptionHandleImplTests.cs — throw error; resets the exception stack trace, making failures harder to diagnose. If the intent… |
What changed in this PR
This PR strengthens Orleans streaming subscription lifecycle coverage with deterministic in-memory tests, while also adjusting runtime behavior around handshake/duplicate-delivery handling and invalid-handle validation.
Changes:
- Expand
StreamSubscriptionHandleImpltest coverage for ordered delivery handshakes, retries, diagnostics emission, completion/error callbacks, resume/unsubscribe, and invalid-handle behavior. - Add new lifecycle-focused tests for
StreamConsumer/StreamConsumerExtensionregistration, resume, and unsubscribe flows (including failure/retry paths). - Fix handshake comparison logic in
StreamSubscriptionHandleImpl.DeliverItemand adjustStreamConsumer.CheckHandleValidityto reject invalid concrete handles before accessing cleared identity.
| File | Description |
|---|---|
| test/Orleans.Streaming.Tests/StreamingTests/StreamSubscriptionHandleImplTests.cs | Adds extensive deterministic tests for delivery/handshake semantics, retries, diagnostics, and invalidation behavior. |
| test/Orleans.Streaming.Tests/StreamingTests/StreamConsumerLifecycleTests.cs | New tests covering consumer resume/unsubscribe lifecycle behavior and failure/retry invariants. |
| src/Orleans.Streaming/Internal/StreamSubscriptionHandleImpl.cs | Updates duplicate-delivery detection to compare against a delivery-handshake token. |
| src/Orleans.Streaming/Internal/StreamConsumer.cs | Validates invalidated concrete handles before accessing stream identity to preserve the intended ArgumentException contract. |
Suppressed comments (1)
test/Orleans.Streaming.Tests/StreamingTests/StreamConsumerLifecycleTests.cs:352
- This
SetObservercall uses a named argument (observer: null) followed by positional arguments, which will not compile. Pass arguments positionally (or name them all) so the batch observer is supplied correctly.
Stream,
observer: null,
observer,
token,
filterData);
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
@copilot review |
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The production changes are small and targeted, and the new deterministic tests comprehensively validate the intended lifecycle and handshake behaviors.
Review tier: Lite
Findings: None
Issues resolved since last review (3)
| Severity | Finding |
|---|---|
test/Orleans.Streaming.Tests/StreamingTests/StreamSubscriptionHandleImplTests.cs — throw error; resets the exception stack trace, making failures harder to diagnose. If the intent… View resolved comment |
|
src/Orleans.Streaming/Internal/StreamSubscriptionHandleImpl.cs — This duplicate-delivery check allocates a new DeliveryToken for every delivered item… View resolved comment |
|
test/Orleans.Streaming.Tests/StreamingTests/StreamConsumerLifecycleTests.cs — This SetObserver call mixes named and positional arguments (batchObserver: null followed by… View resolved comment |



Problem
The stream subscription lifecycle had a CRAP 420 delivery hotspot and limited direct coverage of ordered delivery, retries, terminal callbacks, resume, unsubscribe, and invalid-handle behavior.
Solution
ArgumentExceptioncontract.Rationale
The tests exercise lifecycle guarantees directly without external providers or timing dependencies. The selected
StreamSubscriptionHandleImpltarget now exceeds 90% line and branch coverage and the CRAP 420 hotspot is eliminated.Contributes to #10862.
Microsoft Reviewers: Open in CodeFlow