From d95f252a8e8c779ecefa12adc75770138f5ef4e1 Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Fri, 16 Sep 2022 17:46:10 -0400 Subject: [PATCH] refactor: Extract a unit test for case 1 Also add coverage for when there are no *partitions* in addition to the test for when there are no *parquet files*. --- compactor/src/hot.rs | 51 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/compactor/src/hot.rs b/compactor/src/hot.rs index 85fd507cc9..61ad78b139 100644 --- a/compactor/src/hot.rs +++ b/compactor/src/hot.rs @@ -251,6 +251,49 @@ mod tests { } } + #[tokio::test] + async fn no_partitions_no_candidates() { + let TestSetup { + catalog, shard1, .. + } = test_setup().await; + + let candidates = hot_partitions_for_shard( + Arc::clone(&catalog.catalog), + shard1.shard.id, + &query_times(catalog.time_provider()), + 1, + 1, + ) + .await + .unwrap(); + + assert!(candidates.is_empty()); + } + + #[tokio::test] + async fn no_files_no_candidates() { + let TestSetup { + catalog, + shard1, + table1, + .. + } = test_setup().await; + + table1.with_shard(&shard1).create_partition("one").await; + + let candidates = hot_partitions_for_shard( + Arc::clone(&catalog.catalog), + shard1.shard.id, + &query_times(catalog.time_provider()), + 1, + 1, + ) + .await + .unwrap(); + + assert!(candidates.is_empty()); + } + #[tokio::test] async fn test_hot_partitions_to_compact() { let TestSetup { @@ -299,14 +342,6 @@ mod tests { // In order words, the last Case needs all content of previous tests. // This shows the priority of selecting compaction candidates - // -------------------------------------- - // Case 1: no files yet --> no partition candidates - // - let candidates = hot_partitions_to_compact(Arc::clone(&compactor)) - .await - .unwrap(); - assert!(candidates.is_empty()); - // -------------------------------------- // Case 2: no non-deleleted L0 files --> no partition candidates //