Skip to content

test: move the SDK's OpenTofu recovery tests to nemoclaw-e2e - #13002

Merged
cv merged 1 commit into
v1from
test/sdk-recovery-scenarios
Oct 11, 2026
Merged

cv merged 1 commit into
v1from
test/sdk-recovery-scenarios

Conversation

@cv

@cv cv commented Oct 11, 2026

Copy link
Copy Markdown
Collaborator

Part of #12881.

Failure

Six nemoclaw-sdk tests ran the bundled OpenTofu:

  • Five Helm recovery tests in deployment::runtime::helm_recovery::tests (lifecycle step).
  • managed_gateway_plan_apply_noop_destroy_and_recovery_use_real_opentofu (Live / Docker).

They built their starting states with SDK internals: Record, Store, initialize, tofu, saved_plan, checkpoint_helm_binding, and runtime_stage. The public API can't reach those states offline. Installing the gateway release through apply would pull the pinned chart, because Helm provider 3.3.0 pulls it during every plan. A runtime apply that stops after OpenTofu saves its identities has no fault a test can inject.

Decision

  • Test-only setup in the SDK. A test-scenarios feature compiles three hidden Deployment methods in crates/nemoclaw-sdk/src/deployment/runtime/scenarios.rs:

    • scenario_runtime_stage plans or applies only the runtime stage.
    • scenario_interrupt_runtime_apply saves the configuration as a runtime apply that started and didn't finish.
    • scenario_runtime_tofu runs OpenTofu commands in that stage with destroy's environment.

    Their doc comment says they exist only for these tests. The feature is off by default, no other feature enables it, and only nemoclaw-e2e's dev-dependency turns it on. cargo tree -e features -i nemoclaw-sdk shows it for neither nemoclaw-cli nor any normal workspace build.

  • The Helm tests move to crates/nemoclaw-e2e/tests/helm_recovery.rs. Setup imports the fixture release with the real Helm provider. The tests then call only the public destroy, plan_destroy, and export, and use the public Progress stream for fault timing and cancellation. They read bindings from the stage's terraform.tfstate.

  • The interrupted-destroy test now stops at the real boundary. It no longer runs the SDK's destroy steps by hand. Fault injection starts at Progress::Destroying, after the saved plan, and the test cancels when the native apply completes. Destroy returns Cancelled before its recovery handler runs: the state the old test reproduced by hand.

  • The managed gateway test moves to crates/nemoclaw-e2e/tests/managed_gateway.rs with the same name, so the live-docker runner's GATEWAY_TESTS still selects it. It applies only the runtime stage through scenario_runtime_stage, as before. A full apply would also need sandboxes, so the hook needs fewer SDK internals than a rewrite.

  • Filters and docs: the lifecycle and live-docker filters in .config/nextest.toml select the moved tests, and docs/contributing/live-tests.md names the new location.

  • Dependencies: nemoclaw-e2e gains base64, bollard, and url as dev-dependencies; nemoclaw-sdk drops its unused bollard dev-dependency.

Changed assertions

Assertions not listed moved unchanged, with Fixture::bindings reading the stage's OpenTofu state instead of Store::bindings.

Test Before Now
cancellation_after_successful_apply_retains_a_resumable_destroy_checkpoint record.destroying() && !record.destroyed() export refuses with cannot export while destroy is unfinished
Same test The checkpoint file exists after cancellation and is gone after the retry The stage holds a file the SDK added (other than OpenTofu's .plan and .backup files) after cancellation, and none after the retry
an_interrupted_destroy_recovers_on_retry_without_mutating_during_preview The checkpoint's mode excludes group and other Moved to a new unit test, nemoclaw-runtime files::tests::atomic_writes_are_private_to_their_owner. It checks the save_json writer that saves the checkpoint and fails when atomic_write uses 0644
Same test Bindings and checkpoint bytes are unchanged by plan_destroy Every stage file except the regenerated main.tf.json is byte-identical after plan_destroy. This covers the state and the checkpoint without naming it
Same test The checkpoint exists, and is removed after the retry Same file checks as in the cancellation test
managed_gateway_plan_apply_noop_destroy_and_recovery_use_real_opentofu A loaded record's UID matches the document Removed: it only checked that the state directory belonged to the document, and the runner always supplies a fresh directory
Same test After plan_destroy, the record is pending export refuses with apply is unfinished
Same test After destroy, the record is not pending export refuses with cannot export a destroyed deployment. It checks for unfinished applies first, so the deployment isn't pending
Same test An unchanged runtime apply returns no changes and isn't deferred scenario_runtime_stage returns no changes, and every binding is unchanged

Validation

On linux_arm64, against a bundle built from v1:

  • cargo nextest run -p nemoclaw-e2e --test integration --run-ignored all -E 'test(/^helm_recovery::/)': 5 passed in 50 s, the slowest in 16 s.
  • Mutation checks:
    • Skipping the binding restore in recover_helm_binding fails the two after-plan tests and the interrupted-destroy test.
    • Keeping the checkpoint after recovery fails four of the five tests.
    • Restoring the code passes all five.
  • files::tests::atomic_writes_are_private_to_their_owner fails with mode 0644 and passes with 0600.
  • cargo nextest list --profile lifecycle --run-ignored all and --profile live-docker list the moved tests, and no SDK test runs OpenTofu.
  • cargo nextest run -p nemoclaw-build with the budget, profile, and filter tests: 29 passed.
  • cargo fmt --all --check and cargo clippy --workspace --all-targets -- -D warnings: clean.
  • I couldn't run the managed gateway test locally; it needs cargo ci live-docker's images and documents. CI's Live / Docker job runs it.

Remaining for #12881

  • crates/nemoclaw-e2e/tests/model_live.rs still decodes intent.json and the SDK's internal inference_service target. It runs only by hand on a GPU host, and a rewrite needs such a run to validate.
  • nemoclaw-provider's runtime_contract and runtime_image tests decode SDK-compiled target spec values through the public nemoclaw_sdk::managed::Spec, the type the provider consumes.

With those open, this PR does not close the issue.

The five Helm recovery tests and the managed gateway runtime test ran the
bundled OpenTofu from nemoclaw-sdk and built their starting states with
SDK internals. They now live in nemoclaw-e2e and use a test-scenarios
feature of the SDK, off by default and enabled only by nemoclaw-e2e's
dev-dependency, to build those states; recovery runs through the public
destroy and plan_destroy.
@cv cv added area: e2e End-to-end tests, nightly failures, or validation infrastructure v1 NemoClaw v1 branch area: kubernetes labels Oct 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

@cv
cv merged commit 3b248a7 into v1 Oct 11, 2026
@cv
cv deleted the test/sdk-recovery-scenarios branch October 11, 2026 20:50
cv added a commit that referenced this pull request Oct 12, 2026
Part of #12881.

## Failure

#13002 moved the SDK's Helm recovery tests to nemoclaw-e2e, and #12997
merged after it with the earlier layout. On v1:

- `docs/contributing/testing.md`'s layer table and System section say
the `lifecycle` profile selects ignored Helm recovery tests in the
`nemoclaw-sdk` library.
- `docs/contributing/integration-tests.md` says the same and gives
`cargo test -p nemoclaw-sdk --lib -- --ignored helm_recovery`, which no
longer runs any test.

## Decision

- **`testing.md`:**
- The System row and section list `helm_recovery` with the other
`nemoclaw-e2e` modules that the `lifecycle` profile selects.
- The Live section names nemoclaw-e2e's `managed_gateway` test and links
its inputs in `live-tests.md`, which #13002 already updated.
- **`integration-tests.md`:**
  - The system-test introduction no longer names the SDK.
  - The module table gains `helm_recovery`.
- A new "Helm Release Recovery" subsection explains why each test starts
from an imported release. It says the SDK's test-only `test-scenarios`
feature builds that state and that nemoclaw-e2e enables it, so no flag
is needed. It gives the run command.

I checked the rest of both files for other changes from #13002 and found
none. Two facts stay true:

- The `live-docker` profile still selects one `nemoclaw-sdk` test,
`kubernetes_auth::the_issuer_image_serves_both_documents_over_https`.
- Crates still include `crates/test-support` as private modules.

## Validation

Checked against v1 (`3b248a7b76`):

- `.config/nextest.toml`: the `lifecycle` filter selects
`helm_recovery::` and the `live-docker` filter selects
`managed_gateway::` in `nemoclaw-e2e`'s `integration` binary.
- `crates/nemoclaw-e2e/tests/main.rs` declares both modules
`#[cfg(unix)]`.
- `crates/nemoclaw-e2e/Cargo.toml` enables `test-scenarios` on its
`nemoclaw-sdk` dev-dependency.
- The documented command, `NEMOCLAW_TEST_BUNDLE=… cargo test -p
nemoclaw-e2e --test integration -- --ignored helm_recovery::`, ran 5
tests, all passing, on linux_arm64.
- `cargo test -p nemoclaw-e2e --test integration -- --list --ignored
--exact
managed_gateway::managed_gateway_plan_apply_noop_destroy_and_recovery_use_real_opentofu`
lists the test that `live-tests.md` runs.
- `cargo run -p nemoclaw-build -- fern check`: 0 errors.
`nemoclaw-build`'s `docs::` tests pass.
gaveezy added a commit that referenced this pull request Oct 12, 2026
testing.md and integration-tests.md said the lifecycle profile selects
Helm recovery tests in the nemoclaw-sdk library. #13002 moved those to
nemoclaw-e2e's helm_recovery module, and the only SDK test the profile now
selects is plan_and_apply_refuse_cluster_port_changes_with_separate_state_files.
That test builds its saved OpenTofu states from SDK internals, so it stays
in the SDK instead of moving behind test-scenarios hooks.

Name that test, its purpose and its run command, and list helm_recovery
with the other nemoclaw-e2e system-test modules.

Validation: .config/nextest.toml selects that test by name and the e2e
helm_recovery module by prefix. The test passes with a bundle built from
this branch. nemoclaw-build docs reports no link errors.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Hai Nguyen <[email protected]>
@wscurran wscurran added chore Build, CI, dependency, or tooling maintenance platform: k8s Affects Kubernetes deployments security area: security Security controls, permissions, secrets, or hardening and removed security labels 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: e2e End-to-end tests, nightly failures, or validation infrastructure area: kubernetes area: security Security controls, permissions, secrets, or hardening chore Build, CI, dependency, or tooling maintenance platform: k8s Affects Kubernetes deployments v1 NemoClaw v1 branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants