Skip to content

Harden CancelSendPingAsync tests #116588

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 4 commits into from
Jun 16, 2025

Conversation

antonfirsov
Copy link
Member

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 Harden Ping_TimedOut_* tests #116500, repeating the test with other hosts if it happens.

@antonfirsov antonfirsov requested review from Copilot and a team June 12, 2025 14:45
@github-actions github-actions bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Jun 12, 2025
@antonfirsov antonfirsov added area-System.Net and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Jun 12, 2025
@antonfirsov antonfirsov added this to the 10.0.0 milestone Jun 12, 2025
Copy link
Contributor

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

This comment was marked as outdated.

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 separates the existing CancelSendPingAsync test into two focused scenarios—hostname and IPAddress variants—and hardens the IPAddress test by pinging unreachable addresses with retry logic to reduce CI flakiness.

  • Split CancelSendPingAsync into CancelSendPingAsync_HostName and CancelSendPingAsync_IPAddress methods.
  • Updated the IPAddress test to iterate over multiple unreachable IPs and retry if the network immediately replies.
  • Removed combined host/IP logic and streamlined cancellation calls.
Comments suppressed due to low confidence (1)

src/libraries/System.Net.Ping/tests/FunctionalTests/PingTest.cs:715

  • [nitpick] The comment on the OuterLoop attribute refers to an "external host", but this test targets unreachable IPs. Updating the comment to reflect dependency on unreachable-address behavior would improve clarity.
[OuterLoop] // Depends on external host and assumption that successful ping takes long enough for cancellation to go through first

This comment was marked as outdated.

@antonfirsov
Copy link
Member Author

/azp run runtime-libraries-coreclr outerloop

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@antonfirsov
Copy link
Member Author

/azp run runtime-libraries-coreclr outerloop

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@rzikm rzikm left a comment

Choose a reason for hiding this comment

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

LGTM if CI passes, Thanks!

@antonfirsov
Copy link
Member Author

Outerloop failures are unrelated.

@antonfirsov antonfirsov merged commit 4e454ff into dotnet:main Jun 16, 2025
84 of 94 checks passed
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.

[Test Failure] System.Net.NetworkInformation.Tests.PingTest.CancelSendPingAsync on OSX
2 participants