summaryrefslogtreecommitdiffstats
path: root/src/sandbox
diff options
context:
space:
mode:
Diffstat (limited to 'src/sandbox')
-rw-r--r--src/sandbox/kata.rs35
1 files changed, 34 insertions, 1 deletions
diff --git a/src/sandbox/kata.rs b/src/sandbox/kata.rs
index 66f7cba..26e9acc 100644
--- a/src/sandbox/kata.rs
+++ b/src/sandbox/kata.rs
@@ -83,7 +83,7 @@ impl K8sSandboxProvisioner {
}
}
-pub struct K8sSandboxProvisioner {
+pub(crate) struct K8sSandboxProvisioner {
pub api: String,
pub bearer: String,
pub namespace: String,
@@ -447,4 +447,37 @@ mod tests {
assert!(started.elapsed() >= Duration::from_millis(900), "acquire gave up before the TTL");
assert!(err.to_string().contains("never dialed in"), "{err}");
}
+
+ // ------------------------------------------------------------------
+ // Moved verbatim from tests/kata.rs. It is an opt-in live tier, not a
+ // fixture test: it records its own absence when there is no /dev/kvm or no
+ // AUR_KATA_API, exactly as the vercmp live tier does. It constructs the
+ // provisioner field by field, which is the only reason that struct was
+ // nameable from outside; with the test here, it no longer needs to be.
+ // ------------------------------------------------------------------
+
+ #[test]
+ fn the_live_kata_tier_is_recorded_not_silently_absent() {
+ if !std::path::Path::new("/dev/kvm").exists() {
+ println!("note: no /dev/kvm on this host; the live kata tier is skipped, not passed");
+ return;
+ }
+ let Ok(api) = std::env::var("AUR_KATA_API") else {
+ println!("note: /dev/kvm present but AUR_KATA_API unset; live kata tier still skipped");
+ return;
+ };
+ let cfg = Config::default();
+ let prov = Arc::new(K8sSandboxProvisioner {
+ api,
+ bearer: std::env::var("AUR_KATA_TOKEN").unwrap_or_default(),
+ namespace: std::env::var("AUR_KATA_NS").unwrap_or_else(|_| "default".into()),
+ });
+ let backend = KataBackend::bind(&cfg, "0.0.0.0:9443", &std::env::var("AUR_AGENT_TOKEN").unwrap(), prov).unwrap();
+ let sbx = backend
+ .acquire(&SandboxSpec::new("extra-x86_64", "live", Duration::from_secs(300)))
+ .expect("live kata sandbox should lease");
+ let out = sbx.run(&crate::sandbox::Cmd::new(["/bin/echo", "kata"]), &mut |_| {}).unwrap();
+ assert!(out.success() && String::from_utf8_lossy(&out.stdout).contains("kata"));
+ sbx.destroy().unwrap();
+ }
}