From 765feaa4d8b2758333eca7b68b6abb643dd07f49 Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Mon, 19 Sep 2022 11:41:40 -0400 Subject: [PATCH] refactor: Extract a unit test for case 3 --- compactor/src/hot.rs | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/compactor/src/hot.rs b/compactor/src/hot.rs index b3c02fb9ba..9887b232d0 100644 --- a/compactor/src/hot.rs +++ b/compactor/src/hot.rs @@ -377,6 +377,34 @@ mod tests { assert!(candidates.is_empty()); } + #[tokio::test] + async fn cold_not_returned() { + let TestSetup { + catalog, + shard1, + table1, + .. + } = test_setup().await; + + let partition1 = table1.with_shard(&shard1).create_partition("one").await; + + let builder = TestParquetFileBuilder::default() + .with_creation_time(catalog.time_provider().hours_ago(38)); + partition1.create_parquet_file_catalog_record(builder).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 { @@ -430,20 +458,10 @@ mod tests { .with_compaction_level(CompactionLevel::FileNonOverlapped); let _pf2 = partition2.create_parquet_file_catalog_record(builder).await; - // -------------------------------------- - // Case 3: no new recent writes (within the last 24 hours) --> no partition candidates - // (the cold case will pick them up) - // // partition2 has an old (more than 8 hours ago) non-deleted level 0 file let builder = TestParquetFileBuilder::default().with_creation_time(time_38_hour_ago); let _pf3 = partition2.create_parquet_file_catalog_record(builder).await; - // No hot candidates - let candidates = hot_partitions_to_compact(Arc::clone(&compactor)) - .await - .unwrap(); - assert!(candidates.is_empty()); - // -------------------------------------- // Case 4: has one partition with recent writes (5 hours ago) --> return that partition //