Skip to content

Harden Ping_TimedOut_* tests #116500

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 11, 2025
Merged

Conversation

antonfirsov
Copy link
Member

Fixes #115358.

Depending on the network configuration, we can get an ICMP with Type=Destination Unreachable, Code=Network Unreachable from middlewares when pinging an "unreachable" IP. In #115358 we see this happening on Helix Mac machines, but I was able to reproduce it on an office LAN-connected Windows PC too.

This PR attempts to fix address this problem by repeating the ping tests on other "types" of unreachable hosts until we actually catch a timeout. (We could instead just skip the test on the first DestinationNetworkUnreachable, but then we would loose some functional coverage.)

Marking as draft until we get a few successful outerloop runs.

@antonfirsov antonfirsov added this to the 10.0.0 milestone Jun 10, 2025
@Copilot Copilot AI review requested due to automatic review settings June 10, 2025 20:31
@antonfirsov antonfirsov marked this pull request as draft June 10, 2025 20:31
Copy link
Contributor

@Copilot 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 aims to improve the reliability of ping timeout tests by using multiple unreachable addresses so that intermittent network conditions (such as receiving a DestinationNetworkUnreachable response) don’t falsely mark the tests as failures.

  • Introduces two additional unreachable IP addresses in TestSettings.
  • Refactors the ping tests into a reusable core method that retries the ping if an unexpected ICMP response is received.
  • Updates both synchronous and asynchronous test variants to leverage the new core method.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/libraries/System.Net.Ping/tests/FunctionalTests/TestSettings.cs Added new unreachable addresses to cover varied ICMP responses.
src/libraries/System.Net.Ping/tests/FunctionalTests/PingTest.cs Refactored tests into a common core method and updated test methods accordingly.

Copy link
Contributor

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

@antonfirsov
Copy link
Member Author

/azp run runtime-libraries-coreclr outerloop

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@antonfirsov antonfirsov requested a review from wfurt June 10, 2025 20:32
@antonfirsov
Copy link
Member Author

/azp run runtime-libraries-coreclr outerloop

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@wfurt wfurt left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks @antonfirsov

@antonfirsov
Copy link
Member Author

/azp run runtime-libraries-coreclr outerloop

@antonfirsov antonfirsov marked this pull request as ready for review June 11, 2025 11:57
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@antonfirsov
Copy link
Member Author

/ba-g CI failures are unrelated

@antonfirsov
Copy link
Member Author

The tests passed in 3 consecutive outerloop runs, merging.

@antonfirsov
Copy link
Member Author

/backport to release/9.0-staging

@antonfirsov
Copy link
Member Author

/backport to release/8.0-staging

Copy link
Contributor

Started backporting to release/9.0-staging: https://github.com/dotnet/runtime/actions/runs/15637351117

Copy link
Contributor

Started backporting to release/8.0-staging: https://github.com/dotnet/runtime/actions/runs/15637353573

antonfirsov added a commit that referenced this pull request Jun 16, 2025
Fixes #113831.

Separate `SendPingAsync(hostname)` and `SendPingAsync(IPAddress)` test implementations:
- `SendPingAsync(hostname)`: we didn't see issues with this variant in the CI. It effectively tests if the resolution of `www.microsoft.com` is cancelled as part of the `SendPingAsync` call. Keep the existing logic in a separate method.
- `SendPingAsync(IPAddress)`: occasionally, pinging the valid IP likely resulted in replies before the cancellation could kick in on Helix Mac machines. Instead, let's ping an unreachable IP to avoid this. Since that can also sometimes result to an ICMP reply instead of a timeout, use the same trick as in #116500, repeating the test with other hosts if it happens.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ping_TimedOut_TAP|Sync_Success fails on MacOS
2 participants