Skip to content

Commit

Permalink
Previous fix wasn't effective (#3183)
Browse files Browse the repository at this point in the history
  • Loading branch information
inahga committed May 29, 2024
1 parent 902b992 commit 7d3a0ec
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions integration_tests/tests/integration/in_cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -705,18 +705,18 @@ mod rate_limits {

for handle in handles {
let (retry_after, status) = handle.await.unwrap();
// Every request this test send should get rejected due to a missing body if it gets
// past the rate limiter.
if status.is_client_error() {
assert!(retry_after.is_none());
acceptable_status_count += 1
} else if status == StatusCode::TOO_MANY_REQUESTS {
if status == StatusCode::TOO_MANY_REQUESTS {
assert_matches!(retry_after, Some(retry_after) => {
let retry_after = retry_after.to_str().unwrap().parse::<u64>().unwrap();
assert!(retry_after <= test_config.window);
last_retry_after = Some(retry_after);
});
too_many_requests_count += 1
// Every request this test send should get rejected due to a missing body if it gets
// past the rate limiter.
} else if status.is_client_error() {
assert!(retry_after.is_none());
acceptable_status_count += 1
} else {
panic!("unexpected status {status:?}");
}
Expand All @@ -732,7 +732,7 @@ mod rate_limits {
ratio > expected_429_rate - 0.05 && ratio <= expected_429_rate + 0.05,
"ratio: {ratio} expected 429 rate: {expected_429_rate} \
count of HTTP 429: {too_many_requests_count} \
count of HTTP 400: {acceptable_status_count}",
count of HTTP 4xx: {acceptable_status_count}",
);

let last_retry_after = assert_matches!(last_retry_after, Some(l) => l);
Expand All @@ -743,7 +743,8 @@ mod rate_limits {
for url in [first_request_url.clone(), second_request_url.clone()] {
let method = method.clone();
let response = client.request(method, url).send().await.unwrap();
assert_eq!(response.status(), StatusCode::BAD_REQUEST);
assert!(response.status() != StatusCode::TOO_MANY_REQUESTS);
assert!(response.status().is_client_error());
assert!(response.headers().get("retry-after").is_none());
}
}
Expand Down

0 comments on commit 7d3a0ec

Please sign in to comment.