Skip to content

Commit

Permalink
[Flaky-test] BacklogQuotaManagerTest#testConsumerBacklogEvictionTimeQ…
Browse files Browse the repository at this point in the history
…uota (apache#14000)

* fix flaky test

* change to getCurrentLedgerEntries

Co-authored-by: gavingaozhangmin <[email protected]>

### Motivation

Fixes apache#13952

### Modifications
MAX_ENTRIES_PER_LEDGER = 5,  it will be  uncertain that  the num of entries in last ledger is 4.
Use ManagedLedgerImpl. getNumberOfEntries to get the num of entries in last opened ledger
  • Loading branch information
gaozhangmin authored and nicklixinyang committed Apr 20, 2022
1 parent a4456c1 commit 7871dc8
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import lombok.Cleanup;
import org.apache.bookkeeper.mledger.impl.ManagedLedgerImpl;
import org.apache.pulsar.broker.PulsarService;
import org.apache.pulsar.broker.ServiceConfiguration;
import org.apache.pulsar.broker.service.persistent.PersistentTopic;
import org.apache.pulsar.client.admin.PulsarAdmin;
import org.apache.pulsar.client.api.Consumer;
import org.apache.pulsar.client.api.Message;
Expand Down Expand Up @@ -475,10 +477,12 @@ public void testConsumerBacklogEvictionTimeQuota() throws Exception {
rolloverStats();

stats = admin.topics().getStats(topic1);
PersistentTopic topic1Reference = (PersistentTopic) pulsar.getBrokerService().getTopicReference(topic1).get();
ManagedLedgerImpl ml = (ManagedLedgerImpl) topic1Reference.getManagedLedger();
// Messages on first 2 ledgers should be expired, backlog is number of
// message in current ledger which should be 4.
assertEquals(stats.getSubscriptions().get(subName1).getMsgBacklog(), 4);
assertEquals(stats.getSubscriptions().get(subName2).getMsgBacklog(), 4);
// message in current ledger.
assertEquals(stats.getSubscriptions().get(subName1).getMsgBacklog(), ml.getCurrentLedgerEntries());
assertEquals(stats.getSubscriptions().get(subName2).getMsgBacklog(), ml.getCurrentLedgerEntries());
client.close();
}

Expand Down

0 comments on commit 7871dc8

Please sign in to comment.