Skip to content

Commit

Permalink
Merge branch 'test/drop-segments'
Browse files Browse the repository at this point in the history
  • Loading branch information
marvin-j97 committed May 28, 2024
2 parents b42b9aa + 9682826 commit 2ffab5d
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/compaction/fifo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ mod tests {
}

#[test]
fn ttl() -> crate::Result<()> {
fn fifo_ttl() -> crate::Result<()> {
let tempdir = tempfile::tempdir()?;
let compactor = Strategy::new(u64::MAX, Some(5_000));

Expand All @@ -181,7 +181,7 @@ mod tests {
}

#[test]
fn empty_levels() -> crate::Result<()> {
fn fifo_empty_levels() -> crate::Result<()> {
let tempdir = tempfile::tempdir()?;
let compactor = Strategy::new(1, None);

Expand All @@ -196,7 +196,7 @@ mod tests {
}

#[test]
fn below_limit() -> crate::Result<()> {
fn fifo_below_limit() -> crate::Result<()> {
let tempdir = tempfile::tempdir()?;
let compactor = Strategy::new(4, None);

Expand Down Expand Up @@ -230,7 +230,7 @@ mod tests {
}

#[test]
fn more_than_limit() -> crate::Result<()> {
fn fifo_more_than_limit() -> crate::Result<()> {
let tempdir = tempfile::tempdir()?;
let compactor = Strategy::new(2, None);

Expand Down
6 changes: 3 additions & 3 deletions src/compaction/maintenance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ mod tests {
}

#[test]
fn empty_level() -> crate::Result<()> {
fn maintenance_empty_level() -> crate::Result<()> {
let tempdir = tempfile::tempdir()?;
let compactor = Strategy;

Expand All @@ -146,7 +146,7 @@ mod tests {
}

#[test]
fn below_limit() -> crate::Result<()> {
fn maintenance_below_limit() -> crate::Result<()> {
let tempdir = tempfile::tempdir()?;
let compactor = Strategy;

Expand All @@ -164,7 +164,7 @@ mod tests {
}

#[test]
fn l0_too_large() -> crate::Result<()> {
fn maintenance_l0_too_large() -> crate::Result<()> {
let tempdir = tempfile::tempdir()?;
let compactor = Strategy;

Expand Down
14 changes: 7 additions & 7 deletions src/compaction/tiered.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ mod tests {
}

#[test]
fn empty_levels() -> crate::Result<()> {
fn tiered_empty_levels() -> crate::Result<()> {
let tempdir = tempfile::tempdir()?;
let compactor = Strategy {
base_size: 8 * 1_024 * 1_024,
Expand All @@ -182,7 +182,7 @@ mod tests {
}

#[test]
fn default_l0() -> crate::Result<()> {
fn tiered_default_l0() -> crate::Result<()> {
let tempdir = tempfile::tempdir()?;
let compactor = Strategy {
base_size: 8 * 1_024 * 1_024,
Expand Down Expand Up @@ -215,7 +215,7 @@ mod tests {
}

#[test]
fn ordering() -> crate::Result<()> {
fn tiered_ordering() -> crate::Result<()> {
let tempdir = tempfile::tempdir()?;
let compactor = Strategy {
base_size: 8 * 1_024 * 1_024,
Expand All @@ -242,7 +242,7 @@ mod tests {
}

#[test]
fn more_than_min() -> crate::Result<()> {
fn tiered_more_than_min() -> crate::Result<()> {
let tempdir = tempfile::tempdir()?;
let compactor = Strategy {
base_size: 8 * 1_024 * 1_024,
Expand Down Expand Up @@ -273,7 +273,7 @@ mod tests {
}

#[test]
fn many_segments() -> crate::Result<()> {
fn tiered_many_segments() -> crate::Result<()> {
let tempdir = tempfile::tempdir()?;
let compactor = Strategy {
base_size: 8 * 1_024 * 1_024,
Expand All @@ -299,7 +299,7 @@ mod tests {
}

#[test]
fn deeper_level() -> crate::Result<()> {
fn tiered_deeper_level() -> crate::Result<()> {
let tempdir = tempfile::tempdir()?;
let compactor = Strategy {
base_size: 8 * 1_024 * 1_024,
Expand Down Expand Up @@ -340,7 +340,7 @@ mod tests {
}

#[test]
fn last_level() -> crate::Result<()> {
fn tiered_last_level() -> crate::Result<()> {
let tempdir = tempfile::tempdir()?;
let compactor = Strategy {
base_size: 8 * 1_024 * 1_024,
Expand Down
28 changes: 28 additions & 0 deletions src/compaction/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,3 +393,31 @@ fn drop_segments(

Ok(())
}

#[cfg(test)]
mod tests {
use std::sync::Arc;
use test_log::test;

#[test]
fn compaction_drop_segments() -> crate::Result<()> {
let folder = tempfile::tempdir()?;

let tree = crate::Config::new(folder).open()?;

tree.insert("a", "a", 0);
tree.flush_active_memtable()?;
tree.insert("a", "a", 1);
tree.flush_active_memtable()?;
tree.insert("a", "a", 2);
tree.flush_active_memtable()?;

assert_eq!(3, tree.approximate_len());

tree.compact(Arc::new(crate::compaction::Fifo::new(1, None)))?;

assert_eq!(0, tree.segment_count());

Ok(())
}
}

0 comments on commit 2ffab5d

Please sign in to comment.