Skip to content

Wait for the shutdown duration metric in the HTTP/2 abort test - #70624

Closed
joshbarros wants to merge 1 commit into
dotnet:mainfrom
joshbarros:fix/70583-kestrel-shutdown-metric-race
Closed

joshbarros wants to merge 1 commit into
dotnet:mainfrom
joshbarros:fix/70583-kestrel-shutdown-metric-race

Conversation

@joshbarros

Copy link
Copy Markdown
Contributor
  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • There's an open issue for the PR that you are making.

Description

Http2Connection_ServerShutdown_Abort read the MetricCollector snapshot immediately after server.DisposeAsync() completed. Metric-listener delivery can land just after shutdown, so the collection was occasionally empty and the test failed with Expected count: 1, Actual count: 0.

Wait for at least one measurement before asserting, matching the comparable HTTP/2 metrics tests in the same file (WaitForMeasurementsAsync(minCount: 1)).

Validation

  • dotnet test src/Servers/Kestrel/test/InMemory.FunctionalTests/InMemory.FunctionalTests.csproj --filter "FullyQualifiedName~KestrelMetricsTests": 21 passed, 0 failed.
  • The flake is timing-dependent, so the added wait is the fix rather than a locally reproduced red/green.

Fixes #70583

Http2Connection_ServerShutdown_Abort read the MetricCollector snapshot right after server shutdown. Metric-listener delivery can land just after shutdown completes, so the collection was empty and the test failed intermittently. Wait for at least one measurement, as the comparable HTTP/2 metrics tests already do.

Fixes dotnet#70583
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Nov 16, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Thanks for your PR, @joshbarros. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@BrennanConroy

Copy link
Copy Markdown
Member

Dupe of #70582

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

KestrelMetricsTests.Http2Connection_ServerShutdown_Abort intermittently misses shutdown metric

2 participants