Lines
100 %
Functions
Branches
//! Re-running over an already-current fleet is safe, and never touches the admin.
#![cfg(feature = "db")]
use server::fleet::migrate_fleet;
use tests_integration::fleet_support::{
accounted_for, admin_connect, admin_id, forget_tenant, is_fully_migrated, quarantine_of,
register_tenant,
};
#[tokio::test]
async fn a_second_run_changes_nothing_and_spares_the_admin() -> anyhow::Result<()> {
let admin = admin_connect().await;
let (id, database_name) = register_tenant(&admin, "fleet-again", true).await;
let first = migrate_fleet(admin_id()).await?;
assert!(accounted_for(&first, id), "{first:?}");
let second = migrate_fleet(admin_id()).await?;
assert!(
accounted_for(&second, id),
"an already-current tenant is visited again and still passes: {second:?}"
);
assert!(is_fully_migrated(&database_name).await);
assert_eq!(quarantine_of(&admin, id).await, None);
// The admin row points at the GLOBAL database. Visiting it would migrate the
// global schema through the tenant path, and quarantining it would take the
// whole deployment offline.
assert!(accounted_for(&second, admin_id()), "{second:?}");
assert_eq!(quarantine_of(&admin, admin_id()).await, None);
forget_tenant(&admin, id, &database_name).await;
Ok(())
}