Skip to content

[tests] Remove duplicate integration builds and one CI lane - #13390

Merged
jonathanpeppers merged 2 commits into
mainfrom
jonathanpeppers-slow-test-duplication
Nov 5, 2026
Merged

jonathanpeppers merged 2 commits into
mainfrom
jonathanpeppers-slow-test-duplication

Conversation

@jonathanpeppers

@jonathanpeppers jonathanpeppers commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

Remove duplicate project builds without pruning distinct runtime, language, Unicode-space, or packaging scenarios. Consolidate BundleTool's repeated setup and reduce the MSBuild+Emulator pool from 12 agents to 11. No production code changes.

The public and internal inline jobs and the shared stage template now all read the single MSBuildEmulatorTestAgentCount setting in yaml-templates/variables.yaml.

First PR CI results — November 4

Build 1663708 tested merge commit 2ccc975e, which includes PR head 24cc6034 and the shared 11-agent setting. Azure actually scheduled 11 emulator jobs.

The completed lanes support the direction of the savings estimate, but this is not yet a complete before/after performance result: ten lanes completed successfully; one hosted agent disconnected during toolchain setup before it could run any tests.

Metric Three historical 12-lane runs, in build order 1662092 / 1662106 / 1662097 First 11-lane PR run
Completed primary Run tests tasks 12 / 12 / 12 10 of 11; lane 6 never reached tests
Summed primary test-task time 592.3 / 688.1 / 631.5 agent-minutes 394.5 agent-minutes, partial
Mean elapsed time per completed primary test task 49.4 / 57.3 / 52.6 minutes 39.5 minutes
Longest completed primary test task 58.0 / 92.8 / 96.5 minutes 63.4 minutes, lane 8
Additional automatic-retry task time 1.9 / 3.5 / 0.0 agent-minutes 2.9 agent-minutes

The completed-lane mean is about 25% lower than the median historical per-lane mean (39.5 vs. 52.6 minutes), despite scheduling more cases per lane after reducing the agent count. This is a descriptive comparison of completed lanes, not a measured 25% reduction in total workload or whole-pipeline elapsed time. The missing lane has different tests; dividing its partial 394.5-minute total by a complete historical total would overstate savings. All recorded primary-task work, including failed first test attempts, remains in the table.

Both consolidated BundleTool runtime cases passed on their first attempt, including their builds and install/archive assertions: CoreCLR 6m35s; NativeAOT 8m37s. Only these two BundleTool cases were published, versus 28 fixture setup executions in each historical sample. Of 250 scheduled cases, the ten reporting lanes published 227 final results: 199 passed and 28 skipped/not executed. Lane 6's 23 cases remain unvalidated by this run.

Per-lane primary test-task times
Emulator lane Run tests elapsed Result
1 40.2 min Passed
2 35.2 min Passed
3 33.0 min Passed; CoreCLR BundleTool case
4 41.0 min Primary task completed; one unchanged test passed automatic retry; NativeAOT BundleTool passed first attempt
5 33.3 min Passed
6 Not started Hosted agent lost during SDK/toolchain setup
7 23.8 min Passed
8 63.4 min Primary task completed; one unchanged test passed automatic retry
9 42.6 min Passed
10 42.4 min Passed
11 39.5 min Passed

Retry task time is additional to the primary times above. Azure reports 84.7 minutes for the emulator stage, versus 84.6–126.7 minutes in the historical samples, but the failed/incomplete stage is not a clean successful stage-latency measurement.

Why CI is red, and relevance to this PR

The sole gating root failure is hosted-agent infrastructure loss, not a test assertion or a lane exceeding its 180-minute timeout:

We stopped hearing from agent Azure Pipelines 167.

Lane 6's setup log stops during install OpenJDK and accept Android SDK licenses, while downloading the Android emulator archive. Emulator startup, slicing, Run tests, and result publishing were abandoned. This occurred before the modified tests ran; there is no evidence linking it to test consolidation or the 11-lane shard size. The build remains red, rather than being described as passing despite infrastructure failure.

Two unchanged device tests failed their first attempt and passed the pipeline's existing automatic retry without a code change: InstallAndRunTests.InterfaceMethods_CoreCLR_Native_R8 and NativeLibraryLoadTests.AssemblyStoreDlopenResolvesOriginalPayload(True,True). The latter consumed 10m43s on its failed first attempt and contributes to lane 8's long tail. Neither consolidated BundleTool case needed a retry. The public Windows and Linux test stages passed.

Conclusion: the observed completed-lane runtimes are consistent with retaining one fewer agent, and the intended BundleTool build deduplication is confirmed. The original 10–15% aggregate-work estimate remains an estimate until the missing emulator job completes in a clean retry/run. A targeted retry of failed jobs in msbuilddevice_tests would complete the evidence; no retry was initiated as part of this investigation.

Tests removed or reduced, and retained coverage

Test names below are in Xamarin.Android.Build.Tests.

Removed test/cases Why duplicative; coverage retained
BuildTest3.NativeLibraryJniPreload_AddSomeCustomLibrariesAndIgnoreAllByName() NativeLibraryJniPreload_ExcludeAllCustomLibraries() already adds two custom native libraries, excludes each by name, and verifies that the default preload libraries remain.
PackagingTest.CheckProjectWithSpaceInNameWorks("Test Me", runtime) The retained "TestUnicodeSpace0020\u0020Me" case also contains an ordinary U+0020 space. Keep that case for both runtimes, along with every distinct Unicode-space case.
PackagingTest.CheckClassesDexIsIncluded() Its only packaging assertion is that the signed Release APK contains classes.dex. Move that exact assertion into the existing Release CheckIncludedNativeLibraries() builds, retaining both runtimes and compression settings. The multidex tests also retain their packaged DEX checks.
BuildTest2.BuildMultiDexApplication() The first phase of BuildAfterMultiDexIsNotRequired() builds the same large multidex project and checks both intermediate and packaged DEX files, before testing the transition back to a single DEX. Move the unique no-Duplicate zip entry warning assertion into that retained first build.
FastDevTest.SimpleInstallAndUninstall() InstallTests.InstallAndUnInstall() already builds, installs, verifies the package and fast-deployment contents, uninstalls, and verifies removal. Keep its Debug and Release cases.
ManifestTest.OverlayManifestTest() OverlayManifestIncrementalBuildTest() already performs the initial build with the same CAMERA-permission overlay and checks the merged manifest. It additionally checks no-op target skipping and re-merging after an overlay edit. Keep both runtimes.
C# cases of AndroidUpdateResourcesTest.CheckResourceDesignerIsCreated() CheckOldResourceDesignerIsNotUsed() checks the same intermediate designer creation and removal by Clean, plus the old source designer's contents, for the corresponding C# configurations. Keep all F# cases in CheckResourceDesignerIsCreated().
Four obsolete-property variants per configuration in TrimmableTypeMapBuildTests.Build_WithTrimmableTypeMap_Succeeds() Production code no longer reads $(AndroidTypeMapImplementation), so the five values produce the same integration scenario. Keep one full build for each supported runtime/configuration. Existing standalone TypeMapProguardTargetsTests.AssemblyTargetConsumesLinkedMetadataAcrossRidsAndEmptyStubs() still exercises all five obsolete values against the production targets.
Four obsolete-property variants of InvalidConfigTests.LibraryBuildDoesNotGenerateTypeMap() The same property is unused in production. Keep the baseline library build and its assertion that no typemap assembly list is generated; retain the standalone five-value regression coverage above.
BuildTest.SmokeTestBuildWithSpecialCharacters(false, CoreCLR) ApplicationBuildTests.BuildApplicationWithSpecialCharactersInProject("テスト", true) builds the same basic CoreCLR Release project with a Japanese project name/path. Keep the other runtime/Forms smoke cases and all distinct project names.
One duplicate InvalidConfigTests.R8ObfuscationInvalidConfiguration("AndroidLinkTool", "", "AndroidLinkTool") attribute Two identical [TestCase] attributes exercised the exact same validation target and assertions. Keep one.
BundleToolTests(usesAssemblyBlobs: false, runtime) fixtures CoreCLR Release packaging forces assembly stores, regardless of the obsolete public setting. NativeAOT does not package managed assemblies, so the setting does not distinguish its output. Retain CoreCLR and NativeAOT, both packaged ABIs, and the relevant archive assertions. The consolidated compression check retains both .blob and .dll extension checks.

BundleTool consolidation: preserve assertions, eliminate repeated setup

The existing fixture had seven test methods and four parameter combinations. In each sampled CI run, each fixture appeared on seven different slices, executing its [OneTimeSetUp] 28 times. Every setup built a localization library and a multi-ABI Forms Maps app: 56 initial project builds.

  • Move BuildAppBundleCommand(), BuildApkSetCommand(), and InstallApkSetCommand() into host-side BundleToolTaskTests. These assertions do not depend on fixture parameters, generated projects, or a device; run each once without a building fixture.
  • Combine the BaseZip(), AppBundle(), AppBundleSigned(), and ApkSet() assertions into one BundleArtifacts() case per runtime. Keep archive contents, signing, ABI splits, disabled language splitting, compression, and installation checks.
  • Run the builds inside the test body so their cost is included in reported test duration, rather than hidden in fixture setup. Preserve failed-build outputs and use runtime-specific directories.

This changes 28 setup executions to two, or 56 initial library/application builds to four, regardless of which CI slices receive the two retained cases. This is build deduplication, not deletion of the artifact/install assertions.

Original estimate and why remove one lane

Original estimate: roughly 10–15% less aggregate MSBuild+Emulator test-task time. This is not a measured reduction in whole-pipeline turnaround time; see the incomplete first-run results above.

The investigation used three successful pipelines and their published per-test timestamps/durations:

Pipeline Existing Run tests minutes, summed over 12 agents Modeled removable minutes Estimated reduction
1662092 592 91 15.3%
1662106 688 71 10.4%
1662097 632 80 12.7%

BundleTool-associated pre-test gaps totaled 197–223 aggregate minutes per pipeline, but counting all of that as savings would overstate the evidence. The model excludes every first-in-run gap, uses the observed non-first BundleTool fixture gaps, and subtracts a retained-setup budget using the largest observed cold-start gap for each runtime. The estimates above do not add the separately identified test-body savings.

Dropping one of 12 agents removes 8.3% of parallel capacity. The estimated 10–15% workload reduction provides a rationale for trying 11 agents rather than keeping the redundant builds and their agent cost. The host-test removals are additional savings; they are not used to justify reducing the separate emulator pool.

The CI-pinned dotnet-test-slicer (0.1.0-alpha7) was run locally with the actual CI category filter for all 11 slices. All 250 discovered cases occur exactly once, with 22–23 cases per slice. The two retained BundleTool runtime cases land on separate agents (3 and 4).

A complete successful emulator run is still needed to confirm elapsed time and slice balance. Count-based slicing is not duration balancing. Cold restore/download/compiler/device setup can move to other tests, retries vary, four current minor-API cases lack matching historical timings, and preview-API timing comparisons require target-framework-name normalization. This is therefore a validated test consolidation with an evidence-backed lane-count experiment, not a guarantee of unchanged stage latency. There is no valid local before/after speedup measurement: the original-fixture baseline encountered an existing AVD storage failure; the changed tests were subsequently validated on a clean emulator.

Validation

Local validation was on macOS/arm64 using the locally built Release SDK and prepared JDK 25. Device validation used a clean, session-local API 29 arm64 emulator; it was stopped and removed afterward.

Command/check Result
make prepare CONFIGURATION=Release Passed.
make leeroy CONFIGURATION=Release Passed, including extra API levels and local workload configuration. Initial make all CONFIGURATION=Release built the solution but could not configure the workload before the extra API-level reference assemblies were built; make leeroy completed those prerequisites.
Focused host integration command below 45 passed, 1 expected skip: unsupported Debug NativeAOT F# configuration.
Standalone obsolete-property command below 5 passed, covering all retained obsolete-property values.
Focused device command below 4 passed: CoreCLR and NativeAOT BundleArtifacts, plus Debug/Release install/uninstall. Bundle cases took approximately 2:07 and 1:50, including their builds.
Separate --filter 'FullyQualifiedName~BundleToolTaskTests' host run 3 passed in 6 ms, with no project/device setup; also included in the 45 passing host cases.
All 11 CI slices, using the pinned slicer and CI filter Passed: 250 unique cases, no omissions or duplicates, both runtime cases retained.
CI YAML parsing and git diff --check Passed.
Focused test commands

Host integration coverage:

./dotnet-local.sh test bin/TestRelease/net11.0/Xamarin.Android.Build.Tests.dll --filter 'FullyQualifiedName~BundleToolTaskTests|Name~NativeLibraryJniPreload_ExcludeAllCustomLibraries|Name~CheckProjectWithSpaceInNameWorks|Name~CheckIncludedNativeLibraries|Name~BuildAfterMultiDexIsNotRequired|Name~OverlayManifestIncrementalBuildTest|Name~CheckResourceDesignerIsCreated|Name~CheckOldResourceDesignerIsNotUsed|Name~Build_WithTrimmableTypeMap_Succeeds|Name~LibraryBuildDoesNotGenerateTypeMap|Name~R8ObfuscationInvalidConfiguration|Name~BuildApplicationWithSpecialCharactersInProject|Name~SmokeTestBuildWithSpecialCharacters'

Retained standalone property matrix:

./dotnet-local.sh test src/Microsoft.Android.Build.Tasks/Tests/Microsoft.Android.Build.Tasks.Tests/Microsoft.Android.Build.Tasks.Tests.csproj -c Release --no-build --filter 'Name~AssemblyTargetConsumesLinkedMetadataAcrossRidsAndEmptyStubs'

Device coverage (with ADB_TARGET='-s emulator-5580' and ANDROID_SERIAL=emulator-5580):

./dotnet-local.sh test bin/TestRelease/MSBuildDeviceIntegration/net11.0/MSBuildDeviceIntegration.dll --filter 'FullyQualifiedName~BundleToolTests|FullyQualifiedName~InstallTests.InstallAndUnInstall'

All test commands used JAVA_HOME=$HOME/android-toolchain/jdk-25 and ANDROID_HOME=$HOME/android-toolchain/sdk. Host/device test projects were rebuilt in Release after the source edits. Public Windows/Linux CI passed in build 1663708; a complete 12-to-11-lane emulator stage-time comparison remains blocked on the lost-agent job described above.

Consolidate BundleTool artifact checks per runtime so CI slicing cannot
repeat their project builds. Move command-only checks to host tests,
remove covered integration cases, and reduce emulator lanes to eleven.

Co-authored-by: Copilot App <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 4, 2026 10:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The public and internal CI entrypoints still define jobs inline with parallel: 12, so changing the shared template does not make those pipelines exercise the intended 11-agent experiment.

1 open issue
What changed in this PR

This PR reduces redundant .NET for Android integration-test builds and consolidates BundleTool coverage without changing production code. It also changes the shared emulator-stage template’s default agent count as an experiment in reducing CI resource use.

Changes:

  • Remove duplicate test cases and move unique assertions into retained tests.
  • Consolidate BundleTool artifact checks into one build-backed case per runtime; move command-line checks to host-side tests.
  • Change the emulator template default from 12 agents to 11 and update the test catalog.
File Description
tests/​MSBuildDeviceIntegration/​Tests/​FastDevTest.cs Remove the duplicate install/uninstall smoke test.
tests/​MSBuildDeviceIntegration/​Tests/​BundleToolTests.cs Consolidate artifact and installation checks into one case per runtime.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​TrimmableTypeMapBuildTests.cs Remove redundant obsolete-property build variants.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​Tasks/​BundleToolTaskTests.cs Add host-side BundleTool command-line tests.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​PackagingTest.cs Remove duplicate space-name cases and relocate the packaged DEX assertion.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​ManifestTest.cs Remove overlay coverage duplicated by the incremental test.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​InvalidConfigTests.cs Remove duplicate validation and obsolete-property cases.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​BuildTest3.cs Remove duplicate native-library preload exclusion coverage.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​BuildTest2.cs Move the duplicate-entry warning assertion into the retained multidex test.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​BuildTest.cs Remove one overlapping CoreCLR special-character case.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​AndroidUpdateResourcesTest.cs Retain F# designer tests while removing overlapping C# cases.
build-tools/​automation/​yaml-templates/​stage-msbuild-emulator-tests.yaml Lower the template’s default agent count to 11.
.github/​skills/​tests/​references/​test-catalog.md Document host-side command tests and consolidated device coverage.

Review effort: Balanced

Use one compile-time variable for the public and internal inline jobs
and the shared stage template. This makes the eleven-agent reduction
apply to PR validation as well as the templated pipeline.

Co-authored-by: Copilot App <[email protected]>
@jonathanpeppers
jonathanpeppers merged commit 8aeda52 into main Nov 5, 2026
40 checks passed
@jonathanpeppers
jonathanpeppers deleted the jonathanpeppers-slow-test-duplication branch November 5, 2026 09:57
jonathanpeppers added a commit that referenced this pull request Nov 10, 2026
The internal main pipeline rejects an empty parallel count after #13390.
Restore the stage parameter and pass the shared 11-agent setting from
its caller, where the variable is available during template expansion.

Co-authored-by: Copilot App <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants