Add test for panic in load-base-split
@@ -521,6 +521,32 @@ mod tests {
}
}
+ #[test]
+ fn test_sample_key_num() {
+ let mut hub = AutoSplitController::new(SplitConfigManager::default());
+ hub.cfg.qps_threshold = 2000;
+ hub.cfg.sample_num = 2000;
+ hub.cfg.sample_threshold = 0;
+ hub.cfg.key_threshold = 0;
+ hub.cfg.size_threshold = 0;
+
+ for _ in 0..100 {
+ // qps_stats_vec contains 2000 qps and a readStats with a key range;
+ let mut qps_stats_vec = vec![];
+
+ let mut qps_stats = ReadStats::default();
+ qps_stats.add_qps(1, &Peer::default(), build_key_range(b"a", b"b", false));
+ qps_stats_vec.push(qps_stats);
+
+ let mut qps_stats = ReadStats::default();
+ for _ in 0..2000 {
+ qps_stats.add_qps(1, &Peer::default(), build_key_range(b"b", b"c", false));
+ }
+ qps_stats_vec.push(qps_stats);
+ hub.flush(qps_stats_vec);
+ }
+ }
+
fn add_region(read_stats: &mut Vec<ReadStats>, id: u64, key: u64, size: u64) {
let mut region_info = RegionInfo::new(read_stats[0].sample_num);
region_info.approximate_key = key;
