Lines
100 %
Functions
Branches
//! One sick tenant degrades itself, not the fleet — and quarantine is not a
//! tombstone.
#![cfg(feature = "db")]
use server::fleet::migrate_fleet;
use tests_integration::fleet_support::{
accounted_for, admin_connect, admin_id, create_database, forget_tenant, is_fully_migrated,
quarantine_of, quarantine_reason_in, register_tenant,
};
#[tokio::test]
async fn an_unreachable_tenant_is_quarantined_and_later_released() -> anyhow::Result<()> {
let admin = admin_connect().await;
let (healthy, healthy_db) = register_tenant(&admin, "fleet-ok", true).await;
let (missing, missing_db) = register_tenant(&admin, "fleet-gone", false).await;
let report = migrate_fleet(admin_id()).await?;
assert!(
quarantine_reason_in(&report, missing).is_some(),
"the unreachable tenant must be the one quarantined: {report:?}"
);
quarantine_of(&admin, missing).await.is_some(),
"the failure must be recorded in the global directory, the only place an \
unreachable tenant's failure can live"
assert!(accounted_for(&report, healthy), "{report:?}");
is_fully_migrated(&healthy_db).await,
"a healthy tenant must not be held back by a sick one"
assert_eq!(quarantine_of(&admin, healthy).await, None);
// Repair it. A transient outage must not strand a user permanently, so a
// later run has to retry the tenant and lift the quarantine.
create_database(&admin, &missing_db).await;
assert!(accounted_for(&report, missing), "{report:?}");
assert_eq!(
quarantine_of(&admin, missing).await,
None,
"only a verified success lifts a quarantine, and this was one"
assert!(is_fully_migrated(&missing_db).await);
forget_tenant(&admin, healthy, &healthy_db).await;
forget_tenant(&admin, missing, &missing_db).await;
Ok(())
}