[tests] Fail fast when the emulator package manager service is wedged#11966
Open
simonrozsival wants to merge 1 commit into
Open
[tests] Fail fast when the emulator package manager service is wedged#11966simonrozsival wants to merge 1 commit into
simonrozsival wants to merge 1 commit into
Conversation
Device integration tests only gate on "adb shell echo OK" before running. That succeeds even when the emulator's system_server / package manager service has crashed, so the health check passes, the test proceeds to build and install an app, and then fails deep inside the build with a cryptic bundletool "Failure calling service package: Broken pipe (32)" (XABAS0000) - reported as N unrelated per-test failures long after the emulator died. Probe the package manager service (the same "pm list features" path that bundletool "build-apks --connected-device" and "adb install" use) in the shared SetUp. When it is wedged, restart the emulator once; if it is still broken, mark the run inconclusive with a clear "package manager service is unresponsive" message so an emulator failure is surfaced immediately and is not mistaken for a product regression. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a stronger emulator health check to the shared device-test SetUp so infrastructure failures (wedged system_server / package manager binder) are detected early and reported as inconclusive rather than cascading into many misleading build/install test failures.
Changes:
- Introduces
IsPackageManagerResponsive(out diagnostic)which probesadb shell pm list featureswith retries to detect a broken package service. - Adds
AssertPackageManagerResponsive()to restart the emulator once and mark the run inconclusive if the service remains unresponsive. - Calls the new assertion from the shared
[SetUp]to fail fast before build/install work begins.
Show a summary per file
| File | Description |
|---|---|
| src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/DeviceTest.cs | Adds package-manager responsiveness probing and a fail-fast setup check to restart/skip on emulator service wedges. |
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 2
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.
Problem
Device integration tests (
DeviceTest) gate onadb shell echo OKin the shared[SetUp]before running. That check succeeds even when the emulator'ssystem_server/ package manager service has crashed or wedged. As a result the health check passes, the test proceeds to build and install an app, and then fails deep inside the build with a cryptic error:Because these tests run a combined
/t:Build,Installtarget, an emulator/service failure surfaces as a misleadingFailedBuildException: "Build failure"— reported as N unrelated per-test failures long after the emulator actually died, instead of a single clear "emulator unusable" signal up front.Observed in the wild: a single macOS emulator lane failed 8 diverse tests (BundleTool, Debugging, InstallAndRun, StoreKey) while every other build/test lane stayed green — the classic signature of a wedged package service, not a product regression.
Fix
Probe the package manager service — the same
pm list featuresbinder path thatbundletool build-apks --connected-deviceandadb installrely on — in the sharedSetUp:IsPackageManagerResponsive(out diagnostic)— retries a few times so a momentary hiccup doesn't trigger an unnecessary emulator restart.AssertPackageManagerResponsive()— if the service is wedged, restart the emulator once; if it's still broken,Assert.Inconclusivewith a clear "package manager service is unresponsive (system_server likely crashed)" message.This surfaces the failure before building/installing the app, once, with a real reason — and marks it inconclusive (an infrastructure problem) rather than turning an emulator crash into product-test failures, consistent with the existing
RestartDevicetransient-failure handling.