diff options
| author | aur-build <aur-build@localhost> | 2026-11-19 15:57:39 +0000 |
|---|---|---|
| committer | aur-build <aur-build@localhost> | 2026-11-19 15:57:39 +0000 |
| commit | 94c318f13264bb3c00a9f3057ba2e1aafb57c9e4 (patch) | |
| tree | e3d9176822921a78402248d461c11ff652a1b0f8 /tests | |
| parent | 8dcdce879b51b19603d8163d8a9bfb5f61ff1558 (diff) | |
| download | aur-build-94c318f13264bb3c00a9f3057ba2e1aafb57c9e4.tar.gz aur-build-94c318f13264bb3c00a9f3057ba2e1aafb57c9e4.zip | |
sandbox: the kata lease path publishes a real package, and the config says what it means
The end-to-end claim of the seam, tested as one thing: `plain-make` detected,
approved, built and published through `KataBackend` + `LocalAgentProvisioner` —
a real `sandbox-agent` process, a real nonce-matched rendezvous, real frames —
with a VM being the only thing this host cannot provide. The index ends up
serving the package, the agent's output reaches the same log the SSE tail reads,
and the shim saw exactly one `makepkg`.
Documented where the project records such things: the enum and the refusal of an
unwired kind, the shared listener and the shared Kata backend, and the
`shared_workspace` assertion as a guard rather than a fix — the workspace sync is
still the unimplemented thing it was, and the config now says so at startup
instead of letting `makepkg` discover it.
Also reaped two unreaped `sandbox-agent` children in the remote tests, which was
the last clippy warning in the tree; `--all-targets` is now silent.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/kata.rs | 52 | ||||
| -rw-r--r-- | tests/remote_agent.rs | 4 |
2 files changed, 55 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. +} + diff --git a/tests/remote_agent.rs b/tests/remote_agent.rs index 22e803a..24e259e 100644 --- a/tests/remote_agent.rs +++ b/tests/remote_agent.rs @@ -44,7 +44,10 @@ fn a_full_build_runs_over_the_agent_protocol() { .expect("spawn sandbox-agent"); let out = pipeline::run_with(&ctx).unwrap(); + // Kill *and* reap: an unreaped child is a zombie the next test inherits, and + // clippy is right that a spawn nobody waits on is unfinished business. let _ = agent.kill(); + let _ = agent.wait(); assert!(matches!(out, pipeline::Outcome::Succeeded { .. }), "{out:?}"); // The agent-streamed output landed in the same file the SSE tail reads. @@ -161,6 +164,7 @@ fn a_dial_in_goes_to_whichever_backend_is_waiting() { let spec = SandboxSpec::new("extra-x86_64", "task", Duration::from_secs(10)); let sbx = second.acquire(&spec); let _ = agent.kill(); + let _ = agent.wait(); assert!(sbx.is_ok(), "the second backend must be able to take the dial-in: {:?}", sbx.err()); } |
