Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion crates/peryx-web/tests/unit/ssr/topology/tests.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
use peryx_core::{LocalStatus, NodeLiveness, NodeRole, TopologyView};
use peryx_driver::AppState;
use peryx_http::response_security::FieldClassification;
use peryx_storage::blob::BlobStorage;
use peryx_storage::meta::MetaStore;

use super::{local_status_from_observations, topology_view_for_class};
use super::{local_status, local_status_from_observations, topology_view_for_class};

#[test]
fn topology_projects_authority_and_health() {
Expand Down Expand Up @@ -48,3 +51,31 @@ fn topology_projects_authority_and_health() {
);
}
}

#[tokio::test]
async fn local_status_reads_the_blob_store_before_reporting_liveness() {
for (blob_root_usable, expected) in [(true, NodeLiveness::Live), (false, NodeLiveness::Unready)] {
let directory = tempfile::tempdir().unwrap();
let blobs = directory.path().join("blobs");
// A regular file where the blob root belongs is the seam: the health check creates and reads
// the root as a directory, so it fails while the journal read beside it still succeeds.
if !blob_root_usable {
std::fs::write(&blobs, b"not a directory").unwrap();
}
let app = AppState::new(
MetaStore::open(directory.path().join("peryx.redb")).unwrap(),
BlobStorage::filesystem(&blobs),
60,
Vec::new(),
);

assert_eq!(
local_status(&app).await,
LocalStatus {
role: NodeRole::Writer,
liveness: expected,
frontier: 0,
}
);
}
}