mirror of
https://tangled.org/tranquil.farm/tranquil-pds
synced 2026-09-24 19:24:15 +00:00
Stop talking to docker in tests that don't need docker
`just test` doesn't use docker, but the cleanup was still pruning containers over and over. This switches to only cleaning up containers created by the tests.
This commit is contained in:
Generated
+27
@@ -1646,6 +1646,21 @@ dependencies = [
|
||||
"syn 2.0.117",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "conquer-once"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5d008a441c0f269f36ca13712528069a86a3e60dffee1d98b976eb3b0b2160b4"
|
||||
dependencies = [
|
||||
"conquer-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "conquer-util"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e763eef8846b13b380f37dfecda401770b0ca4e56e95170237bd7c25c7db3582"
|
||||
|
||||
[[package]]
|
||||
name = "const-oid"
|
||||
version = "0.9.6"
|
||||
@@ -6560,6 +6575,16 @@ dependencies = [
|
||||
"thiserror 2.0.18",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "signal-hook"
|
||||
version = "0.3.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d881a16cf4426aa584979d30bd82cb33429027e42122b169753d6ef1085ed6e2"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"signal-hook-registry",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "signal-hook-registry"
|
||||
version = "1.4.8"
|
||||
@@ -7120,6 +7145,7 @@ dependencies = [
|
||||
"async-trait",
|
||||
"bollard",
|
||||
"bytes",
|
||||
"conquer-once",
|
||||
"docker_credential",
|
||||
"either",
|
||||
"etcetera 0.11.0",
|
||||
@@ -7133,6 +7159,7 @@ dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_with",
|
||||
"signal-hook",
|
||||
"thiserror 2.0.18",
|
||||
"tokio",
|
||||
"tokio-stream",
|
||||
|
||||
@@ -90,7 +90,7 @@ tranquil-infra = { workspace = true, features = ["testing"] }
|
||||
tempfile = "3"
|
||||
ciborium = { workspace = true }
|
||||
ctor = { workspace = true }
|
||||
testcontainers = { workspace = true }
|
||||
testcontainers = { workspace = true, features = ["watchdog"] }
|
||||
testcontainers-modules = { workspace = true }
|
||||
tranquil-ripple = { workspace = true }
|
||||
tranquil-sync = { workspace = true }
|
||||
|
||||
@@ -83,28 +83,41 @@ fn has_external_infra() -> bool {
|
||||
|| (std::env::var("DATABASE_URL").is_ok()
|
||||
&& (std::env::var("S3_ENDPOINT").is_ok() || std::env::var("BLOB_STORAGE_PATH").is_ok()))
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "external-infra"))]
|
||||
fn started_container_ids() -> Vec<String> {
|
||||
let db = DB_CONTAINER.get().map(|c| c.id().to_string());
|
||||
#[cfg(feature = "s3")]
|
||||
let s3 = S3_CONTAINER.get().map(|c| c.id().to_string());
|
||||
#[cfg(not(feature = "s3"))]
|
||||
let s3: Option<String> = None;
|
||||
db.into_iter().chain(s3).collect()
|
||||
}
|
||||
|
||||
#[cfg(feature = "external-infra")]
|
||||
fn started_container_ids() -> Vec<String> {
|
||||
Vec::new()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[ctor::dtor]
|
||||
fn cleanup() {
|
||||
if let Some(temp_dir) = TEST_TEMP_DIR.get() {
|
||||
let _ = std::fs::remove_dir_all(temp_dir);
|
||||
}
|
||||
if has_external_infra() {
|
||||
let ids = started_container_ids();
|
||||
if ids.is_empty() {
|
||||
return;
|
||||
}
|
||||
if std::env::var("XDG_RUNTIME_DIR").is_ok() {
|
||||
let _ = std::process::Command::new("podman")
|
||||
.args(["rm", "-f", "--filter", "label=tranquil_pds_test=true"])
|
||||
.args(["rm", "-f"])
|
||||
.args(&ids)
|
||||
.output();
|
||||
}
|
||||
let _ = std::process::Command::new("docker")
|
||||
.args([
|
||||
"container",
|
||||
"prune",
|
||||
"-f",
|
||||
"--filter",
|
||||
"label=tranquil_pds_test=true",
|
||||
])
|
||||
.args(["rm", "-f"])
|
||||
.args(&ids)
|
||||
.output();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user