Watch
0
0
Fork
You've already forked hyperhive
0

test the deployed-rev check and the update-chip comparison. Refs #5913

This commit is contained in:
damocles 2026-11-01 17:38:19 +01:00
commit db4f8a7b15

View file

@ -358,8 +358,13 @@ async fn handle_deploy_request(
/// deployed yet and queues again: the rebuild resolves its pins from
/// `internal/meta` either way, so a second one is redundant but harmless.
fn rev_already_deployed(agent: &str, rev: &str) -> bool {
std::fs::read_to_string(crate::paths::applied_config_marker(agent))
.is_ok_and(|deployed| deployed.trim() == rev)
marker_holds(&crate::paths::applied_config_marker(agent), rev)
}
/// Whether the marker file at `marker` holds exactly `rev`; an absent or
/// unreadable marker holds nothing.
fn marker_holds(marker: &std::path::Path, rev: &str) -> bool {
std::fs::read_to_string(marker).is_ok_and(|deployed| deployed.trim() == rev)
}
/// Queue the first deploy of an agent this hive does not have yet: seed its
@ -406,3 +411,19 @@ async fn publish(client: &async_nats::Client, hive: &str) -> Result<()> {
.with_context(|| format!("publishing the status snapshot for {hive}"))?;
Ok(())
}
#[cfg(test)]
mod rev_marker_tests {
use super::marker_holds;
#[test]
fn a_rev_is_deployed_only_when_the_marker_holds_it() {
let dir = tempfile::tempdir().expect("tempdir");
let marker = dir.path().join(".alice.config-rev");
assert!(!marker_holds(&marker, "aaa"), "no marker, nothing deployed");
std::fs::write(&marker, "aaa").expect("write marker");
assert!(marker_holds(&marker, "aaa"));
assert!(!marker_holds(&marker, "bbb"), "another rev still deploys");
}
}