Skip to content

test(android): remove false boots and port races from emulator, session and reaper tests - #302

Merged
ElbertePlinio merged 2 commits into
mainfrom
fix/210-293-android-test-races
Oct 8, 2026
Merged

ElbertePlinio merged 2 commits into
mainfrom
fix/210-293-android-test-races

Conversation

@ElbertePlinio

Copy link
Copy Markdown
Member

Two Android test races fixed in test code only.

#210: the port collision tests paired a fake emulator that exits with a collision with an adb fake that reports the device as booted. When the fake emulator exited slowly, a boot poll won and startEmulator resolved. "Gives up after the bounded retries" now uses the existing never-booting adb fake. "Retries on a fresh port" had the same race, so it now uses an adb fake that reports a boot only for the retried port's serial. Both tests still prove the same behavior. startEmulator already prefers an exit it has observed, so no product change was needed.

#293: two processes probing the same port the way the allocator does see it as bound about 16% of the time. The abstract socket lock from emulator.test.ts moved into packages/android/test/port-lock.ts. The session, reaper and emulator test files each take their own named lock over their own port range, so a second copy of the same file waits, and different files still run in parallel.

Closes #210
Closes #293

Requirement Verified by Scenario Result Evidence
#210 collision tests never see a false boot Forced-delay experiment, repeat runs 0.2 s delay before the fake emulator exits: old fakes failed 5 of 5 and 3 of 3, new fakes passed 5 of 5 each Fixed ~/Artifacts/pickforge-batch3-2026-10-08/worker-B-pf-race
#210 stable under load Repeat runs 32 busy loops: collision tests 80 of 80; full emulator.test.ts 30 of 30, twice Pass (old: 1 failure in 40) worker-B-pf-race
#293 confirm whether concurrent runs collide Probe experiment Two processes probing the same port; background prober on 5640 to 5649 Bound in about 16% of probes; session and reaper tests failed 5 of 5 with the prober worker-B-pf-race
#293 lock per file Repeat runs Two concurrent copies of session and reaper, 25 rounds under load; plus emulator, 15 rounds 50 of 50 and 30 of 30 passed worker-B-pf-race
Repo checks lint, typecheck, build, PickCheck, coverage Head f87e96c on a quiet host All pass; 2968 tests, thresholds hold ~/Artifacts/pickforge-batch3-2026-10-08/210-293-android-test-races-cov.log

QA device pass: skipped. The change is test code only, so there is nothing to drive.

The collision tests paired an emulator that exits with an adb fake that
always reports a finished boot. A boot poll that ran before the exit was
seen let startEmulator resolve, so the give-up test failed about once in
30 runs. The give-up test now uses an adb that never reports a boot. The
retry test uses an adb that reports a boot only for the retry port.

Closes #210
The port allocator's TCP probe briefly binds each port it checks, so two
concurrent runs of session.test.ts or reaper.test.ts can see each other's
fixed explicit ports as bound and fail with a port collision. Move the
host-wide abstract socket lock from emulator.test.ts into a shared helper.
Each file now holds its own named lock over its disjoint port window, so
a second run of one file waits while different files still run in
parallel.

Closes #293
@ElbertePlinio
ElbertePlinio merged commit 5bd7788 into main Oct 8, 2026
10 checks passed
@ElbertePlinio
ElbertePlinio deleted the fix/210-293-android-test-races branch October 8, 2026 06:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant