fix: treat unexpected cookie values as transient network failures in cookie handler tests#25419
Conversation
…lerCookiesImpl The guard condition in TestNSUrlSessionHandlerCookiesImpl only checked whether Set-Cookie headers were present, not whether they contained the expected cookie value. When httpbin.org transiently returns unexpected cookies, managedCookieResult is true but the value assertion fails. Pre-compute the expected-cookie-value booleans and include them in the IgnoreInCI check so transient server responses are skipped in CI. Ref: #25412 Agent-Logs-Url: https://github.com/dotnet/macios/sessions/ec1eca8a-e6a8-476d-a6c9-afad95e1fec0 Co-authored-by: rolfbjarne <249268+rolfbjarne@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR reduces CI flakiness in the NSUrlSessionHandler cookie tests by treating “unexpected Set-Cookie values” as transient network failures (in addition to the existing guard that only checked header presence). This aligns with observed CI failures where Set-Cookie headers exist but don’t contain the expected cookie value.
Changes:
- Precompute
managedHasExpectedCookie/nativeHasExpectedCookiebased onSet-Cookieheader contents. - Extend the existing
IgnoreInCIguard to also ignore when the expected cookie value isn’t present. - Reuse the computed booleans in the subsequent assertions to keep behavior consistent.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ [PR Build #f2f881e] Build passed (Detect API changes) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
✅ [PR Build #f2f881e] Build passed (Build packages) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
✅ API diff for current PR / commitNET (empty diffs)✅ API diff vs stableNET (empty diffs)ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
✅ [PR Build #f2f881e] Build passed (Build macOS tests) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
🚀 [CI Build #f2f881e] Test results 🚀Test results✅ All tests passed on VSTS: test results. 🎉 All 175 tests passed 🎉 Tests counts✅ cecil: All 1 tests passed. Html Report (VSDrops) Download macOS tests✅ Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download Linux Build VerificationPipeline on Agent |
TestNSUrlSessionHandlerCookiesandTestNSUrlSessionEphemeralHandlerCookieswere flaky across unrelated PRs because the CI-ignore guard only checked whetherSet-Cookieheaders were present, not whether they contained the expected value. Whenhttpbin.orgtransiently returns a different cookie (e.g. from a CDN/load balancer),managedCookieResultistruebut the value assertion fails — escaping the guard entirely.Changes
tests/monotouch-test/System.Net.Http/MessageHandlers.cs— InTestNSUrlSessionHandlerCookiesImpl, pre-computemanagedHasExpectedCookie/nativeHasExpectedCookieafter the async block and fold them into theIgnoreInCIcondition alongside the existing presence checks:The downstream assertions reuse the pre-computed booleans, keeping local runs semantically identical.