Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dev] levels: add key-version test #80

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions src/levels/tests.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::*;
use crate::{db::tests::with_agate_test, table::new_filename, Agate, TableOptions};
use crate::{db::tests::with_agate_test, table::new_filename, Agate};

pub fn helper_dump_levels(lvctl: &LevelsController) {
for level in &lvctl.core.levels {
Expand Down Expand Up @@ -54,7 +54,7 @@ impl KeyValVersion {
}

fn create_and_open(agate: &mut Agate, td: Vec<KeyValVersion>, level: usize) {
let mut table_opts = TableOptions::default();
let mut table_opts = build_table_options(&agate.core.opts);
table_opts.block_size = agate.core.opts.block_size;
table_opts.bloom_false_positive = agate.core.opts.bloom_false_positive;
let mut builder = TableBuilder::new(table_opts.clone());
Expand Down Expand Up @@ -1004,3 +1004,28 @@ mod miscellaneous {
}
}
}

mod key_version {
use super::*;
use crate::db::tests::{generate_test_agate_options, with_agate_test_options};

fn test_options() -> AgateOptions {
let mut options = generate_test_agate_options();
options.sync_writes = false;
options.in_memory = true;
options.mem_table_size = 4 << 20;

options
}

#[test]
fn test_memory_small_table() {
with_agate_test_options(test_options(), move |agate| {
let mut l0 = vec![];
for i in 0..10 {
l0.push(KeyValVersion::new(format!("{:05}", i), "foo", 1, 0));
}
create_and_open(agate, l0, 0);
})
}
}