Skip to content

Commit 58f4ed5

Browse files
authored
chore(meta-test): fix inaccurate expire time in test (#18025)
The actual expire time is calculated by adding the current timestamp and a duration. When the test runs on a heavily load CI nodes, the actual expire time may be inaccurate due to timing variations. In this commit, we add some tolerance to the expire time comparison.
1 parent d87b65c commit 58f4ed5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/meta/service/tests/it/grpc/metasrv_grpc_watch.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,8 +523,12 @@ async fn test_watch_expired_events() -> anyhow::Result<()> {
523523
for i in 0..(32 + 1) {
524524
let k = format!("w_auto_gc_{}", i);
525525
let want = del_event(&k, 1 + i, &k, Some(KvMeta::new_expire(now_sec + 1)));
526+
let want2 = del_event(&k, 1 + i, &k, Some(KvMeta::new_expire(now_sec + 2)));
526527
let msg = client_stream.message().await?.unwrap();
527-
assert_eq!(Some(want), msg.event);
528+
assert!(Some(want.clone()) == msg.event || Some(want2.clone()) == msg.event,
529+
"expect {:?} equals {:?} or {:?}; the expire time is not accurate, so we need to check both",
530+
msg.event, want, want2
531+
);
528532
}
529533

530534
// Check event generated when applying the txn

0 commit comments

Comments
 (0)