This is an automated email from the ASF dual-hosted git repository. penghui pushed a commit to branch branch-2.10 in repository https://gitbox.apache.org/repos/asf/pulsar.git
commit 3e83a5c464f1c7c7244b5a7af46a28c5e7e5a5b3 Author: Zixuan Liu <[email protected]> AuthorDate: Tue Jul 26 00:10:25 2022 +0800 [fix][flaky-test] Fix BacklogQuotaManagerTest.testConsumerBacklogEvictionTimeQuotaWithEmptyLedger (#16735) (cherry picked from commit 70530d4d479ea3d4574b9f383ea5edd0fa978d64) --- .../broker/service/BacklogQuotaManagerTest.java | 35 ++++++++++------------ 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BacklogQuotaManagerTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BacklogQuotaManagerTest.java index 0cbd2c1b2e7..42a22de1c42 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BacklogQuotaManagerTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BacklogQuotaManagerTest.java @@ -536,30 +536,27 @@ public class BacklogQuotaManagerTest { consumer.receive(); admin.topics().unload(topic); - Awaitility.await().until(consumer::isConnected); - PersistentTopicInternalStats internalStats = admin.topics().getInternalStats(topic); - assertEquals(internalStats.ledgers.size(), 2); - assertEquals(internalStats.ledgers.get(1).entries, 0); + + Awaitility.await().untilAsserted(() -> { + PersistentTopicInternalStats internalStats = admin.topics().getInternalStats(topic); + assertEquals(internalStats.ledgers.size(), 2); + assertEquals(internalStats.ledgers.get(1).entries, 0); + }); TopicStats stats = getTopicStats(topic); assertEquals(stats.getSubscriptions().get(subName).getMsgBacklog(), 1); - TimeUnit.SECONDS.sleep(TIME_TO_CHECK_BACKLOG_QUOTA); - - Awaitility.await() - .pollInterval(Duration.ofSeconds(1)) - .atMost(Duration.ofSeconds(TIME_TO_CHECK_BACKLOG_QUOTA)) - .untilAsserted(() -> { - rolloverStats(); + rolloverStats(); - // Cause the last ledger is empty, it is not possible to skip first ledger, - // so the number of ledgers will keep unchanged, and backlog is clear - PersistentTopicInternalStats latestInternalStats = admin.topics().getInternalStats(topic); - assertEquals(latestInternalStats.ledgers.size(), 2); - assertEquals(latestInternalStats.ledgers.get(1).entries, 0); - TopicStats latestStats = getTopicStats(topic); - assertEquals(latestStats.getSubscriptions().get(subName).getMsgBacklog(), 0); - }); + Awaitility.await().untilAsserted(() -> { + // Cause the last ledger is empty, it is not possible to skip first ledger, + // so the number of ledgers will keep unchanged, and backlog is clear + PersistentTopicInternalStats latestInternalStats = admin.topics().getInternalStats(topic); + assertEquals(latestInternalStats.ledgers.size(), 2); + assertEquals(latestInternalStats.ledgers.get(1).entries, 0); + TopicStats latestStats = getTopicStats(topic); + assertEquals(latestStats.getSubscriptions().get(subName).getMsgBacklog(), 0); + }); client.close(); }
