Skip to content

[Shared] Fix flaky tests and avoid deadlock#4158

Merged
martincostello merged 3 commits intoopen-telemetry:mainfrom
martincostello:fix-flaky-test
Apr 20, 2026
Merged

[Shared] Fix flaky tests and avoid deadlock#4158
martincostello merged 3 commits intoopen-telemetry:mainfrom
martincostello:fix-flaky-test

Conversation

@martincostello
Copy link
Copy Markdown
Member

Changes

Merge requirement checklist

  • CONTRIBUTING guidelines followed (license requirements, nullable enabled, static analysis, etc.)
  • Unit tests added/updated
  • Appropriate CHANGELOG.md files updated for non-trivial changes
  • Changes in public API reviewed (if applicable)

- Attempt to fix flaky test shutdown.
- Avoid deadlock when used with `HttpClient.Send()`.
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.53%. Comparing base (54dff63) to head (4136224).
⚠️ Report is 3 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4158      +/-   ##
==========================================
- Coverage   73.62%   73.53%   -0.10%     
==========================================
  Files         466      466              
  Lines       18299    18299              
==========================================
- Hits        13473    13456      -17     
- Misses       4826     4843      +17     
Flag Coverage Δ
unittests-Contrib.Shared.Tests 89.47% <ø> (ø)
unittests-Exporter.Geneva 54.70% <ø> (-0.39%) ⬇️
unittests-Exporter.InfluxDB 95.81% <ø> (ø)
unittests-Exporter.Instana 74.86% <ø> (ø)
unittests-Exporter.OneCollector 94.61% <ø> (ø)
unittests-Extensions 90.78% <ø> (ø)
unittests-Extensions.Enrichment 100.00% <ø> (ø)
unittests-Extensions.Enrichment.AspNetCore 86.27% <ø> (ø)
unittests-Extensions.Enrichment.Http 94.33% <ø> (ø)
unittests-Instrumentation.AWS 83.33% <ø> (-0.21%) ⬇️
unittests-Instrumentation.AspNet 76.61% <ø> (ø)
unittests-Instrumentation.AspNetCore 70.44% <ø> (ø)
unittests-Instrumentation.Cassandra 23.52% <ø> (ø)
unittests-Instrumentation.ConfluentKafka 47.37% <ø> (ø)
unittests-Instrumentation.ElasticsearchClient 80.60% <ø> (ø)
unittests-Instrumentation.EntityFrameworkCore 80.80% <ø> (ø)
unittests-Instrumentation.EventCounters 77.27% <ø> (ø)
unittests-Instrumentation.GrpcCore 91.27% <ø> (ø)
unittests-Instrumentation.GrpcNetClient 73.78% <ø> (ø)
unittests-Instrumentation.Hangfire 86.05% <ø> (ø)
unittests-Instrumentation.Http 74.62% <ø> (ø)
unittests-Instrumentation.Owin 88.62% <ø> (ø)
unittests-Instrumentation.Process 100.00% <ø> (ø)
unittests-Instrumentation.Quartz 78.76% <ø> (ø)
unittests-Instrumentation.Remoting 64.28% <ø> (ø)
unittests-Instrumentation.Runtime 100.00% <ø> (ø)
unittests-Instrumentation.ServiceFabricRemoting 34.68% <ø> (ø)
unittests-Instrumentation.SqlClient 85.21% <ø> (ø)
unittests-Instrumentation.StackExchangeRedis 93.81% <ø> (ø)
unittests-Instrumentation.Wcf 79.68% <ø> (ø)
unittests-OpAmp.Client 83.14% <ø> (+0.55%) ⬆️
unittests-PersistentStorage 68.19% <ø> (ø)
unittests-Resources.AWS 73.88% <ø> (ø)
unittests-Resources.Azure 88.31% <ø> (ø)
unittests-Resources.Container 67.34% <ø> (ø)
unittests-Resources.Gcp 71.42% <ø> (ø)
unittests-Resources.Host 72.26% <ø> (ø)
unittests-Resources.OperatingSystem 76.98% <ø> (ø)
unittests-Resources.Process 100.00% <ø> (ø)
unittests-Resources.ProcessRuntime 79.59% <ø> (ø)
unittests-Sampler.AWS 94.27% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.
see 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@martincostello martincostello marked this pull request as ready for review April 20, 2026 09:49
@martincostello martincostello requested a review from a team as a code owner April 20, 2026 09:49
Copilot AI review requested due to automatic review settings April 20, 2026 09:49
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the shared TestHttpServer test utility to improve shutdown reliability (reduce flakiness) and to mitigate deadlock scenarios when used with synchronous HttpClient.Send().

Changes:

  • Introduces cancellation-based shutdown signaling for the listener loop.
  • Ensures responses are closed after each handled request to stabilize test teardown.
  • Reworks listener task startup to use Task.Factory.StartNew(..., LongRunning, ...) instead of Task.Run.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/Shared/TestHttpServer.cs Outdated
Comment thread test/Shared/TestHttpServer.cs Outdated
martincostello and others added 2 commits April 20, 2026 10:57
Apply code review suggestion.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Apply Copilot suggestions to fix.
@martincostello martincostello added this pull request to the merge queue Apr 20, 2026
Merged via the queue into open-telemetry:main with commit 9ad8820 Apr 20, 2026
322 checks passed
@martincostello martincostello deleted the fix-flaky-test branch April 20, 2026 11:28
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.

3 participants