Skip to content

Fix install-script E2E flakiness and re-add to Windows gate

Placeholder ppxd requested to merge fix/windows-install-script-e2e into main

Summary

Fix two pre-existing test-quality bugs that kept TentacleInstallScriptE2E red on the windows-latest (Administrator) runner — surfaced by the new Windows smoke gate (#407/#408), and red on every push to main before that.

  • UAC tests (3 TentacleUacElevationE2ETests) — two compounding causes:
    1. install-tentacle.ps1 defined its own script-local Test-IsAdministrator, which shadowed the test's parent-scope function global: mock → on an admin host the real check returned $true and elevation was skipped. Fix: guard the definition (if (-not (Test-Path Function:\...))) so an ambient mock wins.
    2. Root cause of the exit-99 mismatch (verified locally with PowerShell): the wrapper invokes the script via the call operator (& script.ps1), and exit N inside a &-invoked script sets $LASTEXITCODE but not the wrapper process's exit code — so the mocked elevation exit (99) was lost and the assertion read 0. The mock was working; this was never a mock-interception problem. Fix: the wrapper ends with exit $LASTEXITCODE.
    • Also factor the elevation launch into a guard-defined Invoke-UacRelaunch seam the test overrides, instead of mocking the built-in Start-Process cmdlet — a cleaner, less fragile seam.
  • install-info parallel race (TentacleInstallScript*E2ETests) — the script writes install-info.json to the shared canonical %ProgramData%\Squid\Tentacle\, so install-script test classes running in parallel clobbered each other's file. Fix: redirect the child's %ProgramData% to a per-test temp dir via ProcessStartInfo, mirroring TentacleUpgradeLifecycleE2ETests.
  • Re-add TentacleInstallScriptE2E to the Windows smoke gate (tentacle-windows-smoke-e2e.yml): both filter defaults + the detect job's path match.

Production change (install-tentacle.ps1) is non-breaking: normal installs have no ambient function override and behave identically. The versioned-layout drift detector is unaffected (it pins the extract/swap region, not the elevation path).

Test plan

  • Root cause reproduced + fix verified locally on PowerShell (exit $LASTEXITCODE propagates the &-invoked script's exit)
  • Category=TentacleInstallScriptE2E dispatched on windows-latest: 15/15 green (was 12/15, then 3 UAC failing)
  • C# compiles clean; brace balance + drift detector verified
  • This PR's gate run exercises the full 6-category default filter (69 tests) on windows-latest and goes green
  • tests.yml (unit + Tentacle drift detector + integration) green

Merge request reports

Loading