Skip to content

test: write test executables out of process - #13111

Merged
cv merged 1 commit into
v1from
test/write-executables-out-of-process
Oct 13, 2026
Merged

cv merged 1 commit into
v1from
test/write-executables-out-of-process

Conversation

@cv

@cv cv commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator

Test executables are now written by a child process, so a concurrently forked child cannot keep them busy. That replaces the workarounds #13056 added one test at a time.

Why

The kernel refuses to run a file that any process holds open for writing (ExecutableFileBusy). When a test thread writes a script, a child that another thread forks at that moment inherits the writable descriptor until it calls exec. #13056 worked around this differently in each test:

Test Workaround
SSH hardware collector Fake docker and nvidia-smi as shell functions, with an alias for the hyphenated name
Packaged recipe A symlinked directory aliasing /bin/cat, replaced by a real directory to tamper with it
vLLM launch /bin/sh symlinked as python3, reading a module-named file from the working directory
SDK postcondition evidence The script run through /bin/sh
Scripted OpenTofu A warm loop that retried tofu init until the file was no longer busy

Change

  • crates/test-support/executable.rs adds write_executable(path, contents). It pipes the contents to /bin/sh -c 'cat > "$1" && chmod 700 "$1"', so the test process never opens the file and no fork can inherit a writable descriptor for it.
  • The five tests above go back to plain scripts written with it. The vLLM fake still checks the --model directory argument that fix: report bounded OpenShell rejections and harden teardown, locking, and test fixtures #13056 added.
  • The scripted OpenTofu drops warm and the call-log reset that followed it.
  • The staged provider in nemoclaw-test-fixtures still runs through /bin/sh, because the code under test writes that file, not the test.

Validation

  • cargo test -p nemoclaw-provider --lib, -p nemoclaw-runtime --lib, and -p nemoclaw-sdk --test integration: eight rounds each, all passed.
  • I couldn't reproduce ExecutableFileBusy on this host, even with the in-process writes this replaces. So these runs show that the tests still pass, not that the race is gone. The fix rests on the reasoning above.
  • cargo ci on linux_arm64: all steps passed. Windows and macOS cfg gates are checked only by GitHub CI.

#13056 avoided executables that a concurrently forked child kept busy in
five ways: shell functions, a symlinked /bin/cat, /bin/sh symlinked as
python3, scripts run through /bin/sh, and a retry loop. A child process now
writes each test executable, so this process never holds it open for
writing and no fork can inherit that descriptor. The SSH collector, recipe,
vLLM launch, and SDK postcondition tests go back to plain scripts, and the
scripted OpenTofu no longer needs its warm-up retry.

The staged provider in nemoclaw-test-fixtures still runs through /bin/sh:
the code under test writes that file, not the test.
@github-actions

Copy link
Copy Markdown
Contributor

@cv
cv enabled auto-merge (squash) October 13, 2026 18:44
@cv
cv merged commit a210031 into v1 Oct 13, 2026
@cv
cv deleted the test/write-executables-out-of-process branch October 13, 2026 18:46
cv added a commit that referenced this pull request Oct 13, 2026
`deployment.rs` and `scripted_tofu.rs` now share one test bundle writer.

Stacked on #13112.

## Why

Both tests wrote a bundle whose manifest verifies. `scripted_tofu.rs`
(#13081) kept a copy of `deployment.rs::write_bundle` that differed only
for `libexec/tofu`, because `deployment.rs` also runs on Windows and the
scripted copy needs Unix.

## Change

- `tests/support/bundle.rs` adds `write_bundle(directory, tofu:
Option<&str>)`. Without a script, every file is a non-executable
fixture. With one, `libexec/tofu` is that script, written with
`write_executable` from #13111. Passing a script on a platform other
than Unix panics.
- `deployment.rs` and `scripted_tofu.rs` call it and drop their own
copies.

I left two other duplicates alone:

- `Events` in `nemoclaw-e2e/tests/helm_recovery.rs`, which is two
methods long.
- `Snapshot` there and `Untouched` in `kubernetes_interruption.rs`,
which check different state.

Both sit in other crates, so sharing them would mean adding them to
`nemoclaw-test-fixtures` for little gain.

## Validation

- `cargo test -p nemoclaw-sdk --test integration`: 444 passed.
- `cargo ci` on linux_arm64: all steps passed. GitHub CI checks the
Windows build of `deployment.rs`; I couldn't cross-compile it here.
cv added a commit that referenced this pull request Oct 13, 2026
Removes the mutex that made scripted OpenTofu tests run one at a time.

Stacked on #13111.

## Why

`scripted_tofu.rs` (#13081) held a process-wide `ONE_AT_A_TIME` mutex
for each `Scripted` fixture. Its comment gave the reason: a child that
another thread forks while `Deployment` holds its lock file keeps the
lock until it calls exec, so the next operation could find the
deployment locked. #13056 fixed that cause in `Store::drop`, which now
unlocks the file explicitly, so the lock is released when an operation
ends even if a child still holds a copy of the descriptor. Nextest
already runs each test in its own process. The mutex only slowed `cargo
test`, which runs tests as threads of one process.

## Change

Remove `ONE_AT_A_TIME` and the guard that `Scripted` held.

## Validation

- `cargo test -p nemoclaw-sdk --test integration`: 12 rounds passed. The
binary takes about 5 s instead of about 17 s.
- `cargo test -p nemoclaw-sdk --test integration kubernetes_interruption
-- --test-threads=32`: 20 rounds passed.
- `cargo ci` on linux_arm64: all steps passed.
@wscurran wscurran added area: ci CI workflows, checks, release automation, or GitHub Actions chore Build, CI, dependency, or tooling maintenance labels Oct 13, 2026
@wscurran wscurran added the v1 NemoClaw v1 branch label Oct 28, 2026
@cv cv added this to the Roadmap: GTC DC 2026 milestone Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: ci CI workflows, checks, release automation, or GitHub Actions chore Build, CI, dependency, or tooling maintenance v1 NemoClaw v1 branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants