Skip to content

The agent that grows with you

test(e2e): Windows update journeys delete their install at teardown

Teknium071d0aa335c2
diff --git a/.github/workflows/windows-install-update-e2e.yml b/.github/workflows/windows-install-update-e2e.yml
index b04ac754106..26b7075d90c 100644
--- a/.github/workflows/windows-install-update-e2e.yml
+++ b/.github/workflows/windows-install-update-e2e.yml
@@ -108,6 +108,20 @@ jobs:
}
Get-Content -LiteralPath $manifest
+ - name: No machine install left behind
+ # Each journey's teardown deletes its fake profile (a full install: checkout, venv with
+ # every extra, PM tools, caches) and its serve.git. All of them on the runner's one drive
+ # outgrew its free space once the suite reached 13 files (run 39853224877: 92 MB left).
+ shell: pwsh
+ run: |
+ $left = @(Get-ChildItem -LiteralPath 'C:\Users' -Directory -Filter '*hermes-e2e-*' -ErrorAction SilentlyContinue)
+ $left += @(Get-ChildItem -Path "${{ runner.temp }}\wm\*\serve.git" -Directory -ErrorAction SilentlyContinue)
+ if ($left.Count -eq 0) { 'every machine install was removed'; exit 0 }
+ foreach ($d in $left) { "::error::left behind by a journey teardown: $($d.FullName)" }
+ Get-ChildItem -Path "${{ runner.temp }}\win-update-e2e\*\teardown-leftovers.txt" -ErrorAction SilentlyContinue |
+ ForEach-Object { Get-Content -LiteralPath $_.FullName }
+ exit 1
+
- name: Upload transcripts, logs and receipts
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
diff --git a/tests/e2e/core/windows_update/_machine.py b/tests/e2e/core/windows_update/_machine.py
index 7c57c8bcde2..5be18a638dd 100644
--- a/tests/e2e/core/windows_update/_machine.py
+++ b/tests/e2e/core/windows_update/_machine.py
@@ -586,6 +586,32 @@ class Machine:
ignore=shutil.ignore_patterns("*.db", "*.db-*"))
(dest / "evidence.txt").write_text(self.evidence(), encoding="utf-8", errors="replace")
(dest / "timings.json").write_text(json.dumps(self.timings, indent=1), encoding="utf-8")
+ # Every machine is a full install (checkout, venv with every extra, PM tools, caches) on the
+ # runner's only drive; kept, they add up past its free space before the last file runs.
+ # The transcripts stay (small, and the only record when no artifacts dir is set).
+ leftovers = [note for tree in (self.profile, self.serve) if (note := _remove_tree(tree))]
+ if leftovers: # the job's "No machine install left behind" step names these
+ dest = Path(artifacts) / self.root.name if artifacts else self.logs
+ (dest / "teardown-leftovers.txt").write_text("\n".join(leftovers) + "\n", encoding="utf-8")
+
+
+def _remove_tree(path: Path) -> str | None:
+ """Delete ``path``; ``None`` when gone, else what stopped it.
+
+ The ``\\\\?\\`` prefix reaches past MAX_PATH (the checkout carries 159-character paths); a
+ just-killed process can hold a handle for a moment, so a failure is retried."""
+ from utils import rmtree_readonly
+
+ error: OSError | None = None
+ for _ in range(5):
+ if not path.exists():
+ return None
+ try:
+ rmtree_readonly("\\\\?\\" + str(path.resolve()))
+ except OSError as exc:
+ error = exc
+ time.sleep(2)
+ return None if not path.exists() else f"{path}: {error}"
def new_machine(tmp_root: Path, base_url: str, *, label: str, person: str = "",