Skip to content

Commit f26e340

Browse files
test(sandbox): add the first testkit suite and run it in Branch E2E
Give new end-to-end tests a home and a CI lane. New tests go in testkit; the old suites take fixes only. - tests/suites/sandbox is a testkit suite workspace. It starts with the long_running_exec_delete test, adapted from the sandbox-lifecycle suite in #4629. Its README holds the guidance on what a test may assert. - The suite builds into a Nix test archive with `--locked`, and a tmachine testsuite and playbook run it against the gateway the installer registered. testkit finds that gateway the way the CLI does, so no target file is needed. The playbook waits for the gateway first, so an unavailable gateway is one environment failure rather than N test failures. It runs nextest serially with a slow-timeout that terminates hung tests, and fails the lane when fewer tests run than expected. - Branch E2E runs it in a `testkit-integration` job on Ubuntu with Docker and the Debian package. It isn't part of the Core E2E result yet. - The alignment check runs in `rust:lockfiles:check` and the Cargo lockfiles CI job, with its tests in `mise run test`, and enrolls tests/testkit and the new suite. A PR that bumps a shared crate in the root Cargo.lock now needs `uv run tasks/scripts/check_cargo_lockfile_alignment.py --fix`. - `mise run e2e:testkit` (and `e2e:testkit:podman`) run the suite against an ephemeral local gateway. - fmt and clippy cover the new workspace in Branch Checks and the mise tasks. Co-authored-by: Evan Lezar <elezar@nvidia.com> Signed-off-by: Matthew Grossman <mgrossman@nvidia.com>
1 parent 400852c commit f26e340

13 files changed

Lines changed: 4605 additions & 3 deletions

File tree

‎.github/workflows/branch-checks.yml‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ jobs:
222222
cargo fmt --manifest-path examples/supervisor-middleware-content-guard/Cargo.toml --all -- --check
223223
cargo fmt --manifest-path examples/isolation-backend-v8/Cargo.toml --all -- --check
224224
cargo fmt --manifest-path tests/testkit/Cargo.toml --all -- --check
225+
cargo fmt --manifest-path tests/suites/sandbox/Cargo.toml --all -- --check
225226
226227
cargo-lockfiles:
227228
name: Cargo lockfiles
@@ -239,7 +240,9 @@ jobs:
239240

240241
- name: Verify Cargo lockfiles
241242
shell: nix develop -c bash -euo pipefail {0}
242-
run: tasks/scripts/check-cargo-lockfiles.sh
243+
run: |
244+
tasks/scripts/check-cargo-lockfiles.sh
245+
uv run tasks/scripts/check_cargo_lockfile_alignment.py
243246
244247
rust-lint:
245248
name: Rust lint (${{ matrix.system }})
@@ -279,6 +282,7 @@ jobs:
279282
cargo clippy --locked --manifest-path examples/supervisor-middleware-content-guard/Cargo.toml --all-targets -- -D warnings
280283
cargo clippy --locked --manifest-path examples/isolation-backend-v8/Cargo.toml --all-targets -- -D warnings
281284
cargo clippy --locked --manifest-path tests/testkit/Cargo.toml --all-targets -- -D warnings
285+
cargo clippy --locked --manifest-path tests/suites/sandbox/Cargo.toml --all-targets -- -D warnings
282286
283287
rust-test:
284288
name: Rust test (${{ matrix.system }})

‎.github/workflows/branch-e2e.yml‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,24 @@ jobs:
261261
{"environment":"fedora-podman-rootless","installer":"rpm","testsuite":"conformance"}
262262
]
263263
264+
# Run suites written on testkit (tests/testkit). New end-to-end tests go here;
265+
# the older suites above take fixes only.
266+
testkit-integration:
267+
needs: prepare-integration
268+
permissions:
269+
actions: read
270+
contents: read
271+
packages: read
272+
uses: ./.github/workflows/integration-runner.yml
273+
with:
274+
category: testkit
275+
source-sha: ${{ needs.prepare-integration.outputs.source_sha }}
276+
integration-inputs-artifact-id: ${{ needs.prepare-integration.outputs.integration_inputs_artifact_id }}
277+
test-matrix: >-
278+
[
279+
{"environment":"ubuntu-docker-rootful","installer":"deb","testsuite":"sandbox-lifecycle"}
280+
]
281+
264282
# Run feature-specific integration tests:
265283
feature-specific-integration:
266284
needs: prepare-integration

‎TESTING.md‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ python/openshell/ # Python unit tests (*_test.py suffix)
1717
e2e/python/ # Python E2E tests (test_*.py prefix)
1818
e2e/rust/ # Rust CLI E2E tests
1919
tests/testkit/ # Support library for SDK-driven E2E suites
20+
tests/suites/sandbox/ # E2E suites written on testkit
2021
```
2122

2223
## Rust Tests
@@ -139,6 +140,30 @@ gateway the same way the CLI does, through `OPENSHELL_GATEWAY`,
139140
[tests/testkit/README.md](tests/testkit/README.md) for how to write and run
140141
tests.
141142

143+
**New end-to-end tests go in testkit.** The older suites under
144+
`tests/suites/conformance`, `features` and `drivers` and the `e2e/` suites take
145+
fixes only. Suites live under `tests/suites/<family>/`, for example
146+
`tests/suites/sandbox/`, and each family is its own Cargo workspace with its own
147+
lockfile. Run them against a local Docker gateway with:
148+
149+
```shell
150+
mise run e2e:testkit
151+
```
152+
153+
CI runs them in the `testkit-integration` job of Branch E2E (label `test:e2e`),
154+
through a tmachine lane that installs the Debian package. The suite's playbook
155+
fails the lane if fewer tests run than it expects, so raise
156+
`suite_expected_tests` in
157+
`tests/ansible/playbooks/suites/sandbox-lifecycle.yaml` when you add a
158+
test.
159+
160+
Workspaces that build root crates through path dependencies must lock shared
161+
crates at the versions in the root `Cargo.lock`; otherwise CI can build against
162+
dependencies the Nix toolchain doesn't support. `mise run rust:lockfiles:check`
163+
verifies this, and `uv run tasks/scripts/check_cargo_lockfile_alignment.py --fix`
164+
re-locks a workspace from the root lockfile. Add new testkit workspaces to
165+
`ALIGNED_WORKSPACES` in that script.
166+
142167
### Python E2E (`e2e/python/`)
143168

144169
`mise run e2e:python` builds `openshell/e2e-python:dev` from

‎tasks/rust.toml‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@ run_windows = "powershell -NoProfile -ExecutionPolicy Bypass -File tasks/scripts
1818
hide = true
1919

2020
["rust:lockfiles:check"]
21-
description = "Verify all tracked Cargo lockfiles are current"
22-
run = "tasks/scripts/check-cargo-lockfiles.sh"
21+
description = "Verify all tracked Cargo lockfiles are current and aligned with the root"
22+
run = [
23+
"tasks/scripts/check-cargo-lockfiles.sh",
24+
"uv run tasks/scripts/check_cargo_lockfile_alignment.py",
25+
]
2326
run_windows = "powershell -NoProfile -ExecutionPolicy Bypass -File tasks/scripts/check-cargo-lockfiles.ps1"
2427
hide = true
2528

@@ -34,6 +37,7 @@ run = [
3437
"cargo clippy --manifest-path examples/supervisor-middleware-content-guard/Cargo.toml --all-targets -- -D warnings",
3538
"cargo clippy --manifest-path examples/isolation-backend-v8/Cargo.toml --all-targets -- -D warnings",
3639
"cargo clippy --manifest-path tests/testkit/Cargo.toml --all-targets -- -D warnings",
40+
"cargo clippy --manifest-path tests/suites/sandbox/Cargo.toml --all-targets -- -D warnings",
3741
]
3842
run_windows = "powershell -NoProfile -ExecutionPolicy Bypass -File tasks/scripts/windows-msvc.ps1 lint native"
3943
hide = true
@@ -47,6 +51,7 @@ run = [
4751
"cargo fmt --manifest-path examples/supervisor-middleware-content-guard/Cargo.toml --all",
4852
"cargo fmt --manifest-path examples/isolation-backend-v8/Cargo.toml --all",
4953
"cargo fmt --manifest-path tests/testkit/Cargo.toml --all",
54+
"cargo fmt --manifest-path tests/suites/sandbox/Cargo.toml --all",
5055
]
5156
hide = true
5257

@@ -59,6 +64,7 @@ run = [
5964
"cargo fmt --manifest-path examples/supervisor-middleware-content-guard/Cargo.toml --all -- --check",
6065
"cargo fmt --manifest-path examples/isolation-backend-v8/Cargo.toml --all -- --check",
6166
"cargo fmt --manifest-path tests/testkit/Cargo.toml --all -- --check",
67+
"cargo fmt --manifest-path tests/suites/sandbox/Cargo.toml --all -- --check",
6268
]
6369
hide = true
6470

‎tasks/test.toml‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ depends = [
2323
"test:docs-website",
2424
"test:docs-nav",
2525
"test:maintainer-approval",
26+
"test:cargo-lockfile-alignment",
2627
]
2728

2829
["test:docs-website"]
@@ -31,6 +32,10 @@ description = "Test the docs-website sync script"
3132
# dependencies and the script's runtime dependency, which live outside the project env.
3233
run = "uv run --no-project --with pytest --with pytest-asyncio --with pyyaml pytest tasks/scripts/sync_docs_website_test.py"
3334

35+
["test:cargo-lockfile-alignment"]
36+
description = "Test the Cargo lockfile alignment check"
37+
run = "uv run --no-project --with pytest pytest tasks/scripts/check_cargo_lockfile_alignment_test.py"
38+
3439
["test:docs-nav"]
3540
description = "Test the docs navigation check"
3641
run = "uv run --no-project --with pytest --with pytest-asyncio --with pyyaml pytest tasks/scripts/check_docs_nav_test.py"
@@ -160,6 +165,14 @@ run = "OPENSHELL_TEST_CONTAINER_ENGINE=docker e2e/with-docker-gateway.sh cargo t
160165
description = "Run the shared OCI image feature suite against a Podman-backed gateway"
161166
run = "OPENSHELL_TEST_CONTAINER_ENGINE=podman e2e/with-podman-gateway.sh cargo test --locked --manifest-path tests/suites/features/Cargo.toml -p openshell-test-feature-oci-image -- --test-threads 1 --nocapture"
162167

168+
["e2e:testkit"]
169+
description = "Run the testkit suites against a Docker-backed gateway"
170+
run = "e2e/with-docker-gateway.sh cargo nextest run --locked --manifest-path tests/suites/sandbox/Cargo.toml --workspace --test-threads 1 --no-fail-fast"
171+
172+
["e2e:testkit:podman"]
173+
description = "Run the testkit suites against a Podman-backed gateway"
174+
run = "e2e/with-podman-gateway.sh cargo nextest run --locked --manifest-path tests/suites/sandbox/Cargo.toml --workspace --test-threads 1 --no-fail-fast"
175+
163176
["e2e:rust:push"]
164177
description = "Run CLI conformance and policy e2e tests against a Docker gateway that pushes configuration"
165178
depends = ["e2e:conformance:build"]
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
---
5+
# Runs the testkit sandbox-lifecycle suite against the gateway the installer
6+
# registered. testkit finds that gateway the way the CLI does, so no target
7+
# file is needed.
8+
- name: Run the sandbox lifecycle suite
9+
hosts: all
10+
gather_facts: false
11+
vars:
12+
suite_root: /var/lib/openshell-sandbox-lifecycle/tests
13+
# Fail when the run executes fewer tests than this, so a dropped or
14+
# filtered-out test cannot pass silently. Raise it when a test is added.
15+
suite_expected_tests: 1
16+
suite_failed: >-
17+
{{ gateway_status is failed or suite_result.rc != 0 or
18+
(suite_tests_run | int) < (suite_expected_tests | int) }}
19+
suite_tests_run: >-
20+
{{ (suite_result.stderr | default('') | regex_findall('Summary \[[^\]]*\]\s+(\d+) tests? run') | first | default(0)) }}
21+
tasks:
22+
- name: Wait for SSH
23+
ansible.builtin.wait_for_connection:
24+
25+
- name: Create suite directory
26+
become: true
27+
ansible.builtin.file:
28+
path: "{{ suite_root }}"
29+
state: directory
30+
owner: tmachine
31+
group: tmachine
32+
mode: "0700"
33+
34+
- name: Extract suite bundle
35+
become: true
36+
ansible.builtin.unarchive:
37+
src: "{{ sandbox_lifecycle_test_bundle }}"
38+
dest: "{{ suite_root }}"
39+
owner: tmachine
40+
group: tmachine
41+
42+
- name: Check suite nextest archive
43+
ansible.builtin.stat:
44+
path: "{{ suite_root }}/tests.tar.zst"
45+
register: suite_archive
46+
47+
- name: Require suite nextest archive
48+
ansible.builtin.assert:
49+
that:
50+
- suite_archive.stat.isreg | default(false)
51+
fail_msg: Sandbox lifecycle test bundle did not contain tests.tar.zst
52+
53+
- name: Resolve installed OpenShell CLI
54+
ansible.builtin.command:
55+
argv:
56+
- /bin/sh
57+
- -c
58+
- command -v openshell
59+
register: openshell_cli
60+
changed_when: false
61+
62+
# Report a gateway that never came up as one environment failure instead of
63+
# as every test failing.
64+
- name: Wait for the registered gateway
65+
ansible.builtin.command:
66+
argv: [timeout, 10s, "{{ openshell_cli.stdout }}", status, --output, json]
67+
register: gateway_status
68+
changed_when: false
69+
until: >-
70+
gateway_status.rc == 0 and
71+
(gateway_status.stdout | from_json).status == 'connected'
72+
retries: 60
73+
delay: 5
74+
ignore_errors: true
75+
76+
# The bundle carries no nextest config, so set the timeouts here. A hung
77+
# test is killed after two minutes instead of holding the lane until the job
78+
# times out.
79+
- name: Write nextest config
80+
ansible.builtin.copy:
81+
dest: "{{ suite_root }}/nextest.toml"
82+
mode: "0600"
83+
content: |
84+
[profile.default]
85+
slow-timeout = { period = "30s", terminate-after = 4 }
86+
become: true
87+
become_user: tmachine
88+
89+
- name: Run the suite
90+
ansible.builtin.command:
91+
argv:
92+
- cargo-nextest
93+
- nextest
94+
- run
95+
- --config-file
96+
- "{{ suite_root }}/nextest.toml"
97+
- --archive-file
98+
- "{{ suite_root }}/tests.tar.zst"
99+
- --workspace-remap
100+
- "{{ suite_root }}"
101+
- --no-capture
102+
# Tests share one gateway and the guest has 4 GiB; run them serially
103+
# whatever --no-capture implies.
104+
- --test-threads
105+
- "1"
106+
- --no-fail-fast
107+
environment:
108+
HOME: /home/tmachine
109+
OPENSHELL_BIN: "{{ openshell_cli.stdout }}"
110+
register: suite_result
111+
changed_when: false
112+
failed_when: false
113+
when: gateway_status is succeeded
114+
115+
- name: Show suite diagnostics
116+
ansible.builtin.debug:
117+
var: suite_result
118+
when: suite_failed | bool
119+
120+
- name: Collect OpenShell gateway diagnostics
121+
ansible.builtin.include_role:
122+
name: openshell_diagnostics
123+
when: suite_failed | bool
124+
125+
- name: Require a connected gateway
126+
ansible.builtin.assert:
127+
that:
128+
- gateway_status is succeeded
129+
fail_msg: OpenShell gateway did not connect before the suite; see gateway diagnostics
130+
131+
- name: Require suite success
132+
ansible.builtin.assert:
133+
that:
134+
- suite_result.rc == 0
135+
fail_msg: Sandbox lifecycle suite failed
136+
137+
- name: Require the expected number of tests
138+
ansible.builtin.assert:
139+
that:
140+
- (suite_tests_run | int) >= (suite_expected_tests | int)
141+
fail_msg: >-
142+
Sandbox lifecycle suite ran {{ suite_tests_run }} tests; expected at
143+
least {{ suite_expected_tests }}

‎tests/artifacts.nix‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ let
5858
mkdir -p "$(dirname "$output")"
5959
cd "$root"
6060
cargo nextest archive \
61+
--locked \
6162
--manifest-path "$manifest_path" \
6263
--target ${target} \
6364
-p ${package} \
@@ -90,6 +91,14 @@ let
9091
target = muslToolchain.target;
9192
output = "artifacts/test-archives/${muslToolchain.target}/openshell-conformance-tests.tar";
9293
};
94+
sandboxLifecycleArchive = mkTestArchive {
95+
name = "sandbox-lifecycle";
96+
workspacePath = "tests/suites/sandbox";
97+
manifestPath = "tests/suites/sandbox/Cargo.toml";
98+
package = "openshell-test-sandbox-lifecycle";
99+
target = muslToolchain.target;
100+
output = "artifacts/test-archives/${muslToolchain.target}/sandbox-lifecycle-tests.tar";
101+
};
93102
providerRefreshKeycloakArchive = mkTestArchive {
94103
name = "provider-refresh-keycloak";
95104
workspacePath = "tests/suites/features";
@@ -317,13 +326,15 @@ rec {
317326
name = "build-artifacts-test-archives";
318327
runtimeInputs = [
319328
conformanceTestArchive
329+
sandboxLifecycleArchive
320330
providerRefreshKeycloakArchive
321331
ociImageArchive
322332
podmanDriverArchive
323333
podmanE2eArchive
324334
];
325335
text = ''
326336
build-openshell-conformance-test-archive
337+
build-sandbox-lifecycle-test-archive
327338
build-provider-refresh-keycloak-test-archive
328339
build-oci-image-test-archive
329340
build-podman-driver-test-archive

‎tests/config.nix‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,13 @@ let
162162
openshell_conformance_test_bundle = "../artifacts/test-archives/${muslTarget}/openshell-conformance-tests.tar";
163163
};
164164
}
165+
{
166+
name = "sandbox-lifecycle";
167+
playbooks = [ "ansible/playbooks/suites/sandbox-lifecycle.yaml" ];
168+
inputs = {
169+
sandbox_lifecycle_test_bundle = "../artifacts/test-archives/${muslTarget}/sandbox-lifecycle-tests.tar";
170+
};
171+
}
165172
{
166173
name = "policy-advisor";
167174
playbooks = [ "ansible/playbooks/conformance/policy-advisor.yaml" ];

0 commit comments

Comments
 (0)