chore: add option to simulator to optionally suppress the output of compaction runs

pull/24376/head
Joe-Blount 2023-04-03 15:02:04 -05:00
parent 711ccc153e
commit 48407e78da
2 changed files with 19 additions and 1 deletions

View File

@ -126,7 +126,9 @@ pub(crate) async fn run_layout_scenario(setup: &TestSetup) -> Vec<String> {
let compact_result = setup.run_compact().await;
// record what the compactor actually did
output.extend(compact_result.run_log);
if !setup.suppress_run_output {
output.extend(compact_result.run_log);
}
// Record any skipped compactions (is after what the compactor actually did)
output.extend(get_skipped_compactions(setup).await);

View File

@ -76,6 +76,7 @@ pub struct TestSetupBuilder<const WITH_FILES: bool> {
run_log: Arc<Mutex<Vec<String>>>,
/// Checker that catalog invariant are not violated
invariant_check: Arc<dyn InvariantCheck>,
suppress_run_output: bool,
}
impl TestSetupBuilder<false> {
@ -107,6 +108,8 @@ impl TestSetupBuilder<false> {
catalog: Arc::clone(&catalog.catalog),
});
let suppress_run_output = false;
// Intercept all catalog commit calls to record them in
// `run_log` as well as ensuring the invariants still hold
let run_log = Arc::new(Mutex::new(vec![]));
@ -157,6 +160,7 @@ impl TestSetupBuilder<false> {
files: vec![],
run_log,
invariant_check,
suppress_run_output,
}
}
@ -290,6 +294,7 @@ impl TestSetupBuilder<false> {
files,
run_log: Arc::new(Mutex::new(vec![])),
invariant_check,
suppress_run_output: false,
}
}
@ -320,6 +325,7 @@ impl TestSetupBuilder<false> {
files,
run_log: Arc::new(Mutex::new(vec![])),
invariant_check,
suppress_run_output: false,
}
}
@ -351,6 +357,7 @@ impl TestSetupBuilder<false> {
files,
run_log: Arc::new(Mutex::new(vec![])),
invariant_check,
suppress_run_output: false,
}
}
@ -504,6 +511,12 @@ impl<const WITH_FILES: bool> TestSetupBuilder<WITH_FILES> {
self
}
/// Set option to suppress output of compaction runs;
pub fn with_suppress_run_output(mut self) -> Self {
self.suppress_run_output = true;
self
}
/// set simulate_without_object_store
pub fn simulate_without_object_store(mut self) -> Self {
let run_log = Arc::clone(&self.run_log);
@ -558,6 +571,7 @@ impl<const WITH_FILES: bool> TestSetupBuilder<WITH_FILES> {
config: Arc::new(self.config),
run_log: self.run_log,
invariant_check: self.invariant_check,
suppress_run_output: self.suppress_run_output,
}
}
}
@ -577,6 +591,8 @@ pub struct TestSetup {
pub partition: Arc<TestPartition>,
/// The compactor2 configuration
pub config: Arc<Config>,
/// allows optionally suppressing output of running the test
pub suppress_run_output: bool,
/// a shared log of what happened during a simulated run
run_log: Arc<Mutex<Vec<String>>>,
/// Checker that catalog invariant are not violated