Add small random delay to async test for stress-testing

This commit is contained in:
Kodi Craft 2024-06-21 12:48:52 +02:00
parent 7c2c03aa40
commit 374e50ee6b
Signed by: kodi
GPG Key ID: 69D9EED60B242822

View File

@ -97,6 +97,10 @@ async fn heavy_async() {
for i in 0..100 { for i in 0..100 {
let client = client.clone(); let client = client.clone();
tasks.push(tokio::spawn(async move { tasks.push(tokio::spawn(async move {
tokio::time::sleep(tokio::time::Duration::from_millis(
rand::random::<u64>() % 100,
))
.await;
let result = client.addition(i, i).await.unwrap(); let result = client.addition(i, i).await.unwrap();
assert_eq!(result, i + i); assert_eq!(result, i + i);
})); }));