Skip to content

Commit

Permalink
name the log after the actual #[test] and share the context to avoid …
Browse files Browse the repository at this point in the history
…having leftover logs on buildomat
  • Loading branch information
lif committed Jul 29, 2023
1 parent 207c318 commit bc0c1b6
Showing 1 changed file with 21 additions and 27 deletions.
48 changes: 21 additions & 27 deletions sled-agent/src/storage/dump_setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand All @@ -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
Expand All @@ -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!
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit bc0c1b6

Please sign in to comment.