1
//! Tenants that exist but were never migrated reach the current schema.
2
#![cfg(feature = "db")]
3

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

            
10
#[tokio::test]
11
1
async fn every_reachable_tenant_reaches_the_current_schema() -> anyhow::Result<()> {
12
1
    let admin = admin_connect().await;
13
1
    let (first, first_db) = register_tenant(&admin, "fleet-a", true).await;
14
1
    let (second, second_db) = register_tenant(&admin, "fleet-b", true).await;
15

            
16
1
    assert!(
17
1
        !is_fully_migrated(&first_db).await,
18
        "precondition: a bare CREATE DATABASE has no schema"
19
    );
20

            
21
1
    let report = migrate_fleet(admin_id()).await?;
22

            
23
1
    assert!(accounted_for(&report, first), "{report:?}");
24
1
    assert!(accounted_for(&report, second), "{report:?}");
25
1
    assert!(
26
1
        is_fully_migrated(&first_db).await,
27
        "a visited tenant must carry the whole migration set, not merely some of it"
28
    );
29
1
    assert!(is_fully_migrated(&second_db).await);
30
1
    assert_eq!(quarantine_of(&admin, first).await, None);
31
1
    assert_eq!(quarantine_of(&admin, second).await, None);
32

            
33
1
    forget_tenant(&admin, first, &first_db).await;
34
1
    forget_tenant(&admin, second, &second_db).await;
35
2
    Ok(())
36
1
}