diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/db/mod.rs | 4 | ||||
| -rw-r--r-- | src/db/pkgbases.rs | 10 | ||||
| -rw-r--r-- | src/sandbox/kata.rs | 30 | ||||
| -rw-r--r-- | src/sandbox/remote.rs | 11 | ||||
| -rw-r--r-- | src/shims/mod.rs | 8 |
5 files changed, 50 insertions, 13 deletions
diff --git a/src/db/mod.rs b/src/db/mod.rs index e42bae4..992a2b6 100644 --- a/src/db/mod.rs +++ b/src/db/mod.rs @@ -52,8 +52,10 @@ pub use packages::{ index_version, our_package_names, }; pub use pkgbases::{ - Pkgbase, accepted_release_for, cas_accepted_release, get_pkgbase, get_pkgbase_by_id, set_aur_head, + Pkgbase, accepted_release_for, get_pkgbase, get_pkgbase_by_id, set_aur_head, }; +#[cfg(feature = "test-support")] +pub use pkgbases::cas_accepted_release; pub use publish_writes::{ NewRelease, accepted_pointer_in, artifact_path, cas_accepted_release_in, insert_package_in, insert_release_in, remove_index_packages_in, remove_package_by_name_in, diff --git a/src/db/pkgbases.rs b/src/db/pkgbases.rs index 8373024..0f711a7 100644 --- a/src/db/pkgbases.rs +++ b/src/db/pkgbases.rs @@ -81,6 +81,16 @@ pub fn set_aur_head(writer: &Writer, pkgbase_id: i64, head: &str, mirror: &str) } +/// Compare-and-set the accepted-release pointer. +/// +/// Test-tier only, and the reason is worth keeping next to it: production +/// performs this CAS inside a transaction through `cas_accepted_release_in`, +/// which is what `pipeline::publish` calls at publish.rs:208. This standalone +/// form takes a `Writer` and is called by nothing in the crate — `tests/db.rs` +/// alone pins that the pointer moves once and refuses the second time. The two +/// names differ by three characters, which is exactly how a name-match census +/// once credited this function with a production caller it never had. +#[cfg(feature = "test-support")] pub fn cas_accepted_release( writer: &Writer, pkgbase_id: i64, diff --git a/src/sandbox/kata.rs b/src/sandbox/kata.rs index 26e9acc..27005bd 100644 --- a/src/sandbox/kata.rs +++ b/src/sandbox/kata.rs @@ -1,7 +1,9 @@ use std::collections::HashMap; use std::io::BufReader; use std::net::{TcpListener, TcpStream}; +#[cfg(feature = "test-support")] use std::path::PathBuf; +#[cfg(feature = "test-support")] use std::process::{Child, Command}; use std::sync::atomic::{AtomicU64, Ordering}; use std::sync::{Arc, Mutex, OnceLock}; @@ -121,17 +123,27 @@ impl Provisioner for K8sSandboxProvisioner { } } +/// Provisions sandboxes by running the local `sandbox-agent` binary. +/// +/// Test-tier only. Production selects `K8sSandboxProvisioner` when the config +/// names an agent-sandbox backend (kata.rs:193); nothing in the crate ever +/// constructs this type. It exists so tests can drive the real agent protocol +/// against the shim binary without a cluster, which is a more valuable test +/// than the absence of one — so it is gated rather than deleted. +#[cfg(feature = "test-support")] pub struct LocalAgentProvisioner { pub bin: PathBuf, children: Mutex<HashMap<String, Child>>, } +#[cfg(feature = "test-support")] impl LocalAgentProvisioner { pub fn new(bin: impl Into<PathBuf>) -> Self { Self { bin: bin.into(), children: Mutex::new(HashMap::new()) } } } +#[cfg(feature = "test-support")] impl Provisioner for LocalAgentProvisioner { fn provision(&self, req: &ProvisionRequest) -> Result<()> { let child = Command::new(&self.bin) @@ -238,18 +250,12 @@ impl KataBackend { }) } - /// NOTE: `KataBackend::reclaim` used to sit here and called nothing but - /// `self.provisioner.reclaim`, which the pool already calls itself at the - /// reaping site. Nothing — not a test — ever called the wrapper, so it is - /// gone rather than gated. The census had credited it to `tests/kata.rs`, - /// where the TTL test implements the *trait's* `reclaim` on a null - /// provisioner: same word, different function. - /// Test-tier in practice — `tests/remote_agent.rs` drives a real agent - /// through it — but it is a plain accessor on a public type, so it is - /// left public rather than gated behind a feature. - pub fn local_addr(&self) -> &str { - &self.addr - } + // NOTE: `KataBackend::reclaim` used to sit here and called nothing but + // `self.provisioner.reclaim`, which the pool already calls itself at the + // reaping site. Nothing — not a test — ever called the wrapper, so it is + // gone rather than gated. The census had credited it to `tests/kata.rs`, + // where the TTL test implements the *trait's* `reclaim` on a null + // provisioner: same word, different function. fn nonce(&self) -> String { let n = self.counter.fetch_add(1, Ordering::SeqCst); diff --git a/src/sandbox/remote.rs b/src/sandbox/remote.rs index 2f5a1b7..c648843 100644 --- a/src/sandbox/remote.rs +++ b/src/sandbox/remote.rs @@ -22,6 +22,17 @@ impl RemoteBackend { Ok(Self { cfg: cfg.clone(), token: token.to_string(), addr: bound.local, queue: bound.rx }) } + /// The address the rendezvous listener actually bound to. + /// + /// Test-tier only. Production binds through `bound_listener` and hands the + /// address to the agent itself, so nothing in the crate asks for it back; + /// `tests/remote_agent.rs` needs it to point a real agent at the socket. + /// It is gated rather than left public because the census believed it had + /// production callers at two `listener.local_addr()` calls — std's method + /// on a `TcpListener`, in sibling files, which a name match cannot tell + /// apart from this one. That confusion is what `dotted_only` confirmation + /// in `tools/test-surface.py` now forces a human to resolve. + #[cfg(feature = "test-support")] pub fn local_addr(&self) -> &str { &self.addr } diff --git a/src/shims/mod.rs b/src/shims/mod.rs index 67c6640..fd515bc 100644 --- a/src/shims/mod.rs +++ b/src/shims/mod.rs @@ -130,6 +130,14 @@ fn forced_fail(tool: &str) -> bool { std::env::var("AUR_SHIM_FAIL").map(|v| v == tool).unwrap_or(false) } +/// Read back the shim's invocation log. +/// +/// Test-tier only. The shim *appends* to `invocations.jsonl` in production — +/// that is how a fake tool leaves evidence — but nothing in the crate reads the +/// file back; `called_with` below is the only reader and it is gated with this. +/// The census credited this function with production callers at the two lines +/// that name the *filename* in a string, which is not a call. +#[cfg(feature = "test-support")] pub fn invocations(dir: &Path) -> Vec<serde_json::Value> { let path = dir.join("invocations.jsonl"); match std::fs::read_to_string(path) { |
