summaryrefslogtreecommitdiffstats
path: root/tests/kata.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/kata.rs')
-rw-r--r--tests/kata.rs52
1 files changed, 51 insertions, 1 deletions
diff --git a/tests/kata.rs b/tests/kata.rs
index 12aa607..29a6f29 100644
--- a/tests/kata.rs
+++ b/tests/kata.rs
@@ -14,7 +14,7 @@ use aur_build::config::Config;
use aur_build::error::Result;
use aur_build::sandbox::kata::{KataBackend, LocalAgentProvisioner, ProvisionRequest, Provisioner};
use aur_build::sandbox::{Cmd, SandboxBackend, SandboxSpec};
-use common::shim_dir;
+use common::{env_with_fixture, shim_dir};
#[test]
fn a_provisioned_sandbox_rendezvous_and_runs_a_command() {
@@ -175,3 +175,53 @@ fn a_loopback_config_never_becomes_agent_sandbox_or_vice_versa() {
assert!(!id.contains("kata@"), "loopback must not report kata: {id}");
assert!(!id.contains("remote@"), "loopback must not report remote: {id}");
}
+
+/// The seam's whole claim, tested as one thing: a real package built and
+/// published through the kata lease path — a real `sandbox-agent` process, a
+/// real nonce-matched rendezvous, real frames — with a VM being the only thing
+/// this host cannot provide. If the lease path and the loopback path disagree
+/// about anything, this is where it shows.
+#[test]
+fn a_fixture_builds_and_publishes_through_the_kata_lease_path() {
+ let (env, _fx) = env_with_fixture("plain-make");
+ aur_build::watch::detect::check_pkgbase(&env.cfg, &env.db, "plain-make").unwrap();
+ let c = aur_build::review::candidates::pending_candidates(&env.db).unwrap().remove(0);
+ let dd = aur_build::review::diff::render_and_store(&env.db, &env.cfg, &c).unwrap();
+ aur_build::review::approve::approve(&env.db, "tester", c.id, &c.identity_hash, &dd, None).unwrap();
+ let c = aur_build::review::candidates::candidate_by_id(&env.db, c.id).unwrap().unwrap();
+ let id = aur_build::pipeline::enqueue_for_candidate(&env.cfg, &env.db, &c).unwrap();
+
+ let mut ctx = aur_build::pipeline::Ctx::new(&env.cfg, &env.db, &id).unwrap();
+ let prov = Arc::new(LocalAgentProvisioner::new(shim_dir().join("sandbox-agent")));
+ let backend = KataBackend::bind(&env.cfg, "127.0.0.1:0", "kata-e2e", prov).unwrap();
+ ctx.backend = Arc::new(backend);
+
+ let out = aur_build::pipeline::run_with(&ctx).unwrap();
+ let release = match out {
+ aur_build::pipeline::Outcome::Succeeded { release_id } => release_id,
+ other => panic!("the kata path must publish, got {other:?}"),
+ };
+ assert!(release > 0);
+
+ // Published, not merely built: the served index now names the package.
+ let world = aur_build::pipeline::publish::index_world(&env.db).unwrap();
+ assert!(
+ world.iter().any(|w| w.pkgbase == "plain-make" && w.version == "1.0-1"),
+ "the index must serve what the kata build produced: {world:?}"
+ );
+
+ // And it ran inside the leased sandbox: the agent streamed the build output
+ // over the wire into the same log file the SSE tail reads, and the shim saw
+ // exactly one makepkg.
+ let log = std::fs::read_to_string(env.cfg.build_log_path(&id)).unwrap();
+ assert!(log.contains("Making package"), "agent output must reach the log:\n{log}");
+ let shimlog = env.cfg.hooks.shim_dir.clone().unwrap();
+ assert_eq!(aur_build::shims::called_with(&shimlog, "makepkg", ""), 1);
+
+ // Deliberately no assertion that the sandbox is gone: the pipeline never
+ // calls `destroy`, and the design says the TTL is the guarantee and destroy
+ // is courtesy (wire.rs). The lease window bounds how long a box lives, not
+ // a teardown call — which is worth knowing, because it means a busy hub
+ // holds up to `steps x builds` sandboxes until their TTL bites.
+}
+