Skip to content

test(sdk): run scripted OpenTofu tests concurrently - #13112

Merged
cv merged 5 commits into
v1from
test/scripted-tofu-concurrency
Oct 13, 2026
Merged

cv merged 5 commits into
v1from
test/scripted-tofu-concurrency

Conversation

@cv

@cv cv commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

Removes the mutex that made scripted OpenTofu tests run one at a time.

This branch also carries #13113, which merged into it: one shared write_bundle in tests/support/bundle.rs for deployment.rs and scripted_tofu.rs.

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.

cv added 2 commits October 13, 2026 11:11
#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.
The scripted tests serialized themselves because a child forked by another
thread could keep a Deployment's lock file locked until it executed. Since
#13056, Store::drop unlocks the file explicitly, so the shared lock is gone
when an operation ends whatever descriptors remain. Without the mutex the
SDK integration binary runs in about 5 s instead of 17 s under cargo test.
Base automatically changed from test/write-executables-out-of-process to v1 October 13, 2026 18:46
@cv
cv enabled auto-merge (squash) October 13, 2026 18:46
cv added 2 commits October 13, 2026 11:46
`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.
…urrency

# Conflicts:
#	crates/nemoclaw-sdk/tests/support/scripted_tofu.rs
@github-actions

Copy link
Copy Markdown
Contributor

@cv
cv merged commit bceec80 into v1 Oct 13, 2026
@cv
cv deleted the test/scripted-tofu-concurrency branch October 13, 2026 20:04
@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