Skip to content

Commit

Permalink
Fix flaky kv test
Browse files Browse the repository at this point in the history
Signed-off-by: Tomasz Pietrek <[email protected]>
  • Loading branch information
Jarema committed Mar 4, 2024
1 parent db70181 commit 22a9718
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions async-nats/tests/kv_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -834,17 +834,22 @@ mod kv {
.unwrap();

kv.put("baz", "value".into()).await.unwrap();
tokio::time::sleep(Duration::from_millis(300)).await;
assert_eq!(
kv.keys()
.await
.unwrap()
.try_collect::<Vec<String>>()
.await
.unwrap()
.len(),
0
);
tryhard::retry_fn(|| async {
match kv.keys().await {
Ok(keys) => {
let keys = keys.try_collect::<Vec<String>>().await.unwrap();
if !keys.is_empty() {
return Err("keys not empty".into());
}
Ok::<(), async_nats::Error>(())
}
Err(e) => Err(e.into()),
}
})
.retries(5)
.exponential_backoff(Duration::from_millis(100))
.await
.unwrap();
}

#[tokio::test]
Expand Down

0 comments on commit 22a9718

Please sign in to comment.