Skip to content

test(windows): fix installer self-update and MCP registry parallel flakes (#4029) - #4036

Merged
Daniel Meppiel (danielmeppiel) merged 6 commits into
mainfrom
danielmeppiel-reimagined-waddle
Nov 20, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 6 commits into
mainfrom
danielmeppiel-reimagined-waddle

Conversation

@danielmeppiel

@danielmeppiel Daniel Meppiel (danielmeppiel) commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Description

TL;DR — The two Windows CI flakes in #4029 are now both closed. The installer self-update flake was already root-caused and fixed on main by #3931; this PR records that evidence and changes nothing in the installer. The MCP registry parallel tests drop their elapsed < 1.0 wall-clock budget for a max-in-flight concurrency counter, so they prove parallelism independent of runner speed.

Note

This PR changes only tests/unit/integration/test_mcp_registry_parallel.py and one CHANGELOG line. A temporary harness workflow was added and reverted in-branch (its run was never approved, so it never executed); the net diff has no workflow change and build-release.yml is untouched.

Problem (WHY)

  • Installer: all 8 Windows installer job failures on main (2026-11-19 07:10–15:08 UTC) failed Test 5 (apm self-update from v0.28.0) with Expand-Archive : Cannot find an overload for "ExtractToDirectory" and the argument count: "3". Cause: the old binary's self-update leaked the pwsh host's PSModulePath into Windows PowerShell 5.1, which then loaded PowerShell 7's Archive module. It was not a file-release race; intermittency tracked the runner image mix.
  • MCP registry: three tests asserted elapsed < 1.0 over three 500 ms sleeps. On main run 44515662558 (Windows units (2/2)) the lookups ran in parallel yet failed: Wall time 1.234s >= 1.0s (not parallel). Thread startup and scheduler jitter on a loaded runner exceed the budget.

Approach (WHAT)

Flake Action
Installer self-update No change: fixed by #3931 (a98ac4238): test scrubs PSModulePath for pre-0.37 binaries, self_update drops it, install.ps1 falls back to the 2-arg ZipFile.ExtractToDirectory. Evidence below.
MCP registry parallel Replace wall time with _InFlightProbe: each stubbed lookup holds until all 3 are in flight together, test asserts max_in_flight == 3.

Implementation (HOW)

  • tests/unit/integration/test_mcp_registry_parallel.py — new _InFlightProbe stub (lock-guarded in-flight counter + threading.Event). Pass path has no time dependency. A serialized caller never reaches the target; the first call gives up after 10 s and releases the rest, so a serial regression fails fast instead of hanging. The three *_parallel_wall_time tests become *_runs_lookups_concurrently, keeping their result assertions (call count, valid/invalid, key order). The order/exception/clamp tests are unchanged.
  • CHANGELOG.md — one internal line under Fixed.

Trade-offs

  • Event + timeout vs threading.Barrier: a barrier raises BrokenBarrierError inside the worker, which batch_fetch_server_info maps to None, hiding the cause. The probe always returns a valid result, and only the max_in_flight assertion decides.
  • 10 s give-up timeout: bounds only the failure path; the passing path never waits on it.
  • Installer evidence from main, not PR reruns: the Windows installer job runs only on pushes to main. 19 consecutive green runs of the real job on the real event are stronger than synthetic PR reruns and need no workflow change during the 0.37 release (PM ruling).

Benefits

  1. The MCP parallel tests no longer depend on machine speed (20/20 green under full CPU saturation locally).
  2. A serialized executor fails all three concurrency tests (recorded mutant below).
  3. The installer flake has a documented root cause and 19/19 green runs since its fix.

Issue and approved scope

Issue: Fixes #4029

Human scope-approval comment: #4029 (comment) (eligibility.cjs: record-present, contact_confirmation_needed: false)

Completes the issue: both flakes fixed (installer by #3931, MCP here), recorded mutant, 10+ consecutive green installer runs, one CHANGELOG line.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Maintenance / refactor

Testing

  • Tested locally
  • All existing tests pass
  • Added tests for new functionality (if applicable)

Validation

Scenario evidence

Promise Test Principle
Registry lookups run concurrently test_{validate_servers_exist,check_servers_needing_installation,batch_fetch_server_info}_runs_lookups_concurrently Performance (bounded parallel I/O)
Windows self-update upgrades in place tests/integration/test_windows_installer_launchers.py (Test 5) Portability

Recorded mutant — set workers = 1 in all three MCPServerOperations batch methods (src/apm_cli/registry/operations.py), then restored:

$ uv run --extra dev pytest tests/unit/integration/test_mcp_registry_parallel.py -q
FAILED ...::test_validate_servers_exist_runs_lookups_concurrently
FAILED ...::test_check_servers_needing_installation_runs_lookups_concurrently
FAILED ...::test_batch_fetch_server_info_runs_lookups_concurrently
FAILED ...::test_batch_fetch_clamps_max_workers_to_four
4 failed, 3 passed in 30.74s

Unmutated

$ uv run --extra dev pytest tests/unit/integration/test_mcp_registry_parallel.py -q
7 passed in 0.96s
# 20 sequential runs with every CPU pinned by busy loops (nproc=2):
pass=20/20 under full CPU load

Lint contract (.apm/instructions/linting.instructions.md, on HEAD merged with current main): ruff check, ruff format --check, pylint R0801, lint-auth-signals.sh — all exit 0.

Installer: 19 consecutive green Windows installer jobs on main since #3931 (workflow build-release.yml, event push)
Run Created (UTC) Head Job Result
44629756116 2026-11-19T22:33:34Z 67936cd7d 135932939913 success
44627126683 2026-11-19T22:17:04Z 849608294 135923812873 success
44618326103 2026-11-19T21:23:44Z 14d828e3f 135892895064 success
44616669469 2026-11-19T21:13:57Z 945a8fb64 135887095167 success
44608786680 2026-11-19T20:26:58Z 2cff05910 135859489972 success
44605677944 2026-11-19T20:09:05Z 0a0f2a250 135848598018 success
44605019099 2026-11-19T20:05:18Z 1995f5045 135846284164 success
44600807041 2026-11-19T19:40:46Z 8921f49df 135831376968 success
44600417841 2026-11-19T19:38:28Z e64639cad 135829977464 success
44597965588 2026-11-19T19:24:21Z 9182f6816 135821289173 success
44596680888 2026-11-19T19:16:55Z 8b0520b81 135816726107 success
44584504592 2026-11-19T18:07:52Z ee00d6aae 135773682560 success
44580762435 2026-11-19T17:46:28Z a53298957 135760445241 success
44576742672 2026-11-19T17:23:55Z 0bb0886db 135746144670 success
44568842147 2026-11-19T16:40:59Z b50c40353 135717999548 success
44560426036 2026-11-19T15:56:21Z 94b0c693f 135687871215 success
44557731357 2026-11-19T15:41:56Z 17993ab38 135678259654 success
44553241330 2026-11-19T15:18:08Z d46ce76e5 135662288945 success
44551948140 2026-11-19T15:11:17Z a98ac4238 135657736921 success

Before #3931, the same job failed 8 of 21 main pushes (runs 44477507825, 44481309217, 44487123861, 44500212313, 44515662558, 44534060108, 44540425052, 44551368046), every one at Test 5 with the ExtractToDirectory overload error.

How to test

  • uv run --extra dev pytest tests/unit/integration/test_mcp_registry_parallel.py -q → 7 passed.
  • Set workers = 1 on the three workers = ... lines in src/apm_cli/registry/operations.py, rerun → the three *_runs_lookups_concurrently tests fail with max in flight 1 (not parallel); revert.

Changelog

  • One line in one section under ## [Unreleased] in CHANGELOG.md: user-visible effect first, 25 words or fewer, ending with (#PR); breaking changes only under upgrade notes; no Highlights; see .github/instructions/changelog.instructions.md.
  • N/A -- internal-only change (CI, tests, refactor).

Spec conformance (OpenAPM v0.1)

  • N/A -- this PR does not change OpenAPM-observable behaviour.

Co-authored-by: Copilot [email protected]

#4029)

Replace the wall-clock budget (elapsed < 1.0s) in the three parallel
registry tests with an in-flight probe: each stubbed lookup holds until
all three lookups are in flight together, and the test asserts
max_in_flight == 3. The result no longer depends on runner speed, and a
serialized executor (workers = 1) fails all three tests.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
The installer job evidence comes from main instead.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
@danielmeppiel Daniel Meppiel (danielmeppiel) added this to the 0.37.0 milestone Nov 20, 2026
@danielmeppiel Daniel Meppiel (danielmeppiel) changed the title [0.38] test(windows): fix installer self-update and MCP registry parallel flakes (#4029) test(windows): fix installer self-update and MCP registry parallel flakes (#4029) Nov 20, 2026
@danielmeppiel
Daniel Meppiel (danielmeppiel) marked this pull request as ready for review November 20, 2026 07:56
Copilot AI balanced review requested due to automatic review settings November 20, 2026 07:56

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 changelog entry for this test-only change conflicts with the release-note policy excluding internal CI/test changes and leaves an otherwise-empty Fixed section.

1 open issue
What changed in this PR

This PR stabilizes MCP registry concurrency tests for #4029 by replacing tight timing assertions with direct overlap checks. Installer code is unchanged; the description records evidence for the earlier fix in #3931.

Changes:

  • Add a lock-protected in-flight probe with a bounded timeout.
  • Update three tests to assert concurrent lookups while preserving result checks.
  • Add an internal changelog entry describing the test stabilization.
File Description
tests/​unit/​integration/​test_mcp_registry_parallel.py Replace wall-clock assertions with concurrency checks.
CHANGELOG.md Record the Windows CI test stabilization under Fixed.

Review effort: Balanced

Comment thread CHANGELOG.md Resolved
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
…ELOG [Unreleased] resolved)

Co-authored-by: Copilot App <[email protected]>
@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 58f4445 into main Nov 20, 2026
27 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-reimagined-waddle branch November 20, 2026 08:16
3 of 14 tasks
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.

Fix the two Windows CI flakes

2 participants