Skip to content

test(e2e): split the deployment lifecycle test into explicit scenarios - #13042

Merged
cv merged 2 commits into
NVIDIA:v1from
bowenzhu21:test/deployment-lifecycle-scenarios
Oct 12, 2026
Merged

cv merged 2 commits into
NVIDIA:v1from
bowenzhu21:test/deployment-lifecycle-scenarios

Conversation

@bowenzhu21

Copy link
Copy Markdown

Fixes #12530.

Failure

lifecycle() in crates/nemoclaw-e2e/tests/deployment.rs set up a deployment, ran the plan, apply, export, reapply, and destroy checks, and chose drift checks by inspecting each test's document: web search registrations when a search integration was bound, tool policies with more than one sandbox, native settings when the inference API, agent authentication, harness execution, or harness settings were set, and network policy drift, with its own setup change, when the policy was explicit. A test's body did not show which of these it ran.

Decision

Lifecycle::start owns the setup: the fixture gateway, image engine, secrets, progress recording, and deployment. The checks are named methods: apply, export_and_reapply_unchanged, assert_search_registration_drift, assert_tool_policy_drift, assert_native_settings_drift, and destroy. Each test calls the checks it exercises and asserts its own effect count, and each fault injection is still undone inside the check that makes it.

Since #12885 kept one system lifecycle per drift kind (#12906), no test has an explicit network policy, so the policy setup change and drift check are removed rather than kept unreachable. Lower layers cover explicit policies: the openshell contract tests apply the resources compiled from explicit-policy.yaml and read them back unchanged (#12908), explicit_policy_reaches_the_gateway_and_detects_drift checks policy drift in the provider, and policy_template_markers_remain_literal_in_opentofu_configuration checks the templated path the setup change wrote.

web_search_cli_export_reapply_and_destroy and tool_disclosure_cli_export_reapply_and_drift are renamed for the drift they check, and docs/contributing/integration-tests.md follows. All 24 tests keep their test and ignore attributes, and Lifecycle owns the same resources and drops them in the same order.

Validation

  • Each test runs the checks it ran before. With a marker in each branch of lifecycle() on v1 at 29bb057, sdk_apply_cli_export… reached no drift check, separate_agent_sandboxes… only tool policies, tool_disclosure… only native settings, and web_search… only search registrations, with 4, 7, 4, and 6 gateway effects. No test reached the explicit-policy setup or check. The new tests call the same checks and assert the same counts.
  • The other assertions moved unchanged. With self. and whitespace removed, the old and new code have the same 39 assertions and 8 fault injections and restores outside the explicit-policy check. The conditional effect count became one assertion per test.
  • The deployment suite passes before and after against one bundle. A single cargo ci bundle at 29bb057 served both runs on Linux ARM64: all 24 deployment:: tests passed before (168 s) and after (174 s).
  • cargo ci passes on Linux ARM64 (1,377 tests, 127 lifecycle tests).
  • CI passes on a fork run. CI / Bundle passes on Linux ARM64 and AMD64 with both live suites, macOS, and Windows, and every platform's lifecycle shards ran and passed all 24 deployment:: tests.

Signed-off-by: Bowen Zhu [email protected]

lifecycle() chose its drift checks by inspecting each test's document,
so a test's body did not say what it checked. Each of its four tests
reaches at most one drift check: web search registrations, tool
policies across sandboxes, or native settings.

Lifecycle::start now owns the setup, and each test calls its checks
explicitly: apply, export and unchanged reapply, its drift check, and
destroy. Each test asserts its own effect count. The explicit network
policy setup and drift check are removed because no remaining test has
an explicit policy. Two tests are renamed for the drift they check.

Signed-off-by: Bowen Zhu <[email protected]>
@copy-pr-bot

copy-pr-bot Bot commented Oct 12, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@cv
cv enabled auto-merge (squash) October 12, 2026 22:03
@cv cv added the v1 NemoClaw v1 branch label Oct 12, 2026
@cv
cv merged commit f0adf0c into NVIDIA:v1 Oct 12, 2026
cv pushed a commit that referenced this pull request Oct 13, 2026
…el services (#13058)

Docker-managed vLLM and Ollama services get CPU and memory limits, and a
service-level `updatePolicy` that stops plan and apply from replacing a
running model container unless the user opts in.

## Why

On `v1`, every managed model container on Docker runs with a fixed 104
GiB memory limit and no CPU cap.
An image, model, or serving change replaces the running container
without asking, so a routine re-apply, for example from automation that
bumps an image, can take a serving model down.

This PR also carries the fixes for the review findings on the limits
commit of #12736 (review at 487cfc8, items N1–N7):

| Finding | Problem | Fixed here by |
|---|---|---|
| CL-1 / N1 (medium) | Lowering `memoryLimitGiB` resized the running
model in place under `Preserve` and could OOM-kill it | A
`memory-limit-gib` label forces replacement, and
`preserve_docker_models` refuses an in-place memory decrease |
| CL-2 / N2 | The new default had no release note and no CLI hint |
Release-notes entry, and a `help` field on `DockerModelUpdateRefused`
naming `spec.services.<name>.updatePolicy` |
| CL-5 / N5 | A 1 s CFS period gave up to 1 s throttle stalls | 100 ms
period, `quota = millis × 100`, raised to the kernel's 1000 µs minimum |
| CL-6 / N6 | Docs said `Preserve` blocks limit changes when Docker
applied memory in place; no `/proc` watchdog caveat; no CFS period |
`inference.md`, `usage.md`, `provider.md` updated |
| CL-7 / N7 | Tests accepted the in-place memory update and never
checked provider refresh | Unit cases for memory decreases and Podman
with SSH placement; e2e steps for the stopped-container refresh and
memory refusal |

CL-3 and CL-4 concern the legacy `kubernetes.*` field migration, which
is not part of this split.

## What changes

- **Configuration.** `container.cpuLimitMillis` and
`container.memoryLimitGiB` on `kind: vllm` and `kind: ollama`, and a
per-service `updatePolicy` (`Preserve`, the default, or `Recreate`). The
new `ServiceUpdatePolicy` type lives in `services/update_policy.rs` and
is exported as `nemoclaw_sdk::services::ServiceUpdatePolicy`. The schema
default comes from `registry::constrain_schema`.
- **Validation.** An explicit memory limit must cover `sharedMemoryGiB`
under private IPC and the inline recipe's `preparationMemoryGiB`. A zero
CPU limit is refused before native container creation.
- **Docker compilation** (`docker_compute.rs`, `managed/spec.rs`).
- A CPU limit sets `cpu_period = 100000` and `cpu_quota = cpuLimitMillis
× 100` (at least 1000) in the OpenTofu resource and in the native
`HostConfig`.
  - A memory limit sets `memory` and `memory_swap`.
- Labels `nemoclaw.nvidia.com/cpu-limit-millis` (when a CPU limit is
set) and `nemoclaw.nvidia.com/memory-limit-gib` (when memory differs
from 104 GiB) force replacement. Without them, the pinned Docker
provider v4.6.0 would update limits in place, drop the CFS quota, and
could OOM-kill the model by lowering memory.
- Omitted limits add no CPU settings or labels and keep the 104 GiB
memory limit; `Process` omits `cpu_limit_millis` when unset, so existing
specifications serialize unchanged.
- **Update safety** (`deployment/runtime.rs`). `preserve_docker_models`
runs during runtime observation for plan and apply. Under `Preserve` it
refuses a plan that deletes a running or incompletely observed model
container, or lowers its `memory`/`memory_swap`, with the new
`Error::DockerModelUpdateRefused`. Missing containers, containers the
provider refreshes as stopped (`must_run = false`), deposed instances,
the gateway, and the Ollama proxy are not affected.
- **CLI.** The refusal carries a `help` line in text and JSON output
that names `spec.services.<name>.updatePolicy: Recreate` and links the
new docs section.
- **Docs.** New "Set Container Limits and Update Policy" section in
`docs/inference.md`; updates to `usage.md` (change table, Podman note),
`provider.md` (generated Docker attributes), `troubleshooting.md`, and a
release-notes entry. Schema and `docs/reference/configuration.md`
regenerated.

## Breaking or user-visible changes

- **Docker model updates default to `Preserve`.** Changing a managed
vLLM or Ollama service's image, model, serving settings,
`cpuLimitMillis`, or `memoryLimitGiB` now fails at plan and apply while
the container runs:

  ```
Docker model service 'qwen' is preserved by updatePolicy: Preserve;
replacing a running or incompletely observed container requires explicit
updatePolicy: Recreate, which permits downtime if the replacement cannot
start; resources retained
  ```

Set `spec.services.<name>.updatePolicy: Recreate` to allow the
replacement and its downtime. Changing only the policy does not restart
the container.
- Declaring `memoryLimitGiB: 104` (the default) does not replace an
existing container.
- Rust API: `managed::Process` gains `cpu_limit_millis: Option<u32>`,
and `Error` gains `DockerModelUpdateRefused { service }`.

## Test proof

`cargo ci` on linux_arm64 (aarch64, `CARGO_BUILD_JOBS=16`), tree
`b63292802` (commit `c8166f739`, on top of `642211537`, which merges
`v1` a5445c7):

```
ok tools in 0s
ok fmt in 1s
ok clippy in 21s
ok build in 37s
     Summary [  18.905s] 1392 tests run: 1392 passed, 177 skipped
ok test in 24s
ok schema in 0s
ok bundle in 64s
     Summary [ 424.928s] 129 tests run: 129 passed (1 slow), 49 skipped
ok lifecycle in 430s
All selected CI steps passed in 580s
```

The test step also ran 4 doctests, all passing.
`nemoclaw-build docs` (local link and heading check) also passes.
The slow test is `nemoclaw-provider::contract
service_readiness::standalone_proxy_readiness_rechecks_identity_and_credentials_without_sdk_or_gateway`
(10.3 s against its 10 s limit). This PR does not change that binary,
and `v1` runs the test in 9.9 s on this host.

### New tests: red on `v1`, green here

"v1 code" means every production file in this PR reset to `v1`
29bb057, with this PR's test files kept.
"Hunk removed" means the branch with one production hunk taken out or
disabled.
Each run was restored to the commit afterwards.

| Test | v1 code | Hunk removed (branch) | Branch |
|---|---|---|---|
|
`deployment::runtime::tests::docker_model_updates_preserve_running_containers_unless_recreation_is_explicit`
| FAIL: `updatePolicy` is an unknown field | FAIL without the
`preserve_docker_models` call; FAIL without the memory-decrease check
(CL-1) | PASS |
|
`managed::spec::tests::zero_cpu_limit_is_rejected_before_native_container_creation`
| FAIL: unknown field `cpu_limit_millis` | FAIL without the
`cpu_limit_millis != Some(0)` check | PASS |
|
`managed::spec::tests::legacy_service_process_keeps_its_fields_without_cpu_limit`
| does not compile (E0609, no field `cpu_limit_millis` on `Process`) |
FAIL without `skip_serializing_if` on `cpu_limit_millis` | PASS |
|
`runtime_compile::docker_model_limits_reach_opentofu_and_native_container_configuration`
| FAIL: `container.cpuLimitMillis` is an unknown field | FAIL without
the memory-limit label; FAIL without the CPU quota on the Docker
resource | PASS |
|
`runtime_compile::omitted_docker_model_limits_keep_independent_legacy_defaults`
| does not compile (E0609) | FAIL without the memory-limit label; FAIL
without `skip_serializing_if` | PASS |
|
`runtime_compile::docker_model_update_policy_does_not_change_runtime_resources`
| FAIL: `updatePolicy` is an unknown field | FAIL when the policy is
made to change the runtime process (a mutation; there is no hunk to
remove) | PASS |
|
`runtime_compile::portable_container_memory_limits_cover_shared_memory_and_recipe_preparation_on_docker`
| FAIL: `container.memoryLimitGiB` is an unknown field | FAIL without
`validate_memory` | PASS |
|
`formatting::tests::docker_model_refusal_names_the_service_update_policy_field`
(nemoclaw-cli) | does not compile (E0599, no variant
`DockerModelUpdateRefused`) | FAIL without the `help` arm | PASS |

Commands: `cargo nextest run --locked -p nemoclaw-sdk -p nemoclaw-cli
--profile ci -E 'test(=…)'` for the unit and integration tests.
Each "v1 code" run first compiled out the tests that cannot compile
there (`#[cfg(any())]`) so the rest of the binary could run.

### Lifecycle-only tests (`remote_service`, run with the bundle from
`cargo ci bundle`)

| Test | Branch | Time |
|---|---|---|
|
`remote_service::remote_model_reapply_and_drift_keep_bindings_and_stop_on_observation_failure`
| PASS | 85.6 s |
|
`remote_service::remote_ollama_recovers_reapplies_and_stops_on_observation_failure_keeping_data`
| PASS | 82.9 s |
|
`remote_service::managed_bearer_credentials_survive_recovery_reapply_and_replacement_outside_state`
| PASS | 73.4 s |
|
`remote_service::managed_bearer_cleanup_recovers_damage_keeps_bindings_and_teardown_accepts_both_identities`
| PASS | 73.0 s |
|
`remote_service::managed_pi_applies_without_generation_and_refused_sandbox_changes_keep_intent`
| PASS | 60.7 s |
|
`remote_service::remote_ollama_preserve_refuses_image_and_memory_changes_and_recreate_plans_replacement`
| PASS | 42.8 s |
|
`remote_service::remote_vllm_preserve_refuses_image_change_and_recreate_plans_replacement`
| PASS | 26.4 s |
|
`remote_service::partial_runtime_destroy_retains_storage_without_creating_network`
| PASS | 10.3 s |
|
`remote_service::partial_ollama_destroy_retains_storage_without_creating_network`
| PASS | 10.0 s |
|
`remote_service::unverified_ollama_images_are_checked_after_pull_before_storage`
| PASS | 9.2 s |
|
`remote_service::unverified_vllm_images_are_checked_after_pull_before_storage`
| PASS | 9.0 s |

Every scenario now deploys with `cpuLimitMillis` (1250 for vLLM, 10 for
Ollama) and `memoryLimitGiB: 64`.
What this PR adds to them:

- Each apply through the shared `Scenario::apply` helper checks
`CpuPeriod`, `CpuQuota`, `Memory` and `MemorySwap` in the container's
`HostConfig`, and its `memory-limit-gib` label, for vLLM and, in
`remote_ollama_preserve_…`, for Ollama.
- An image change (vLLM and Ollama) and a memory decrease (Ollama) are
refused at plan and apply, leaving the engine state, runtime state and
`intent.json` unchanged, then planned as a replacement under `Recreate`.
These steps run in their own scenarios, `remote_vllm_preserve_…` and
`remote_ollama_preserve_…`, each ending with the no-probe check, so
`remote_model_…` and `remote_ollama_recovers_…` keep close to `v1`'s
steps and time.
- A stopped vLLM container, which the provider refreshes as `must_run =
false`, is replaced under `Preserve`.
- The bearer key survives an image replacement under `Recreate`.

Reds: each run rebuilt the bundle with `cargo ci bundle` from the
modified tree, then ran `NEMOCLAW_TEST_BUNDLE=$PWD/dist/linux_arm64
cargo nextest run --locked --workspace --all-targets --profile lifecycle
--run-ignored only -E 'test(/^remote_service::/)'` on all 11
`remote_service` tests.

- **v1 code** (`v1` a5445c7 with its own bundle, and this branch's
`remote_service.rs`): all 11 fail at scenario setup, because `v1`
rejects `container.cpuLimitMillis` ("unknown fields are not allowed").
- **Without the `preserve_docker_models` call:**
`remote_vllm_preserve_…` and `remote_ollama_preserve_…` fail, because
the plan they expect to be refused succeeds. The other 9 pass:
`managed_bearer_credentials_…` uses `Recreate`, and `remote_model_…` and
`remote_ollama_recovers_…` no longer change the image or memory.
- **Without the memory-limit label:** the five scenarios that apply
through `Scenario::apply` (`remote_model_…`, both `…_preserve_…` tests,
`managed_bearer_cleanup_…` and `managed_pi_…`) fail the
`memory-limit-gib` label check after their first apply. In a diagnostic
run that applied `remote_ollama_preserve_…` without that check, it
failed because a memory decrease under `Recreate` plans an in-place
`["update"]`, not a replacement. That in-place update is the CL-1
failure.
- **With stopped containers also protected** (the `must_run != false`
clause removed): `remote_model_…` fails, because the plan for its
stopped container is refused with `DockerModelUpdateRefused`. The other
10 pass.

**Timing budget.**
On linux_amd64, this PR's first CI run took 91.3 s for
`remote_ollama_recovers_…`, over the 90 s per-test lifecycle limit in
`.config/test-budgets.yaml`, and 81.0 s for `remote_model_…`; `v1` runs
them there in 65.7–68.7 s and 67.5–68.7 s.
This PR had added an image change and a memory decrease to
`remote_ollama_recovers_…`, and `Preserve` refusals to
`remote_model_…`'s existing image-change step.
Those steps now run in `remote_vllm_preserve_…` and
`remote_ollama_preserve_…`, as #13042 split the deployment lifecycle
test into explicit scenarios; no limit changes.
In three runs of the `remote_service` tests on this host, interleaved
with `v1` a5445c7's:

| Test | This PR | `v1` | Estimate on linux_amd64 |
|---|---|---|---|
| `remote_model_…` | 85.0–85.3 s | 86.4–87.3 s | 67 s |
| `remote_ollama_recovers_…` | 86.0–87.0 s | 86.0–87.4 s | 67 s |
| `remote_ollama_preserve_…` | 42.7–43.1 s | — | 33–39 s |
| `remote_vllm_preserve_…` | 25.5–26.3 s | — | 20–24 s |

Each estimate multiplies this PR's time by `v1`'s linux_amd64 time over
its time here: 0.77–0.79 for the two existing tests, and 0.77–0.91 (the
range across `remote_service` tests) for the new ones.
CI runs the lifecycle suite in two slices with a 300 s budget each. Run
the same way here (`cargo ci lifecycle --partition slice:N/2`, twice
each), this branch's slices took 208.9–211.1 s and 218.0–226.6 s; `v1`'s
took 208.9–209.0 s and 198.7–201.7 s here and 201.6–206.0 s and
184.2–186.8 s on linux_amd64. Scaled the same way, this branch's slices
would take about 204 s and 206 s there.

## Depends on / merge order

- Base: `v1` (a5445c7 is merged into this branch). No dependencies;
merges in parallel with #13056, #13057 and #13059.
- It shares files with #13057 (`remote_service.rs`, `vllm/mod.rs`) and
#13059 (`formatting.rs`). `git merge-tree` of this branch with the
planning slices for #13056, #13057, #13059 and #13060 reports no
conflicts.
- #13061 needs this PR in `v1`, because its cluster settings use
`ServiceUpdatePolicy`. #13062 adds back the Kubernetes and OpenShift
wording removed from this PR's doc comments and docs, and the
`kubernetes.is_none()` guards in `preserve_docker_models`.

### Live evidence (not qualification; #12732 stays open)

`split/3-docker-container-limits` @ `fe97763b7`, this branch's
`dist/linux_arm64` bundle (`0.1.0-dev.2857ec70977bc92c`). 2026-10-12,
one GB300 (ARM64), local Docker engine, Docker managed gateway.

**Setup.** A copy of #12736's review deployment `docker-openclaw` with a
fresh UID and state directory, on 172.30.142.0/24 port 17842:
- managed Ollama `qwen3:0.6b`, profile `gb300`, image
`nc-prototype-ollama@sha256:dea377de…`;
- `container.cpuLimitMillis: 4000`, `container.memoryLimitGiB: 48`;
- an OpenClaw sandbox (image built from `split/8`; `image/` is identical
to `v1`).

| Check | Observed |
|---|---|
| Plan | `Plan incomplete · 6 known resource changes` |
| Apply | Ollama created in 1 s, agent runtime in 17 s. Apply ended
after 102 s with the known readiness message. |
| `docker inspect` of the model container | `CpuPeriod=100000`,
`CpuQuota=400000` (4000 millis × 100), `NanoCpus=0`,
`Memory=51539607552` (48 GiB), labels
`nemoclaw.nvidia.com/cpu-limit-millis=4000` and `memory-limit-gib=48`,
runtime `nvidia` |
| `memoryLimitGiB` 48 → 40 under the default `Preserve`: plan | EXIT 1:
`Docker model service 'qwen' is preserved by updatePolicy: Preserve;
replacing a running or incompletely observed container requires explicit
updatePolicy: Recreate, which permits downtime if the replacement cannot
start; resources retained`, plus the `DockerModelUpdateRefused` help
(below) |
| Same change: apply | EXIT 1: `No runtime resources changed.` plus the
same help |
| Container after the refused change | Same container ID; `Memory` still
48 GiB |
| Same change with `updatePolicy: Recreate` | 68 s. `ollama/qwen: delete
complete`, then `create complete`. New container ID with
`Memory=42949672960` (40 GiB), label `memory-limit-gib=40`,
`CpuQuota=400000` unchanged. The next plan: `No resource changes
planned.` |
| Destroy | `Destroy complete · 10s`; GPU back to 0 MiB |

The help printed at both plan and apply: `To replace the running model
container, set spec.services.qwen.updatePolicy: Recreate and apply
again; the model is unavailable until the replacement starts. See
docs/inference.md#set-container-limits-and-update-policy.`

Notes:
- Both applies ended with the known upstream "Fabric readiness could not
be established" (`fabric_health_unsupported`). This is not a failure of
this PR.
- Destroy retained the gateway-init container, the network and the
`gateway-data` and `ollama-qwen-data` volumes, as designed.

Split from #12736.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
@wscurran wscurran added area: e2e End-to-end tests, nightly failures, or validation infrastructure chore Build, CI, dependency, or tooling maintenance 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 chore Build, CI, dependency, or tooling maintenance v1 NemoClaw v1 branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants