Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt to dodge flakiness in heavy_tasks_doesnt_block_graphql test #2437

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
Loading