Skip to content

Commit 08d3732

Browse files
committed
fix unit test.
Signed-off-by: root <[email protected]>
1 parent b1ae686 commit 08d3732

File tree

1 file changed

+8
-56
lines changed

1 file changed

+8
-56
lines changed

Diff for: src/engine.rs

+8-56
Original file line numberDiff line numberDiff line change
@@ -336,19 +336,13 @@ where
336336
memtable
337337
.read()
338338
.fetch_entries_to(begin, end, max_size, &mut ents_idx)?;
339-
println!(
340-
"[fetch_entries_to_aio] (stage1) time cost: {:?} us",
341-
start.elapsed().as_micros()
342-
);
339+
343340

344341
let bytes = self.pipe_log.async_read_bytes(&mut ents_idx).unwrap();
345342
parse_entries_from_bytes::<M>(bytes, &mut ents_idx, vec);
346343

347344
ENGINE_READ_ENTRY_COUNT_HISTOGRAM.observe(ents_idx.len() as f64);
348-
println!(
349-
"[fetch_entries_to_aio] (end) time cost: {:?} us",
350-
start.elapsed().as_micros()
351-
);
345+
352346
return Ok(ents_idx.len());
353347
}
354348

@@ -846,66 +840,24 @@ mod tests {
846840
assert_eq!(d, &data);
847841
});
848842
}
849-
850-
// Recover the engine.
851-
let engine = engine.reopen();
852843
for i in 10..20 {
853844
let rid = i;
854845
let index = i;
855-
engine.scan_entries(rid, index, index + 2, |_, q, d| {
846+
engine.scan_entries_aio(rid, index, index + 2, |_, q, d| {
856847
assert_eq!(q, LogQueue::Append);
857848
assert_eq!(d, &data);
858849
});
859850
}
860-
}
861-
}
862851

863-
#[test]
864-
fn test_async_read() {
865-
let normal_batch_size = 10;
866-
let compressed_batch_size = 5120;
867-
for &entry_size in &[normal_batch_size] {
868-
if entry_size == normal_batch_size {
869-
println!("[normal_batch_size]");
870-
} else if entry_size == compressed_batch_size {
871-
println!("[compressed_batch_size]");
872-
}
873-
let dir = tempfile::Builder::new()
874-
.prefix("test_get_entry")
875-
.tempdir()
876-
.unwrap();
877-
let cfg = Config {
878-
dir: dir.path().to_str().unwrap().to_owned(),
879-
target_file_size: ReadableSize::gb(1),
880-
..Default::default()
881-
};
882-
883-
let engine =
884-
RaftLogEngine::open_with_file_system(cfg.clone(), Arc::new(DefaultFileSystem))
885-
.unwrap();
886-
887-
assert_eq!(engine.path(), dir.path().to_str().unwrap());
888-
let data = vec![b'x'; entry_size];
889-
for i in 10..1010 {
890-
for rid in 10..15 {
891-
let index = i;
892-
engine.append(rid, index, index + 1, Some(&data));
893-
}
894-
}
895-
for i in 10..15 {
852+
// Recover the engine.
853+
let engine = engine.reopen();
854+
for i in 10..20 {
896855
let rid = i;
897-
let index = 10;
898-
println!("[PREAD]");
899-
engine.scan_entries(rid, index, index + 1000, |_, q, d| {
900-
assert_eq!(q, LogQueue::Append);
901-
assert_eq!(d, &data);
902-
});
903-
println!("[AIO]");
904-
engine.scan_entries_aio(rid, index, index + 1000, |_, q, d| {
856+
let index = i;
857+
engine.scan_entries(rid, index, index + 2, |_, q, d| {
905858
assert_eq!(q, LogQueue::Append);
906859
assert_eq!(d, &data);
907860
});
908-
println!("====================================================================================");
909861
}
910862
}
911863
}

0 commit comments

Comments
 (0)