From d3ae2740df5ab8439fbfdd82f4ab91b300f9f4bf Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Mon, 2 Sep 2024 11:39:59 -0700 Subject: [PATCH] nicer output for tests --- .../tasks/instance_reincarnation.rs | 23 +++++++++++-------- nexus/types/src/internal_api/background.rs | 2 +- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/nexus/src/app/background/tasks/instance_reincarnation.rs b/nexus/src/app/background/tasks/instance_reincarnation.rs index bf254fee6f1..05e0a22e1af 100644 --- a/nexus/src/app/background/tasks/instance_reincarnation.rs +++ b/nexus/src/app/background/tasks/instance_reincarnation.rs @@ -356,10 +356,12 @@ mod test { // Activate the task again, and check that our instance had an // instance-start saga started. let result = task.activate(&opctx).await; - assert_eq!(starter.count_reset(), 1); let status = serde_json::from_value::(result) .expect("JSON must be correctly shaped"); + eprintln!("activation: {status:#?}"); + + assert_eq!(starter.count_reset(), 1); assert_eq!(status.instances_found, 1); assert_eq!( status.instances_reincarnated, @@ -433,31 +435,34 @@ mod test { } // Activate the task again, and check that our instance had an - // instance-start saga started. + // instance-start saga started. let result = task.activate(&opctx).await; - assert_eq!(starter.count_reset(), will_reincarnate.len() as u64); let status = serde_json::from_value::(result) .expect("JSON must be correctly shaped"); + eprintln!("activation: {status:#?}"); + + assert_eq!(starter.count_reset(), will_reincarnate.len() as u64); assert_eq!(status.instances_found, will_reincarnate.len()); assert_eq!(status.already_reincarnated, Vec::new()); assert_eq!(status.query_error, None); assert_eq!(status.restart_errors, Vec::new()); for id in &status.instances_reincarnated { + eprintln!("instance {id} reincarnated"); assert!( - will_reincarnate.contains(id), - "expected {id} to be reincarnated, but found {:?}", + !will_not_reincarnate.contains(id), + "expected {id} not to reincarnate! reincarnated: {:?}", status.instances_reincarnated ); } - for id in will_not_reincarnate { + for id in will_reincarnate { assert!( - !status.instances_reincarnated.iter().any(|&i| i == id), - "expected {id} to not reincarnate, but found {:?}", + status.instances_reincarnated.contains(&id), + "expected {id} to have reincarnated! reincarnated: {:?}", status.instances_reincarnated - ); + ) } } } diff --git a/nexus/types/src/internal_api/background.rs b/nexus/types/src/internal_api/background.rs index c8898c09110..50f8c76b29e 100644 --- a/nexus/types/src/internal_api/background.rs +++ b/nexus/types/src/internal_api/background.rs @@ -56,7 +56,7 @@ pub struct RegionSnapshotReplacementFinishStatus { } /// The status of an `instance_reincarnation` background task activation. -#[derive(Default, Serialize, Deserialize)] +#[derive(Default, Serialize, Deserialize, Debug)] pub struct InstanceReincarnationStatus { /// Total number of instances in need of reincarnation on this activation. pub instances_found: usize,