Dapr.Testcontainers: probe gRPC port with HTTP/2 preface to eliminate transient Unavailable on first RPC - #1821
Merged
Conversation
…oid gRPC race Agent-Logs-Url: https://github.com/dapr/dotnet-sdk/sessions/8beecfaa-641c-482e-b48a-3d2c94223114 Co-authored-by: WhitWaldo <2238529+WhitWaldo@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dapr/dotnet-sdk/sessions/2e9b5dd1-ff11-474e-8d77-221496dbcedf Co-authored-by: WhitWaldo <2238529+WhitWaldo@users.noreply.github.com>
…ttent flake Agent-Logs-Url: https://github.com/dapr/dotnet-sdk/sessions/21318e37-45ab-4556-aefc-eceea6479054 Co-authored-by: WhitWaldo <2238529+WhitWaldo@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dapr/dotnet-sdk/sessions/d28335b6-74ba-4cd8-971a-81ee9391ff97 Co-authored-by: WhitWaldo <2238529+WhitWaldo@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
WhitWaldo
May 18, 2026 22:02
View session
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1821 +/- ##
==========================================
+ Coverage 64.90% 65.01% +0.10%
==========================================
Files 300 300
Lines 8833 8874 +41
Branches 1040 1043 +3
==========================================
+ Hits 5733 5769 +36
- Misses 2846 2849 +3
- Partials 254 256 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
WhitWaldo
marked this pull request as ready for review
May 18, 2026 22:34
This was referenced Jun 11, 2026
This was referenced Jun 30, 2026
This was referenced Jul 13, 2026
This was referenced Jul 20, 2026
This was referenced Jul 27, 2026
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
Integration tests intermittently fail on the first RPC with:
Root cause:
DaprdContainer.StartAsynconly validates the gRPC port at the TCP layer. A successful TCP connect proves Docker's port forwarding accepts SYNs — it does not prove the upstream HTTP/2 (gRPC) server is actively serving. On slow CI hosts there is a brief window between Docker publishing the port and daprd's gRPCServe()loop being wired up; the test's first RPC lands in that window and getsUnavailable. The HTTP reachability probe already in place only covers the HTTP server on a different port.For reference, daprd's startup log order (
dapr/dapr/pkg/runtime/runtime.goL790/L802/L813) isAPI gRPC→HTTP→Internal gRPC, so the existing"Internal gRPC server is running"wait is in fact the last of the three and is not the source of the flake. An earlier commit on this branch that changed that wait message is reverted here.Changes:
ContainerReadinessProbe.WaitForGrpcServerReadyAsync(host, port, timeout, ct)— new probe that performs the HTTP/2 connection handshake itself: opens TCP, sends the 24-byte client preface (RFC 7540 §3.5:PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n), and waits for any bytes back from the server'sSETTINGSframe. Per-attempt bound of 2 s, 200 ms inter-attempt backoff, retriesSocketException/IOException/attempt-timeout until the overall timeout. Dependency-free; works against any HTTP/2 (gRPC) server.DaprdContainer.StartAsync— invokes the new probe against127.0.0.1:GrpcPortas the final readiness gate, alongside the existing HTTP reachability probe for the HTTP port.ContainerReadinessProbeTests— 4 tests: HTTP/2 server preface → returns; accepts-but-never-responds (simulates the CI race) →TimeoutException; port refused → retries then times out; pre-cancelled token →OperationCanceledException.DaprdContainer.cs; the log line is back to"Internal gRPC server is running".Out of scope:
test/Dapr.E2E.Test/DaprTestApp.cs(uses thedapr runCLI, different startup mechanism).PortUtilities.GetAvailablePortreleases the socket before returning the number — TOCTOU race used in app-first mode, already wrapped inDaprTestApplicationBuilder's retry loop.Issue reference
Checklist