KAFKA-9544; Fix flaky test `AdminClientTest.testDefaultApiTimeoutOverride` (#8101)

There is a race condition with the backoff sleep in the test case and setting the next allowed send time in the AdminClient. To fix it, we allow the test case to do the backoff sleep multiple times if needed.

Reviewers: Rajini Sivaram <rajinisivaram@googlemail.com>
This commit is contained in:
Jason Gustafson 2020-02-19 09:24:26 -08:00 committed by GitHub
parent eb7dfef245
commit 5a19fe6cd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 3 deletions

View File

@ -2740,11 +2740,14 @@ public class KafkaAdminClientTest {
// Wait for the request to be timed out before backing off
TestUtils.waitForCondition(() -> !env.kafkaClient().hasInFlightRequests(),
"Timed out waiting for inFlightRequests to be timed out");
time.sleep(retryBackoffMs);
// Since api timeout bound is not hit, AdminClient should retry
TestUtils.waitForCondition(() -> env.kafkaClient().hasInFlightRequests(),
"Timed out waiting for Metadata request to be sent");
TestUtils.waitForCondition(() -> {
boolean hasInflightRequests = env.kafkaClient().hasInFlightRequests();
if (!hasInflightRequests)
time.sleep(retryBackoffMs);
return hasInflightRequests;
}, "Timed out waiting for Metadata request to be sent");
time.sleep(requestTimeoutMs + 1);
TestUtils.assertFutureThrows(result.future, TimeoutException.class);