From f667f573ff12321f2913ccf17cdf9e9bcc97b550 Mon Sep 17 00:00:00 2001 From: Stanislav Kozlovski Date: Wed, 27 Feb 2019 20:36:49 +0000 Subject: [PATCH] Address flakiness of CustomQuotaCallbackTest#testCustomQuotaCallback (#6330) --- .../integration/kafka/api/CustomQuotaCallbackTest.scala | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/src/test/scala/integration/kafka/api/CustomQuotaCallbackTest.scala b/core/src/test/scala/integration/kafka/api/CustomQuotaCallbackTest.scala index fed5380afee..8c1d34ddc2c 100644 --- a/core/src/test/scala/integration/kafka/api/CustomQuotaCallbackTest.scala +++ b/core/src/test/scala/integration/kafka/api/CustomQuotaCallbackTest.scala @@ -81,6 +81,7 @@ class CustomQuotaCallbackTest extends IntegrationTestHarness with SaslSetup { @After override def tearDown(): Unit = { adminClients.foreach(_.close()) + GroupedUserQuotaCallback.tearDown() super.tearDown() } @@ -102,7 +103,7 @@ class CustomQuotaCallbackTest extends IntegrationTestHarness with SaslSetup { // ClientQuotaCallback#quotaLimit is invoked by each quota manager once for each new client assertEquals(1, quotaLimitCalls(ClientQuotaType.PRODUCE).get) assertEquals(1, quotaLimitCalls(ClientQuotaType.FETCH).get) - assertTrue(s"Too many quotaLimit calls $quotaLimitCalls", quotaLimitCalls(ClientQuotaType.REQUEST).get <= serverCount) + assertTrue(s"Too many quotaLimit calls $quotaLimitCalls", quotaLimitCalls(ClientQuotaType.REQUEST).get <= 10) // sanity check // Large quota updated to small quota, should throttle user.configureAndWaitForQuota(9000, 3000) user.produceConsume(expectProduceThrottle = true, expectConsumeThrottle = true) @@ -321,6 +322,12 @@ object GroupedUserQuotaCallback { ClientQuotaType.REQUEST -> new AtomicInteger ) val callbackInstances = new AtomicInteger + + def tearDown(): Unit = { + callbackInstances.set(0) + quotaLimitCalls.values.foreach(_.set(0)) + UnlimitedQuotaMetricTags.clear() + } } /**