name what is true in three more comments, and test the old event log's removal
This commit is contained in:
parent
cb9fbfc9da
commit
49ee678117
4 changed files with 47 additions and 6 deletions
|
|
@ -170,3 +170,44 @@ fn remove_old_event_log(harness: &Path) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::remove_old_event_log;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn the_old_event_log_and_its_wal_files_are_removed_and_nothing_else() {
|
||||||
|
let dir = tempfile::tempdir().unwrap();
|
||||||
|
for name in [
|
||||||
|
"hyperhive-events.sqlite",
|
||||||
|
"hyperhive-events.sqlite-wal",
|
||||||
|
"hyperhive-events.sqlite-shm",
|
||||||
|
"hyperhive-turn-stats.sqlite",
|
||||||
|
] {
|
||||||
|
std::fs::write(dir.path().join(name), b"x").unwrap();
|
||||||
|
}
|
||||||
|
remove_old_event_log(dir.path());
|
||||||
|
assert!(!dir.path().join("hyperhive-events.sqlite").exists());
|
||||||
|
assert!(!dir.path().join("hyperhive-events.sqlite-wal").exists());
|
||||||
|
assert!(!dir.path().join("hyperhive-events.sqlite-shm").exists());
|
||||||
|
assert!(dir.path().join("hyperhive-turn-stats.sqlite").exists());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_harness_dir_without_the_log_is_left_alone() {
|
||||||
|
let dir = tempfile::tempdir().unwrap();
|
||||||
|
remove_old_event_log(dir.path());
|
||||||
|
assert_eq!(std::fs::read_dir(dir.path()).unwrap().count(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A removal that fails for another reason is logged and the rest still go.
|
||||||
|
#[test]
|
||||||
|
fn a_failed_removal_does_not_stop_the_others() {
|
||||||
|
let dir = tempfile::tempdir().unwrap();
|
||||||
|
std::fs::create_dir(dir.path().join("hyperhive-events.sqlite")).unwrap();
|
||||||
|
std::fs::write(dir.path().join("hyperhive-events.sqlite-wal"), b"x").unwrap();
|
||||||
|
remove_old_event_log(dir.path());
|
||||||
|
assert!(dir.path().join("hyperhive-events.sqlite").is_dir());
|
||||||
|
assert!(!dir.path().join("hyperhive-events.sqlite-wal").exists());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -750,8 +750,8 @@ impl Coordinator {
|
||||||
|
|
||||||
/// Per-agent harness-internal state dir. Bind-mounted RW into the
|
/// Per-agent harness-internal state dir. Bind-mounted RW into the
|
||||||
/// agent container at `/agents/{name}/harness`. Holds sqlite dbs
|
/// agent container at `/agents/{name}/harness`. Holds sqlite dbs
|
||||||
/// and config files owned by the harness (`hyperhive-events.sqlite`,
|
/// and config files owned by the harness (`hyperhive-turn-stats.sqlite`,
|
||||||
/// `hyperhive-turn-stats.sqlite`, `hyperhive-model`) — kept separate
|
/// `hyperhive-model`) — kept separate
|
||||||
/// from the agent-visible `state/` so claude's "my notes" view is
|
/// from the agent-visible `state/` so claude's "my notes" view is
|
||||||
/// uncluttered and the host vacuum has a clean sweep root.
|
/// uncluttered and the host vacuum has a clean sweep root.
|
||||||
pub fn agent_harness_dir(name: &hive_types::Ident) -> PathBuf {
|
pub fn agent_harness_dir(name: &hive_types::Ident) -> PathBuf {
|
||||||
|
|
|
||||||
|
|
@ -321,8 +321,8 @@ async fn cmd_serve(
|
||||||
swarm_agent_status::spawn(std::sync::Arc::clone(&coord));
|
swarm_agent_status::spawn(std::sync::Arc::clone(&coord));
|
||||||
// Squid's users file: the hashes of this hive's agents' proxy credentials.
|
// Squid's users file: the hashes of this hive's agents' proxy credentials.
|
||||||
workers::squid_users::spawn(coord.shutdown_rx());
|
workers::squid_users::spawn(coord.shutdown_rx());
|
||||||
// Per-agent events.sqlite + bash-tasks file cleanup now runs
|
// Per-agent bash-tasks file cleanup, and the removal of the old event log,
|
||||||
// agent-side in the harness (`hive_agent::vacuum`): the files are
|
// now run agent-side in the harness (`hive_agent::vacuum`): the files are
|
||||||
// agent-owned, so host-side deletes hit PermissionDenied / readonly-db
|
// agent-owned, so host-side deletes hit PermissionDenied / readonly-db
|
||||||
// under privsep. See issue tracker "perms borked".
|
// under privsep. See issue tracker "perms borked".
|
||||||
// (turn-stats.sqlite has no vacuum — it's one tiny row per turn,
|
// (turn-stats.sqlite has no vacuum — it's one tiny row per turn,
|
||||||
|
|
|
||||||
|
|
@ -132,8 +132,8 @@ let
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# Who is signed in, for the profile menu of the dashboard and the agent page
|
# Who is signed in, for the profile menu of the dashboard (served from
|
||||||
# (both are served from this vhost, so one location covers both). Authelia
|
# this vhost). Authelia
|
||||||
# answers with the session's display name and e-mail; the swarm UI's
|
# answers with the session's display name and e-mail; the swarm UI's
|
||||||
# `/api/whoami` (../swarm-ui.nix) is the same location. `=` exact match, so
|
# `/api/whoami` (../swarm-ui.nix) is the same location. `=` exact match, so
|
||||||
# the `proxy_pass` URI replaces the request's, and it wins over `/api/`.
|
# the `proxy_pass` URI replaces the request's, and it wins over `/api/`.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue