1
//! Re-running over an already-current fleet is safe, and never touches the admin.
2
#![cfg(feature = "db")]
3

            
4
use server::fleet::migrate_fleet;
5
use tests_integration::fleet_support::{
6
    accounted_for, admin_connect, admin_id, is_fully_migrated, quarantine_of, register_tenant,
7
};
8

            
9
#[tokio::test]
10
1
async fn a_second_run_changes_nothing_and_spares_the_admin() -> anyhow::Result<()> {
11
1
    let admin = admin_connect().await;
12
1
    let (id, database_name, _id_guard) = register_tenant(&admin, "fleet-again", true).await;
13

            
14
1
    let first = migrate_fleet(admin_id()).await?;
15
1
    assert!(accounted_for(&first, id), "{first:?}");
16

            
17
1
    let second = migrate_fleet(admin_id()).await?;
18
1
    assert!(
19
1
        accounted_for(&second, id),
20
        "an already-current tenant is visited again and still passes: {second:?}"
21
    );
22
1
    assert!(is_fully_migrated(&database_name).await);
23
1
    assert_eq!(quarantine_of(&admin, id).await, None);
24

            
25
    // The admin row points at the GLOBAL database. Visiting it would migrate the
26
    // global schema through the tenant path, and quarantining it would take the
27
    // whole deployment offline.
28
1
    assert!(accounted_for(&second, admin_id()), "{second:?}");
29
1
    assert_eq!(quarantine_of(&admin, admin_id()).await, None);
30
2
    Ok(())
31
1
}