[Tests] Retry flaky InstallAndroidDependenciesTest download#11974
Open
simonrozsival wants to merge 1 commit into
Open
[Tests] Retry flaky InstallAndroidDependenciesTest download#11974simonrozsival wants to merge 1 commit into
simonrozsival wants to merge 1 commit into
Conversation
InstallAndroidDependenciesTest exercises the InstallAndroidDependencies
target, which downloads the Android SDK and JDK over the network. These
downloads fail intermittently in CI, causing the ("GoogleV2", CoreCLR)
and ("Xamarin", CoreCLR) cases to fail randomly across unrelated PRs.
Retry the install build up to 3 times, waiting 10 seconds between
attempts and starting from a clean SDK/JDK directory each time so a
partial download does not affect the next attempt.
Mitigates dotnet#11973
Contributor
There was a problem hiding this comment.
Pull request overview
Mitigates CI flakiness in InstallAndroidDependenciesTest by adding retry logic around the network-dependent InstallAndroidDependencies build target (SDK/JDK downloads), reducing random failures in unrelated PRs.
Changes:
- Add up-to-3 retry loop for
InstallAndroidDependencieswith a 10s backoff between attempts. - Recreate the SDK/JDK directories on each attempt to avoid partial/corrupt downloads affecting subsequent retries.
Show a summary per file
| File | Description |
|---|---|
| src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AndroidDependenciesTests.cs | Adds retry/backoff + per-attempt cleanup to reduce network-related test flakiness in CI. |
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 1
Comment on lines
+69
to
+91
| // InstallAndroidDependencies downloads the Android SDK and JDK over the network, which | ||
| // can fail intermittently in CI. Retry a few times before giving up, starting from a | ||
| // clean SDK/JDK directory each attempt so a partial download does not affect the next. | ||
| // See https://github.com/dotnet/android/issues/11973 | ||
| const int maxInstallAttempts = 3; | ||
| bool installSucceeded = false; | ||
| for (int attempt = 1; attempt <= maxInstallAttempts; attempt++) { | ||
| foreach (var path in new [] { sdkPath, jdkPath }) { | ||
| if (Directory.Exists (path)) | ||
| Directory.Delete (path, recursive: true); | ||
| Directory.CreateDirectory (path); | ||
| } | ||
|
|
||
| if (b.Build (proj, parameters: buildArgs.ToArray ())) { | ||
| installSucceeded = true; | ||
| break; | ||
| } | ||
|
|
||
| TestContext.WriteLine ($"InstallAndroidDependencies attempt {attempt} of {maxInstallAttempts} failed. Please check the task output in 'install-deps.log'."); | ||
| if (attempt < maxInstallAttempts) | ||
| Thread.Sleep (TimeSpan.FromSeconds (10)); | ||
| } | ||
| Assert.IsTrue (installSucceeded, $"InstallAndroidDependencies should have succeeded within {maxInstallAttempts} attempts."); |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
InstallAndroidDependenciesTestexercises theInstallAndroidDependenciestarget, which downloads the Android SDK and JDK over the network. Because there is no caching (the test wipes and recreates the SDK/JDK directories on every run), these downloads fail intermittently in CI — causing the("GoogleV2", CoreCLR)and("Xamarin", CoreCLR)cases to fail randomly across unrelated PRs.Typical failure (a short 2–4s
FailedBuildException, with the real error hidden in the per-testinstall-deps.logartifact):Change
Retry the
InstallAndroidDependenciesbuild up to 3 times:Notes
This is a mitigation for the CI flakiness, not a confirmed root-cause fix — the underlying network failure still needs to be characterized from
install-deps.log. The tracking issue is intentionally left open for that investigation.Mitigates #11973