Skip to content

Commit

Permalink
utils: bugfix for unit test case.
Browse files Browse the repository at this point in the history
Signed-off-by: weizhen.zt <wodemia@linux.alibaba.com>
  • Loading branch information
weizhen.zt authored and jiangliu committed Nov 9, 2023
1 parent c608ef6 commit b572a0f
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions utils/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -966,16 +966,18 @@ mod tests {
assert_eq!(f.latency_start(), None);
f.measure_latency.store(true, Ordering::Relaxed);
let s = f.latency_start().unwrap();
let d = Duration::new(2, 0);
let d = Duration::new(1, 500_000_000);
/* because of the timer resolution, the elapsed maybe greater than 1.5s gentlely*/
f.latency_end(&s.checked_sub(d), StatsFop::Read);

assert_eq!(
f.read_latency_dist[latency_micros_range_index(2 * 1000 * 1000)].count(),
f.read_latency_dist[latency_micros_range_index(1_500_000)].count(),
1
);
assert_eq!(
f.fop_cumulative_latency_total[StatsFop::Read as usize].count(),
saturating_duration_micros(&d)
/* we think if the latency delta error no more 1ms, the test is successful. */
assert!(
f.fop_cumulative_latency_total[StatsFop::Read as usize].count()
- saturating_duration_micros(&d)
<= 1000
);
}

Expand Down

0 comments on commit b572a0f

Please sign in to comment.