Skip to content

Commit

Permalink
remove redundant code
Browse files Browse the repository at this point in the history
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
  • Loading branch information
BugenZhao committed Oct 24, 2022
1 parent db7e33f commit 9797e93
Showing 1 changed file with 19 additions and 56 deletions.
75 changes: 19 additions & 56 deletions src/storage/hummock_test/src/snapshot_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,14 @@ use crate::test_utils::get_test_notification_client;

macro_rules! assert_count_range_scan {
($storage:expr, $range:expr, $expect_count:expr, $epoch:expr) => {{
use std::ops::RangeBounds;
let range = $range;
let bounds: (Bound<Vec<u8>>, Bound<Vec<u8>>) =
(range.start_bound().cloned(), range.end_bound().cloned());
let mut it = $storage
.iter(
None,
$range,
bounds,
ReadOptions {
epoch: $epoch,
table_id: Default::default(),
Expand All @@ -56,9 +60,13 @@ macro_rules! assert_count_range_scan {

macro_rules! assert_count_backward_range_scan {
($storage:expr, $range:expr, $expect_count:expr, $epoch:expr) => {{
use std::ops::RangeBounds;
let range = $range;
let bounds: (Bound<Vec<u8>>, Bound<Vec<u8>>) =
(range.start_bound().cloned(), range.end_bound().cloned());
let mut it = $storage
.backward_iter(
$range,
bounds,
ReadOptions {
epoch: $epoch,
table_id: Default::default(),
Expand Down Expand Up @@ -128,12 +136,7 @@ async fn test_snapshot_inner(enable_sync: bool, enable_commit: bool) {
.unwrap();
}
}
assert_count_range_scan!(
hummock_storage,
(Bound::Unbounded, Bound::Unbounded),
2,
epoch1
);
assert_count_range_scan!(hummock_storage, .., 2, epoch1);

let epoch2 = epoch1 + 1;
hummock_storage
Expand Down Expand Up @@ -167,18 +170,8 @@ async fn test_snapshot_inner(enable_sync: bool, enable_commit: bool) {
.unwrap();
}
}
assert_count_range_scan!(
hummock_storage,
(Bound::Unbounded, Bound::Unbounded),
3,
epoch2
);
assert_count_range_scan!(
hummock_storage,
(Bound::Unbounded, Bound::Unbounded),
2,
epoch1
);
assert_count_range_scan!(hummock_storage, .., 3, epoch2);
assert_count_range_scan!(hummock_storage, .., 2, epoch1);

let epoch3 = epoch2 + 1;
hummock_storage
Expand Down Expand Up @@ -212,24 +205,9 @@ async fn test_snapshot_inner(enable_sync: bool, enable_commit: bool) {
.unwrap();
}
}
assert_count_range_scan!(
hummock_storage,
(Bound::Unbounded, Bound::Unbounded),
0,
epoch3
);
assert_count_range_scan!(
hummock_storage,
(Bound::Unbounded, Bound::Unbounded),
3,
epoch2
);
assert_count_range_scan!(
hummock_storage,
(Bound::Unbounded, Bound::Unbounded),
2,
epoch1
);
assert_count_range_scan!(hummock_storage, .., 0, epoch3);
assert_count_range_scan!(hummock_storage, .., 3, epoch2);
assert_count_range_scan!(hummock_storage, .., 2, epoch1);
}

async fn test_snapshot_range_scan_inner(enable_sync: bool, enable_commit: bool) {
Expand Down Expand Up @@ -320,12 +298,7 @@ async fn test_snapshot_range_scan_inner(enable_sync: bool, enable_commit: bool)
2,
epoch
);
assert_count_range_scan!(
hummock_storage,
(Bound::Unbounded, Bound::Unbounded),
4,
epoch
);
assert_count_range_scan!(hummock_storage, .., 4, epoch);
}

#[ignore]
Expand Down Expand Up @@ -451,18 +424,8 @@ async fn test_snapshot_backward_range_scan_inner(enable_sync: bool, enable_commi
3,
epoch
);
assert_count_backward_range_scan!(
hummock_storage,
(Bound::Unbounded, Bound::Unbounded),
6,
epoch
);
assert_count_backward_range_scan!(
hummock_storage,
(Bound::Unbounded, Bound::Unbounded),
8,
epoch + 1
);
assert_count_backward_range_scan!(hummock_storage, .., 6, epoch);
assert_count_backward_range_scan!(hummock_storage, .., 8, epoch + 1);
assert_count_backward_range_scan!(
hummock_storage,
(Bound::Included(key!(7)), Bound::Excluded(key!(2))),
Expand Down

0 comments on commit 9797e93

Please sign in to comment.