Skip to content

Commit d3d5171

Browse files
authored
fix(e2e): parse swap rows from GitHub runners (#7329)
<!-- markdownlint-disable MD041 --> ## Summary Fix the Hermes rebuild swap probes so they accept the five-column `swapon` rows returned by GitHub Actions runners. Before this change, both probes reported healthy swap as zero; now they read the `SIZE` field while preserving digit-only output support. ## Changes - Parse digit-only `SIZE` output and validated `NAME TYPE SIZE USED PRIO` runner rows. - Add a regression test with the exact pre-provision and post-provision row shapes from the failed release gate. - Reject unrelated five-field output so diagnostics cannot bypass swap provisioning. - Record the escaped-defect cause: the parser assumed `--output SIZE` always produced one column, and the test covered only that assumed output. ## Type of Change - [x] Code change (feature, bug fix, or refactor) - [ ] Code change with doc updates - [ ] Doc only (prose changes, no code sample modifications) - [ ] Doc only (includes code sample changes) ## Quality Gates - [x] Tests added or updated for changed behavior - [ ] Existing tests cover changed behavior — justification: - [ ] Tests not applicable — justification: - [ ] Docs updated for user-facing behavior changes - [x] Docs not applicable — justification: This change only affects internal E2E release-validation infrastructure. - [ ] Sensitive paths changed (security, policy, credentials, preflight, onboarding, inference, runner, sandbox, or messaging) - [ ] Sensitive-path review completed or maintainer-approved waiver recorded — reviewer/approval link/justification: - [ ] Non-success, skipped, or missing CI check accepted by maintainer — check name, approval link, and follow-up issue: ## DGX Station Hardware Evidence - [ ] Tested on DGX Station - Tested commit: not applicable - Station profile/scenario: not applicable - Result: not applicable - Supporting evidence: not applicable ## Verification - [x] PR description includes a `Signed-off-by:` line and every commit appears as `Verified` in GitHub - [x] Normal `pre-commit`, `commit-msg`, and `pre-push` hooks passed, or `npm run check:diff` passed when hooks were skipped or unavailable - [x] Targeted behavior tests pass for the current change set, or tests are marked not applicable above — `npx vitest run --project e2e-support test/e2e/support/hermes-rebuild-swap.test.ts` (5 passed) - [ ] Applicable broad gate passed — not applicable to this focused helper change. A complete E2E-support run passed 1,273 tests; six unrelated macOS time-out or fixture failures remain outside the changed files. - [x] Quality Gates section completed with required justifications or waivers - [x] No secrets, API keys, or credentials committed - [ ] `npm run docs` builds without warnings (doc changes only) - [ ] Doc pages follow the [style guide](https://github.com/NVIDIA/NemoClaw/blob/main/docs/CONTRIBUTING.md) (doc changes only) - [ ] New doc pages include SPDX header and frontmatter (new pages only) --- Signed-off-by: Julie Yaunches <[email protected]> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved parsing of active swap information from multi-line runner-style output, including handling file/partition rows and descriptive columns. * More reliably totals swap sizes and safely ignores unrelated rows, improving swap-related decision behavior. * **Tests** * Added end-to-end test cases covering varied swap row formats and validation of the summed total. * Added coverage for ignoring irrelevant output and ensuring the rebuild condition triggers appropriately. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 5814d19 commit d3d5171

2 files changed

Lines changed: 26 additions & 2 deletions

File tree

‎test/e2e/fixtures/hermes-rebuild-swap.ts‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,16 @@ export function parseActiveSwapBytes(output: string): number {
99
.map((line) => line.trim())
1010
.filter(Boolean)
1111
.reduce((total, line) => {
12-
if (!/^\d+$/u.test(line)) return total;
13-
return total + Number.parseInt(line, 10);
12+
const fields = line.split(/\s+/u);
13+
const isSwapRow =
14+
fields.length === 5 &&
15+
(fields[1] === "file" || fields[1] === "partition") &&
16+
/^\d+$/u.test(fields[2] ?? "") &&
17+
/^\d+$/u.test(fields[3] ?? "") &&
18+
/^-?\d+$/u.test(fields[4] ?? "");
19+
const size = fields.length === 1 ? fields[0] : isSwapRow ? fields[2] : undefined;
20+
if (!size || !/^\d+$/u.test(size)) return total;
21+
return total + Number.parseInt(size, 10);
1422
}, 0);
1523
}
1624

‎test/e2e/support/hermes-rebuild-swap.test.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,22 @@ describe("Hermes rebuild swap", () => {
1515
expect(parseActiveSwapBytes("17179869184\n17179869184\n")).toBe(HERMES_REBUILD_SWAP_BYTES);
1616
});
1717

18+
it("adds active swap sizes from GitHub Actions runner rows", () => {
19+
const output = [
20+
"/swapfile file 3221221376 0 -2",
21+
"/mnt/nemoclaw-hermes-rebuild.swap file 34359734272 0 -3",
22+
].join("\n");
23+
24+
expect(parseActiveSwapBytes(output)).toBe(37_580_955_648);
25+
});
26+
27+
it("ignores unrelated five-field output", () => {
28+
const activeSwapBytes = parseActiveSwapBytes("notice ignored 34359738368 text text");
29+
30+
expect(activeSwapBytes).toBe(0);
31+
expect(needsHermesRebuildSwap({ activeSwapBytes, githubActions: true })).toBe(true);
32+
});
33+
1834
it("provisions swap only on GitHub Actions runners below the rebuild floor", () => {
1935
expect(needsHermesRebuildSwap({ activeSwapBytes: 0, githubActions: true })).toBe(true);
2036
expect(

0 commit comments

Comments
 (0)