[tests] Assert.Inconclusive() tests with http errors#10650
Merged
jonathanpeppers merged 4 commits intomainfrom Jan 6, 2026
Merged
[tests] Assert.Inconclusive() tests with http errors#10650jonathanpeppers merged 4 commits intomainfrom
Assert.Inconclusive() tests with http errors#10650jonathanpeppers merged 4 commits intomainfrom
Conversation
MSBuild tests using `DownloadedCache` can randomly fail with HTTP
errors such as:
System.Net.Http.HttpRequestException : Response status code does not indicate success: 504 (Gateway Time-out).
Stack trace
at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
at Xamarin.ProjectTools.DownloadedCache.GetAsFile(String url, String filename) in /Users/runner/work/1/s/android/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Common/DownloadedCache.cs:line 39
at Xamarin.ProjectTools.BuildItem.<>c__DisplayClass70_0.<set_WebContent>b__0() in /Users/runner/work/1/s/android/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Common/BuildItem.cs:line 309
at Xamarin.ProjectTools.XamarinProject.<>c.<Save>b__110_0(BuildItem s) in /Users/runner/work/1/s/android/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Common/XamarinProject.cs:line 455
at System.Collections.Generic.List`1.AddRange(IEnumerable`1 collection)
at Xamarin.ProjectTools.XamarinProject.Save(Boolean saveProject) in /Users/runner/work/1/s/android/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Common/XamarinProject.cs:line 455
at Xamarin.ProjectTools.ProjectBuilder.Save(XamarinProject project, Boolean doNotCleanupOnUpdate, Boolean saveProject) in /Users/runner/work/1/s/android/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Common/ProjectBuilder.cs:line 98
at Xamarin.ProjectTools.ProjectBuilder.Build(XamarinProject project, Boolean doNotCleanupOnUpdate, String[] parameters, Boolean saveProject, Dictionary`2 environmentVariables) in /Users/runner/work/1/s/android/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Common/ProjectBuilder.cs:line 128
at Xamarin.Android.Build.Tests.BindingBuildTest.BindngFilterUnsupportedNativeAbiLibraries(AndroidRuntime runtime) in /Users/runner/work/1/s/android/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BindingBuildTest.cs:line 411
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)
Let's call `Assert.Inconclusive()` when we catch such exceptions,
so that the test is marked as inconclusive instead of failed.
We also log information about the exception.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves test reliability by handling transient HTTP errors gracefully. When tests download resources using DownloadedCache, transient network failures (timeouts, gateway errors, etc.) will now mark tests as inconclusive rather than failed, with detailed logging to aid debugging.
Key changes:
- Added try-catch block to handle
HttpRequestExceptionwith transient error filtering - Implemented
IsTransientError()method to identify recoverable HTTP errors (504, 408, 502, 503) - Added comprehensive logging before marking tests inconclusive
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Common/DownloadedCache.cs
Outdated
Show resolved
Hide resolved
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Common/DownloadedCache.cs
Outdated
Show resolved
Hide resolved
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Common/DownloadedCache.cs
Outdated
Show resolved
Hide resolved
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Common/DownloadedCache.cs
Outdated
Show resolved
Hide resolved
jonathanpeppers
commented
Dec 18, 2025
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Common/DownloadedCache.cs
Show resolved
Hide resolved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
MSBuild tests using
DownloadedCachecan randomly fail with HTTP errors such as:Let's call
Assert.Inconclusive()when we catch such exceptions, so that the test is marked as inconclusive instead of failed.We also log information about the exception.