Skip to content

Commit

Permalink
improve assert failure message for send_data retry tests and increase…
Browse files Browse the repository at this point in the history
… tolerance for time measurements (#610)

improve assert failure message for send_data retry tests and bump
tolerance.
  • Loading branch information
ekump committed Sep 6, 2024
1 parent c48d94b commit cef5282
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions trace-utils/src/send_data/retry_strategy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,10 @@ mod tests {
use super::*;
use tokio::time::Instant;

const RETRY_STRATEGY_TIME_TOLERANCE_MS: u64 = 25;
// This tolerance is on the higher side to account for github's runners not having consistent
// performance. It shouldn't impact the quality of the tests since the most important aspect
// of the retry logic is we wait a minimum amount of time.
const RETRY_STRATEGY_TIME_TOLERANCE_MS: u64 = 100;

#[cfg_attr(miri, ignore)]
#[tokio::test]
Expand All @@ -135,7 +138,8 @@ mod tests {
&& elapsed
<= retry_strategy.delay_ms
+ Duration::from_millis(RETRY_STRATEGY_TIME_TOLERANCE_MS),
"Elapsed time was not within expected range"
"Elapsed time of {} ms was not within expected range",
elapsed.as_millis()
);

let start = Instant::now();
Expand All @@ -147,7 +151,8 @@ mod tests {
&& elapsed
<= retry_strategy.delay_ms
+ Duration::from_millis(RETRY_STRATEGY_TIME_TOLERANCE_MS),
"Elapsed time was not within expected range"
"Elapsed time of {} ms was not within expected range",
elapsed.as_millis()
);
}

Expand All @@ -170,7 +175,8 @@ mod tests {
&& elapsed
<= retry_strategy.delay_ms
+ Duration::from_millis(RETRY_STRATEGY_TIME_TOLERANCE_MS),
"Elapsed time was not within expected range"
"Elapsed time of {} ms was not within expected range",
elapsed.as_millis()
);

let start = Instant::now();
Expand All @@ -185,7 +191,8 @@ mod tests {
<= retry_strategy.delay_ms
+ (retry_strategy.delay_ms * 2)
+ Duration::from_millis(RETRY_STRATEGY_TIME_TOLERANCE_MS),
"Elapsed time was not within expected range"
"Elapsed time of {} ms was not within expected range",
elapsed.as_millis()
);
}

Expand All @@ -208,7 +215,8 @@ mod tests {
&& elapsed
<= retry_strategy.delay_ms
+ Duration::from_millis(RETRY_STRATEGY_TIME_TOLERANCE_MS),
"Elapsed time was not within expected range"
"Elapsed time of {} ms was not within expected range",
elapsed.as_millis()
);

let start = Instant::now();
Expand All @@ -221,7 +229,8 @@ mod tests {
&& elapsed
<= retry_strategy.delay_ms * 4
+ Duration::from_millis(RETRY_STRATEGY_TIME_TOLERANCE_MS),
"Elapsed time was not within expected range"
"Elapsed time of {} ms was not within expected range",
elapsed.as_millis()
);
}

Expand All @@ -246,7 +255,8 @@ mod tests {
<= retry_strategy.delay_ms
+ retry_strategy.jitter.unwrap()
+ Duration::from_millis(RETRY_STRATEGY_TIME_TOLERANCE_MS),
"Elapsed time was not within expected range"
"Elapsed time of {} ms was not within expected range",
elapsed.as_millis()
);
}

Expand Down

0 comments on commit cef5282

Please sign in to comment.