mirror of
https://github.com/NVIDIA/OpenShell.git
synced 2026-10-21 06:11:31 +08:00
* test(e2e): keep lifecycle sandboxes running Signed-off-by: Evan Lezar <elezar@nvidia.com> * test(e2e): cover sandbox terminal lifecycle semantics Signed-off-by: Drew Newberry <anewberry@nvidia.com> * test(e2e): synchronize detached main exit checks Signed-off-by: Drew Newberry <anewberry@nvidia.com> --------- Signed-off-by: Evan Lezar <elezar@nvidia.com> Signed-off-by: Drew Newberry <anewberry@nvidia.com> Co-authored-by: Drew Newberry <anewberry@nvidia.com>
58 lines
1.8 KiB
Rust
58 lines
1.8 KiB
Rust
// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
//! VM-driver-specific assertions for the sandbox root filesystem.
|
|
|
|
use std::process::Stdio;
|
|
|
|
use openshell_e2e::harness::binary::openshell_cmd;
|
|
use openshell_e2e::harness::output::strip_ansi;
|
|
use openshell_e2e::harness::sandbox::SandboxGuard;
|
|
|
|
#[tokio::test]
|
|
async fn vm_overlay() {
|
|
let mut sandbox = SandboxGuard::create_keep(
|
|
&["sh", "-c", "echo vm-sandbox-ready; exec sleep infinity"],
|
|
"vm-sandbox-ready",
|
|
)
|
|
.await
|
|
.expect("sandbox create should start a durable main process");
|
|
|
|
let script = concat!(
|
|
"set -eu; ",
|
|
"test \"$(stat -f -c %T /)\" = \"overlayfs\"; ",
|
|
"printf \"overlay-write\\n\" > /sandbox/overlay-check; ",
|
|
"test \"$(cat /sandbox/overlay-check)\" = \"overlay-write\"; ",
|
|
"if [ -e /opt/openshell/tls/tls.key ]; then ",
|
|
"test \"$(stat -c %a /opt/openshell/tls/tls.key)\" = \"600\"; ",
|
|
"fi; ",
|
|
"echo vm-overlay-ok",
|
|
);
|
|
|
|
let mut exec_cmd = openshell_cmd();
|
|
exec_cmd
|
|
.args(["sandbox", "exec", "--name", &sandbox.name, "--no-tty", "--"])
|
|
.arg("sh")
|
|
.arg("-lc")
|
|
.arg(script)
|
|
.stdout(Stdio::piped())
|
|
.stderr(Stdio::piped());
|
|
|
|
let output = exec_cmd
|
|
.output()
|
|
.await
|
|
.expect("failed to run VM overlay assertion");
|
|
let combined = strip_ansi(&format!(
|
|
"{}{}",
|
|
String::from_utf8_lossy(&output.stdout),
|
|
String::from_utf8_lossy(&output.stderr),
|
|
));
|
|
assert!(
|
|
output.status.success() && combined.contains("vm-overlay-ok"),
|
|
"VM overlay assertion failed (status {:?}):\n{combined}",
|
|
output.status.code(),
|
|
);
|
|
|
|
sandbox.cleanup().await;
|
|
}
|