Lines
100 %
Functions
Branches
use super::*;
fn report_with(migrated: usize, quarantined: Vec<(Uuid, String)>) -> FleetReport {
FleetReport {
migrated,
quarantined,
..FleetReport::default()
}
#[test]
fn a_run_that_verified_everything_is_healthy() {
assert!(report_with(3, Vec::new()).is_healthy());
assert!(FleetReport::default().is_healthy());
fn a_single_quarantine_makes_the_run_degraded() {
let report = report_with(9, vec![(Uuid::nil(), "unreachable".to_owned())]);
assert!(
!report.is_healthy(),
"one tenant left behind must be visible in the exit code, not averaged away"
);
fn the_summary_reports_every_category() {
let report = FleetReport {
migrated: 2,
quarantined: vec![(Uuid::nil(), "boom".to_owned())],
unresolved: vec![Uuid::nil()],
unpublished: vec![(Uuid::nil(), "write failed".to_owned())],
};
assert_eq!(
report.summary(),
"migrated 2, quarantined 1, unresolved 1, unpublished 1"
fn a_tenant_this_run_never_verified_is_not_a_success() {
// Another worker held the claim to the end. It may since have died, and
// nothing would say so — exiting 0 here would gate a rollout on a database
// no one has looked at.
assert!(!report.is_healthy());
fn a_verdict_that_could_not_be_written_fails_the_run() {
// The dangerous case: the tenant failed, but its quarantine did not stick,
// so it is still being served on the wrong schema.
migrated: 5,
unpublished: vec![(Uuid::nil(), "directory unreachable".to_owned())],
fn outcomes_carry_their_reason() {
assert_eq!(Outcome::Migrated, Outcome::Migrated);
assert_ne!(Outcome::Migrated, Outcome::Unresolved);
Outcome::Quarantined("no such database".to_owned()),
Outcome::Quarantined("no such database".to_owned())
fn a_directory_at_the_current_schema_is_aligned() {
let drift = schema_drift(&[1, 2, 3, 5, 6], &[1, 2, 3, 5, 6]);
assert!(drift.is_aligned());
fn a_directory_behind_this_binary_is_reported_as_missing() {
// The Job reconciled before its own release migrated the global database.
let drift = schema_drift(&[1, 2, 3, 5, 6], &[1, 2, 3]);
assert_eq!(drift.missing, vec![5, 6]);
assert!(drift.unknown.is_empty());
assert!(!drift.is_aligned());
fn a_directory_ahead_of_this_binary_is_reported_as_unknown() {
// A rolled-back image, or one whose migration files were edited in place
// after being applied. Passing this would fail EVERY tenant on a
// disagreement that is not the tenant's, and those quarantines would outrank
// the correct run's because they are written later.
let drift = schema_drift(&[1, 2, 3], &[1, 2, 3, 5, 6]);
assert_eq!(drift.unknown, vec![5, 6]);
assert!(drift.missing.is_empty());
fn drift_is_judged_by_version_not_by_count() {
// Five applied, but the wrong five. Counting would call this aligned.
let drift = schema_drift(&[1, 2, 3, 5, 6], &[1, 2, 3, 4, 7]);
assert_eq!(drift.unknown, vec![4, 7]);