Skip to content

Commit

Permalink
test: add seqno recovery test for remove()
Browse files Browse the repository at this point in the history
  • Loading branch information
marvin-j97 committed Dec 23, 2024
1 parent 4b1b89e commit 675f184
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions tests/seqno_recovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,47 @@ fn recover_seqno() -> fjall::Result<()> {

Ok(())
}

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

let mut seqno = 0;

// NOTE: clippy bug
#[allow(unused_assignments)]
{
let keyspace = Config::new(&folder).open()?;

let partitions = &[
keyspace.open_partition("default1", PartitionCreateOptions::default())?,
keyspace.open_partition("default2", PartitionCreateOptions::default())?,
keyspace.open_partition("default3", PartitionCreateOptions::default())?,
];

for tree in partitions {
for x in 0..ITEM_COUNT as u64 {
let key = x.to_be_bytes();
tree.remove(key)?;

seqno += 1;
assert_eq!(seqno, keyspace.instant());
}

for x in 0..ITEM_COUNT as u64 {
let key: [u8; 8] = (x + ITEM_COUNT as u64).to_be_bytes();
tree.remove(key)?;

seqno += 1;
assert_eq!(seqno, keyspace.instant());
}
}
}

for _ in 0..10 {
let keyspace = Config::new(&folder).open()?;
assert_eq!(seqno, keyspace.instant());
}

Ok(())
}

0 comments on commit 675f184

Please sign in to comment.