use std::time::Duration;
use microsandbox::Sandbox;
use test_utils::msb_test;
#[msb_test]
async fn shutdown_control_id_zero_stops_sandbox() {
let name = "correlation-shutdown-id-zero";
let sandbox = Sandbox::builder(name)
.image("mirror.gcr.io/library/alpine")
.cpus(1)
.memory(256)
.replace()
.create()
.await
.expect("create sandbox");
let stop_result = tokio::time::timeout(Duration::from_secs(30), sandbox.stop()).await;
if stop_result.is_err() {
if let Ok(h) = Sandbox::get(name).await {
let _ = h.kill().await;
let _ = h.remove().await;
}
}
Sandbox::remove(name).await.ok();
stop_result
.expect("stop timed out; relay likely rejected core.shutdown id 0")
.expect("stop failed");
}