Skip to content

Commit

Permalink
Attempt to dodge flakiness in heavy_tasks_doesnt_block_graphql test
Browse files Browse the repository at this point in the history
  • Loading branch information
rafal-ch committed Nov 14, 2024
1 parent ba0fa15 commit e87165e
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions tests/tests/dos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ async fn heavy_tasks_doesnt_block_graphql() {
client.produce_blocks(NUM_OF_BLOCKS, None).await.unwrap();

// Given
for _ in 0..50 {
for _ in 0..150 {
let url = url.clone();
let query = query.clone();
tokio::spawn(async move {
Expand All @@ -713,11 +713,27 @@ async fn heavy_tasks_doesnt_block_graphql() {
// Wait for all queries to start be processed on the node.
tokio::time::sleep(Duration::from_secs(1)).await;

const RETRIES: u32 = 3;
const TIMEOUT_SECS: u64 = 4;

// When
let result = tokio::time::timeout(Duration::from_secs(5), client.health()).await;
let mut retries = RETRIES;
let result = loop {
if retries == 0 {
panic!("Health check timed out after 3 retries");
}

match tokio::time::timeout(Duration::from_secs(TIMEOUT_SECS), client.health())
.await
{
Ok(result) => break result,
Err(_) => retries -= 1,
}

// Intentionally no sleep between retries, try ASAP to make sure that the node is still under load.
};

// Then
let result = result.expect("Health check timed out");
let health = result.expect("Health check failed");
assert!(health);
}

0 comments on commit e87165e

Please sign in to comment.