From bc0c1b6060876ab1c872d9d2d458b1bbcf2f01cf Mon Sep 17 00:00:00 2001 From: lif <> Date: Sat, 29 Jul 2023 09:08:00 +0000 Subject: [PATCH] name the log after the actual #[test] and share the context to avoid having leftover logs on buildomat --- sled-agent/src/storage/dump_setup.rs | 48 ++++++++++++---------------- 1 file changed, 21 insertions(+), 27 deletions(-) diff --git a/sled-agent/src/storage/dump_setup.rs b/sled-agent/src/storage/dump_setup.rs index 7df79e7fcab..279fabd37ea 100644 --- a/sled-agent/src/storage/dump_setup.rs +++ b/sled-agent/src/storage/dump_setup.rs @@ -862,6 +862,7 @@ struct CleanupDirInfo { #[cfg(test)] mod tests { use super::*; + use dropshot::test_util::LogContext; use illumos_utils::dumpadm::{ DF_VALID, DUMPADM, DUMP_MAGIC, DUMP_OFFSET, DUMP_VERSION, }; @@ -875,18 +876,19 @@ mod tests { // even in the same thread, or we will panic while panicking. #[test] fn test_sequentially() { - test_does_not_configure_coreadm_when_no_crash_dataset_mounted(); - test_configures_coreadm_only_when_crash_dataset_mounted(); - test_savecore_and_dumpadm_not_called_when_occupied_and_no_dir(); - test_dumpadm_called_when_vacant_slice_but_no_dir(); - test_savecore_and_dumpadm_invoked_when_slices_occupied_and_dir_is_available(); - test_archives_rotated_logs_and_cores(); + let logctx = + omicron_test_utils::dev::test_setup_log("test_sequentially"); + test_does_not_configure_coreadm_when_no_crash_dataset_mounted(&logctx); + test_configures_coreadm_only_when_crash_dataset_mounted(&logctx); + test_savecore_and_dumpadm_not_called_when_occupied_and_no_dir(&logctx); + test_dumpadm_called_when_vacant_slice_but_no_dir(&logctx); + test_savecore_and_dumpadm_invoked_when_slices_occupied_and_dir_is_available(&logctx); + test_archives_rotated_logs_and_cores(&logctx); } - fn test_does_not_configure_coreadm_when_no_crash_dataset_mounted() { - let logctx = omicron_test_utils::dev::test_setup_log( - "test_does_not_configure_coreadm_when_no_crash_dataset_mounted", - ); + fn test_does_not_configure_coreadm_when_no_crash_dataset_mounted( + logctx: &LogContext, + ) { let mut worker = DumpSetupWorker::new(logctx.log.clone()); // nothing when no disks @@ -903,10 +905,9 @@ mod tests { assert_eq!(worker.chosen_core_dir, None); } - fn test_configures_coreadm_only_when_crash_dataset_mounted() { - let logctx = omicron_test_utils::dev::test_setup_log( - "test_configures_coreadm_only_when_crash_dataset_mounted", - ); + fn test_configures_coreadm_only_when_crash_dataset_mounted( + logctx: &LogContext, + ) { let mut worker = DumpSetupWorker::new(logctx.log.clone()); // something when there's one that's ready! @@ -987,10 +988,9 @@ mod tests { // if we only have two filled dump slices and nowhere to evacuate them, // don't call dumpadm at all. - fn test_savecore_and_dumpadm_not_called_when_occupied_and_no_dir() { - let logctx = omicron_test_utils::dev::test_setup_log( - "test_savecore_and_dumpadm_not_called_when_occupied_and_no_dir", - ); + fn test_savecore_and_dumpadm_not_called_when_occupied_and_no_dir( + logctx: &LogContext, + ) { let mut worker = DumpSetupWorker::new(logctx.log.clone()); let tempdir = TempDir::new().unwrap(); let (occupied, _) = populate_tempdir_with_fake_dumps(&tempdir); @@ -1008,10 +1008,7 @@ mod tests { // if we have one dump slice that's free and one that's full, // and nowhere to savecore the full one, // we should always call dumpadm with the free one. - fn test_dumpadm_called_when_vacant_slice_but_no_dir() { - let logctx = omicron_test_utils::dev::test_setup_log( - "test_dumpadm_called_when_vacant_slice_but_no_dir", - ); + fn test_dumpadm_called_when_vacant_slice_but_no_dir(logctx: &LogContext) { let mut worker = DumpSetupWorker::new(logctx.log.clone()); let tempdir = TempDir::new().unwrap(); let (occupied, vacant) = populate_tempdir_with_fake_dumps(&tempdir); @@ -1045,8 +1042,8 @@ mod tests { // but we also have somewhere to unload them, // call dumpadm and savecore. fn test_savecore_and_dumpadm_invoked_when_slices_occupied_and_dir_is_available( + logctx: &LogContext, ) { - let logctx = omicron_test_utils::dev::test_setup_log("test_savecore_and_dumpadm_invoked_when_slices_occupied_and_dir_is_available"); let mut worker = DumpSetupWorker::new(logctx.log.clone()); let tempdir = TempDir::new().unwrap(); let (occupied, _) = populate_tempdir_with_fake_dumps(&tempdir); @@ -1077,10 +1074,7 @@ mod tests { ) } - fn test_archives_rotated_logs_and_cores() { - let logctx = omicron_test_utils::dev::test_setup_log( - "test_archives_rotated_logs_and_cores", - ); + fn test_archives_rotated_logs_and_cores(logctx: &LogContext) { let mut worker = DumpSetupWorker::new(logctx.log.clone()); // coreadm will get called