Skip to content

Add a local replay harness for the Emulator Preview multi-run job - #24

Merged
jpcottin merged 2 commits into
mainfrom
ci/local-replay-harness
Jul 26, 2026
Merged

Add a local replay harness for the Emulator Preview multi-run job#24
jpcottin merged 2 commits into
mainfrom
ci/local-replay-harness

Conversation

@jpcottin

Copy link
Copy Markdown
Owner

What

scripts/replay-preview-multirun.sh replays the Emulator Preview multi-run CI job locally. Same boot/snapshot cycles, a few minutes instead of a ~25 minute push round trip:

scripts/replay-preview-multirun.sh            # 4 cycles, throwaway AVD, cleaned up after
scripts/replay-preview-multirun.sh -n 2 -k    # 2 cycles, keep the AVD
scripts/replay-preview-multirun.sh -h         # options

It reports the app pid per cycle — identical from cycle 2 on means the app survived every snapshot restore, which is the property the experiment exists to check.

Written for a dev machine, not a runner

CI can assume it owns the host. A laptop cannot, so:

  • adb calls are pinned to the emulator the script launched, identified as the device that appears after launch rather than assuming emulator-5554. Another emulator may already hold the default ports, and adb may still list a stale entry for one that has exited. If ours never appears and the log shows the console port was taken, it reports that instead of driving someone else's device.
  • Shutdown is scoped to the emulator's own process group.
  • A pre-existing AVD is reused and never deleted — only one the script created is cleaned up, and -k keeps that too.
  • An existing console auth token is left untouched.

README

Updated the CI/CD section: it still described three jobs (there are six), and the smoke matrix had grown to API 37.0 + 37.1 across two GPU backends and both channels. Added the three experiment jobs, the shared composite action, and the local-replay instructions.

Verification

  • Full 4-cycle run end to end: app pid identical across cycles 2–4, quickboot snapshot restored each time, qemu-img snapshot table populated.
  • Input guards rejected -a "", -a ../evil, -n abc, -n 0 without touching any AVD.
  • Pre-existing-AVD protection tested against a sentinel AVD in a sandbox HOME: reused, reported, and left intact.
  • Serial selection unit-tested across four cases (foreign emulator present, stale entry only, clean machine, two foreign emulators). The previous tail -1 approach hijacked a foreign device in the stale-entry case; the new logic errors cleanly.

The last one was not hypothetical — a concurrent emulator on 5554 during testing is exactly how the bug surfaced.

Not included

avd pause before the exit screenshot, which would have removed the few seconds of drift between the screenshot and the snapshot: the console advertises it under help avd but the current preview build answers KO: not implemented, and the guest keeps running through it. Worth revisiting when it lands.

jpcottin added 2 commits July 26, 2026 12:02
Pushing to see how the preview emulator behaves is a 25-minute round trip.
scripts/replay-preview-multirun.sh runs the same boot/snapshot cycles on a
dev machine in a few minutes: create the AVD, install the APK with auto-play
enabled, play, screenshot, shut down so the emulator writes its quickboot
snapshot, and repeat. It reports the app pid per cycle, which is the property
the experiment exists to check.

It is written for a developer machine rather than a runner, so unlike CI it
cannot assume it owns the host:

- every adb call is pinned to the emulator it launched. The emulator is
  identified as the device that appears after launch, not by assuming
  emulator-5554 -- another emulator may already hold the default ports, and
  adb may still list a stale entry for one that has exited. If ours never
  appears and the log shows the console port was taken, it says so instead of
  driving somebody else's device.
- shutdown is scoped to the emulator's own process group.
- an AVD that already existed is reused and never deleted; only one the
  script created is cleaned up, and -k keeps that too.
- an existing console auth token is left untouched.

README gains the local-replay instructions and an updated CI/CD table: it
still described three jobs, and the smoke matrix had grown to cover API 37.0
and 37.1 across two GPU backends and both channels.
…down

A cycle that failed part-way left the emulator running, and the script went
straight to removing the AVD. The emulator was still writing, so it recreated
the directory after the delete -- leaving an .avd with no .ini, which the next
run then reused and could not boot.

Take the emulator down and wait for its process group before reporting or
removing anything, and keep the AVD if it somehow will not stop. Treat an
.avd/.ini pair that is missing one half as incomplete: say so and replace it,
rather than trying to boot it.
@jpcottin
jpcottin merged commit f253468 into main Jul 26, 2026
13 checks passed
@jpcottin
jpcottin deleted the ci/local-replay-harness branch July 26, 2026 22:40
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.

1 participant