test(rootfs): pin the arch and locate the keg tools

The cache-seeding tests seeded entry names under amd64 but resolved
the request against the host arch, so on an arm64 host the lookup
missed and the tests walked into the network path. Requests now pin
arch, matching the seeded names on any host. The tool gate uses
find_tool: on macOS the e2fsprogs binaries are keg-only, never on
PATH.
This commit is contained in:
vhaudiquet committed 2026-10-31 18:10:32 -05:00
1 parent 84ccff0157
commit 92ff76a1b6
1 file changed
+18 -12
+18 -12
View File
@@ -405,10 +405,8 @@ mod tests {
use crate::progress::NoProgress; use crate::progress::NoProgress;
fn have_e2fsprogs() -> bool { fn have_e2fsprogs() -> bool {
std::process::Command::new("mkfs.ext4") crate::utils::find_tool("mkfs.ext4").is_some()
.arg("-V") && crate::utils::find_tool("debugfs").is_some()
.output()
.is_ok()
} }
#[test] #[test]
@@ -447,9 +445,10 @@ mod tests {
.unwrap(); .unwrap();
tar.into_inner().unwrap().finish().unwrap(); tar.into_inner().unwrap().finish().unwrap();
let req = PrepareRequest::new( let mut req = PrepareRequest::new(
"ubuntu@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "ubuntu@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
); );
req.arch = "amd64".to_string();
let pulled = cache.pull(&req, &NoProgress).unwrap(); let pulled = cache.pull(&req, &NoProgress).unwrap();
assert!(!pulled.downloaded); assert!(!pulled.downloaded);
assert_eq!(pulled.cache_path, entry); assert_eq!(pulled.cache_path, entry);
@@ -474,9 +473,10 @@ mod tests {
// real pull flow. // real pull flow.
let dir = tempfile::tempdir().unwrap(); let dir = tempfile::tempdir().unwrap();
let cache = RootfsCache::new(dir.path().to_path_buf()); let cache = RootfsCache::new(dir.path().to_path_buf());
let req = PrepareRequest::new( let mut req = PrepareRequest::new(
"ubuntu@sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", "ubuntu@sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
); );
req.arch = "amd64".to_string();
// A pinned OCI source resolves without the network, so // A pinned OCI source resolves without the network, so
// parse_image_ref succeeds; the entry is absent, so pull takes // parse_image_ref succeeds; the entry is absent, so pull takes
// the download path and fails in fill_entry (no registry // the download path and fails in fill_entry (no registry
@@ -502,7 +502,8 @@ mod tests {
touch_entry(&cache, "alpine-3.23.0-x86_64.tar.gz"); touch_entry(&cache, "alpine-3.23.0-x86_64.tar.gz");
touch_entry(&cache, "alpine-3.22.9-x86_64.tar.gz"); touch_entry(&cache, "alpine-3.22.9-x86_64.tar.gz");
let req = PrepareRequest::new("alpine:3.23"); let mut req = PrepareRequest::new("alpine:3.23");
req.arch = "amd64".to_string();
let (source, path, downloaded) = cache.ensure_entry(&req, &NoProgress, false).unwrap(); let (source, path, downloaded) = cache.ensure_entry(&req, &NoProgress, false).unwrap();
assert!(!downloaded); assert!(!downloaded);
assert_eq!(path, dir.path().join("alpine-3.23.0-x86_64.tar.gz")); assert_eq!(path, dir.path().join("alpine-3.23.0-x86_64.tar.gz"));
@@ -519,7 +520,8 @@ mod tests {
touch_entry(&cache, "alpine-3.20.3-x86_64.tar.gz"); touch_entry(&cache, "alpine-3.20.3-x86_64.tar.gz");
touch_entry(&cache, "alpine-3.23.0-x86_64.tar.gz"); touch_entry(&cache, "alpine-3.23.0-x86_64.tar.gz");
let req = PrepareRequest::new("alpine:3.23"); let mut req = PrepareRequest::new("alpine:3.23");
req.arch = "amd64".to_string();
let (_, path, _) = cache.ensure_entry(&req, &NoProgress, false).unwrap(); let (_, path, _) = cache.ensure_entry(&req, &NoProgress, false).unwrap();
assert_eq!(path, dir.path().join("alpine-3.23.0-x86_64.tar.gz")); assert_eq!(path, dir.path().join("alpine-3.23.0-x86_64.tar.gz"));
} }
@@ -531,13 +533,15 @@ mod tests {
touch_entry(&cache, "alpine-20250401-x86_64.tar.gz"); touch_entry(&cache, "alpine-20250401-x86_64.tar.gz");
touch_entry(&cache, "alpine-3.23.0-x86_64.tar.gz"); touch_entry(&cache, "alpine-3.23.0-x86_64.tar.gz");
let req = PrepareRequest::new("alpine:edge"); let mut req = PrepareRequest::new("alpine:edge");
req.arch = "amd64".to_string();
let (_, path, _) = cache.ensure_entry(&req, &NoProgress, false).unwrap(); let (_, path, _) = cache.ensure_entry(&req, &NoProgress, false).unwrap();
assert_eq!(path, dir.path().join("alpine-20250401-x86_64.tar.gz")); assert_eq!(path, dir.path().join("alpine-20250401-x86_64.tar.gz"));
// Plain "alpine" floats among releases; the edge date is // Plain "alpine" floats among releases; the edge date is
// invisible to it. // invisible to it.
let req = PrepareRequest::new("alpine"); let mut req = PrepareRequest::new("alpine");
req.arch = "amd64".to_string();
let (_, path, _) = cache.ensure_entry(&req, &NoProgress, false).unwrap(); let (_, path, _) = cache.ensure_entry(&req, &NoProgress, false).unwrap();
assert_eq!(path, dir.path().join("alpine-3.23.0-x86_64.tar.gz")); assert_eq!(path, dir.path().join("alpine-3.23.0-x86_64.tar.gz"));
} }
@@ -549,7 +553,8 @@ mod tests {
touch_entry(&cache, "ubuntu-24.04-amd64.tar.gz"); touch_entry(&cache, "ubuntu-24.04-amd64.tar.gz");
touch_entry(&cache, "ubuntu-26.04-amd64.tar.gz"); touch_entry(&cache, "ubuntu-26.04-amd64.tar.gz");
let req = PrepareRequest::new("ubuntu:lts"); let mut req = PrepareRequest::new("ubuntu:lts");
req.arch = "amd64".to_string();
let (source, _, _) = cache.ensure_entry(&req, &NoProgress, false).unwrap(); let (source, _, _) = cache.ensure_entry(&req, &NoProgress, false).unwrap();
let ImageSource::DirectTarball { version, .. } = source else { let ImageSource::DirectTarball { version, .. } = source else {
panic!("expected a direct tarball"); panic!("expected a direct tarball");
@@ -599,7 +604,8 @@ mod tests {
// tree itself: the marker is read back out of the image. // tree itself: the marker is read back out of the image.
let image = rootfs.dir().join("rootfs.img"); let image = rootfs.dir().join("rootfs.img");
assert!(image.exists()); assert!(image.exists());
let out = std::process::Command::new("debugfs") let debugfs = crate::utils::find_tool("debugfs").unwrap();
let out = std::process::Command::new(debugfs)
.arg("-R") .arg("-R")
.arg("cat /etc-marker") .arg("cat /etc-marker")
.arg(&image) .arg(&image)