mirror of https://github.com/apache/kafka.git
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:
parent
eb7dfef245
commit
5a19fe6cd1
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue