Skip to content

Commit ca4b1c7

Browse files
committed
test(e2e): isolate VM-specific smoke assertions
Signed-off-by: Evan Lezar <elezar@nvidia.com>
1 parent 72b9c4a commit ca4b1c7

5 files changed

Lines changed: 63 additions & 43 deletions

File tree

‎TESTING.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@ Suites:
153153
- VM suite (`--features e2e-vm`) - runs e2e tests on a VM.
154154
- Kubernetes credential-driver suite (`--features e2e-kubernetes-credential-drivers`) - targeted Kubernetes Secrets and Vault provider credential storage coverage.
155155

156+
VM overlay and TLS-key permission assertions run only in the VM suite; the
157+
driver-neutral smoke test does not include them.
158+
156159
GPU device-selection tests compare OpenShell sandboxes against a plain Docker or
157160
Podman container that requests `--device nvidia.com/gpu=all`. The probe image
158161
defaults to the image used by the `gateway` stage in

‎e2e/rust/Cargo.toml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ name = "oidc_pkce"
4141
path = "tests/oidc_pkce.rs"
4242
required-features = ["e2e-oidc-pkce"]
4343

44+
[[test]]
45+
name = "vm_overlay"
46+
path = "tests/vm_overlay.rs"
47+
required-features = ["e2e-vm"]
48+
4449
[[test]]
4550
name = "custom_image"
4651
path = "tests/custom_image.rs"

‎e2e/rust/e2e-vm.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,6 @@ fi
371371
# The CLI uses the raw endpoint but still resolves matching metadata so it
372372
# can find the mTLS client bundle.
373373

374-
export OPENSHELL_E2E_EXPECT_VM_OVERLAY=1
375374
export OPENSHELL_E2E_DRIVER="vm"
376375
export OPENSHELL_E2E_VM_STATE_DIR="${RUN_STATE_DIR}"
377376
e2e_export_gateway_restart_metadata \
@@ -405,5 +404,6 @@ if [ -n "${E2E_TEST_OVERRIDE}" ]; then
405404
else
406405
run_e2e_test smoke
407406
run_e2e_test host_gateway_alias
407+
run_e2e_test vm_overlay
408408
run_e2e_test vm_gateway_start
409409
fi

‎e2e/rust/tests/smoke.rs‎

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,6 @@ async fn gateway_smoke() {
6868
sb.create_output,
6969
);
7070

71-
if std::env::var_os("OPENSHELL_E2E_EXPECT_VM_OVERLAY").is_some() {
72-
assert_vm_overlay_root(&sb.name).await;
73-
}
74-
7571
// ── 3. Verify the sandbox appeared in the list ───────────────────
7672
let mut list_cmd = openshell_cmd();
7773
list_cmd
@@ -99,41 +95,3 @@ async fn gateway_smoke() {
9995
// ── 4. Cleanup ───────────────────────────────────────────────────
10096
sb.cleanup().await;
10197
}
102-
103-
async fn assert_vm_overlay_root(sandbox_name: &str) {
104-
let script = concat!(
105-
"set -eu; ",
106-
"test \"$(stat -f -c %T /)\" = \"overlayfs\"; ",
107-
"printf \"overlay-write\\n\" > /sandbox/overlay-check; ",
108-
"test \"$(cat /sandbox/overlay-check)\" = \"overlay-write\"; ",
109-
"if [ -e /opt/openshell/tls/tls.key ]; then ",
110-
"test \"$(stat -c %a /opt/openshell/tls/tls.key)\" = \"600\"; ",
111-
"fi; ",
112-
"echo vm-overlay-ok",
113-
);
114-
115-
let mut exec_cmd = openshell_cmd();
116-
exec_cmd
117-
.args(["sandbox", "exec", "--name", sandbox_name, "--no-tty", "--"])
118-
.arg("sh")
119-
.arg("-lc")
120-
.arg(script)
121-
.stdout(Stdio::piped())
122-
.stderr(Stdio::piped());
123-
124-
let output = exec_cmd
125-
.output()
126-
.await
127-
.expect("failed to run VM overlay assertion");
128-
let combined = strip_ansi(&format!(
129-
"{}{}",
130-
String::from_utf8_lossy(&output.stdout),
131-
String::from_utf8_lossy(&output.stderr),
132-
));
133-
134-
assert!(
135-
output.status.success() && combined.contains("vm-overlay-ok"),
136-
"VM overlay assertion failed (status {:?}):\n{combined}",
137-
output.status.code(),
138-
);
139-
}

‎e2e/rust/tests/vm_overlay.rs‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
//! VM-driver-specific assertions for the sandbox root filesystem.
5+
6+
use std::process::Stdio;
7+
8+
use openshell_e2e::harness::binary::openshell_cmd;
9+
use openshell_e2e::harness::output::strip_ansi;
10+
use openshell_e2e::harness::sandbox::SandboxGuard;
11+
12+
#[tokio::test]
13+
async fn vm_overlay() {
14+
let mut sandbox = SandboxGuard::create(&["--", "echo", "vm-sandbox-ready"])
15+
.await
16+
.expect("sandbox create should succeed");
17+
18+
let script = concat!(
19+
"set -eu; ",
20+
"test \"$(stat -f -c %T /)\" = \"overlayfs\"; ",
21+
"printf \"overlay-write\\n\" > /sandbox/overlay-check; ",
22+
"test \"$(cat /sandbox/overlay-check)\" = \"overlay-write\"; ",
23+
"if [ -e /opt/openshell/tls/tls.key ]; then ",
24+
"test \"$(stat -c %a /opt/openshell/tls/tls.key)\" = \"600\"; ",
25+
"fi; ",
26+
"echo vm-overlay-ok",
27+
);
28+
29+
let mut exec_cmd = openshell_cmd();
30+
exec_cmd
31+
.args(["sandbox", "exec", "--name", &sandbox.name, "--no-tty", "--"])
32+
.arg("sh")
33+
.arg("-lc")
34+
.arg(script)
35+
.stdout(Stdio::piped())
36+
.stderr(Stdio::piped());
37+
38+
let output = exec_cmd
39+
.output()
40+
.await
41+
.expect("failed to run VM overlay assertion");
42+
let combined = strip_ansi(&format!(
43+
"{}{}",
44+
String::from_utf8_lossy(&output.stdout),
45+
String::from_utf8_lossy(&output.stderr),
46+
));
47+
assert!(
48+
output.status.success() && combined.contains("vm-overlay-ok"),
49+
"VM overlay assertion failed (status {:?}):\n{combined}",
50+
output.status.code(),
51+
);
52+
53+
sandbox.cleanup().await;
54+
}

0 commit comments

Comments
 (0)