Repository navigation
test(cryptography): wait for CompleteAsync in the empty-stream tests - #1925
Draft
nelson-parente wants to merge 1 commit into
Draft
nelson-parente wants to merge 1 commit into
nelson-parente wants to merge 1 commit into
Conversation
ProcessStreamAsync writes requests and reads responses on two separate tasks. With a mocked response stream that ends at once, the reader can complete the output channel before the writer calls CompleteAsync, so Verify(CompleteAsync, Times.Once) can run too early. Wait for the request stream to complete before the verification, as the other tests in these files already do. Signed-off-by: Nelson Parente <nelson_parente@live.com.pt> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017JhKUDV9dbs5JDz2uwZqz5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
EncryptionStreamProcessorTests.ProcessStreamAsync_WithEmptyStream_SendsNoRequestscan fail with this error:The same error message lists
CompleteAsync()under "Performed invocations", so the call happened, but after the verification. Master run 36749821550 on 2026-09-30 failed this way inUnit Tests .NET 8.0 / test/Dapr.Cryptography.Test. Since 2026-09-25 it is the only failure of the Cryptography unit jobs in the 20sdk_buildruns (64 jobs), so it is rare.ProcessStreamAsyncwrites the requests and reads the responses on two separate tasks. The writer callsCompleteAsyncin itsfinallyblock. In the test, the mocked response stream ends at once. So the reader can complete the output channel before the writer reachesCompleteAsync, andawait foreachoverGetProcessedDataAsyncthen returns before the call. With a real gRPC call this order cannot occur, because the server ends its response stream only after the client completes the request stream.The tests
ProcessStreamAsync_SendsOptionsOnlyInFirstRequestandProcessStreamAsync_AssignsSequenceNumbersInOrderin the same files already handle this. They set aTaskCompletionSourcein theCompleteAsynccallback and wait for it before they assert. This PR applies the same pattern toProcessStreamAsync_WithEmptyStream_SendsNoRequestsinEncryptionStreamProcessorTestsandDecryptionStreamProcessorTests, which have the same race. The change is in the tests only.Issue reference
No issue.
Checklist
Local checks (.NET SDK 10.0.401, macOS arm64)
MockExceptionas CI. With the wait from this PR, it passed in 3 of 3 runs.Dapr.Cryptography.Testruns (81 tests) passed on net10.0.🤖 Generated with Claude Code
https://claude.ai/code/session_017JhKUDV9dbs5JDz2uwZqz5