KAFKA-10874: Fix flaky ClientQuotasRequestTest.testAlterIpQuotasRequest (#9778)

Reviewers: Chia-Ping Tsai <chia7712@gmail.com>, David Jacot <djacot@confluent.io>
This commit is contained in:
Geordie 2021-01-07 16:46:07 +08:00 committed by GitHub
parent 22e8e71156
commit 71540c03b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions

View File

@ -29,6 +29,8 @@ import org.junit.Test
import java.util
import java.util.concurrent.{ExecutionException, TimeUnit}
import kafka.utils.TestUtils
import scala.jdk.CollectionConverters._
class ClientQuotasRequestTest extends BaseRequestTest {
@ -212,7 +214,12 @@ class ClientQuotasRequestTest extends BaseRequestTest {
InetAddress.getByName(unknownHost)
else
InetAddress.getByName(entityName)
assertEquals(expectedMatches(entity), servers.head.socketServer.connectionQuotas.connectionRateForIp(entityIp), 0.01)
var currentServerQuota = 0
TestUtils.waitUntilTrue(
() => {
currentServerQuota = servers.head.socketServer.connectionQuotas.connectionRateForIp(entityIp)
Math.abs(expectedMatches(entity) - currentServerQuota) < 0.01
}, s"Connection quota of $entity is not ${expectedMatches(entity)} but $currentServerQuota")
}
}