Skip to content

Commit

Permalink
[fix] [test] Fix flaky test ManagedLedgerTest.testGetNumberOfEntriesI…
Browse files Browse the repository at this point in the history
…nStorage (apache#22344)

(cherry picked from commit fc066d7)
(cherry picked from commit 100a53b)
  • Loading branch information
poorbarcode authored and mukesh-ctds committed Apr 17, 2024
1 parent 0cea3a0 commit 5c6d6c8
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2636,10 +2636,10 @@ public void testGetNumberOfEntriesInStorage() throws Exception {
managedLedger.addEntry(("entry-" + i).getBytes(Encoding));
}

//trigger ledger rollover and wait for the new ledger created
Field stateUpdater = ManagedLedgerImpl.class.getDeclaredField("state");
stateUpdater.setAccessible(true);
stateUpdater.set(managedLedger, ManagedLedgerImpl.State.LedgerOpened);
// trigger ledger rollover and wait for the new ledger created
Awaitility.await().untilAsserted(() -> {
assertEquals("LedgerOpened", WhiteboxImpl.getInternalState(managedLedger, "state").toString());
});
managedLedger.rollCurrentLedgerIfFull();
Awaitility.await().untilAsserted(() -> {
assertEquals(managedLedger.getLedgersInfo().size(), 3);
Expand Down

0 comments on commit 5c6d6c8

Please sign in to comment.