Skip to content

Commit

Permalink
[fix][test] Flaky-test: ManagedLedgerTest.testTimestampOnWorkingLedger (
Browse files Browse the repository at this point in the history
apache#22600)

(cherry picked from commit 5d9ccd4)
  • Loading branch information
shibd committed Apr 27, 2024
1 parent 7cc99df commit cdd50a4
Showing 1 changed file with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2446,7 +2446,7 @@ public void testRetentionSize() throws Exception {
});
}

@Test(groups = "flaky")
@Test
public void testTimestampOnWorkingLedger() throws Exception {
ManagedLedgerConfig conf = new ManagedLedgerConfig();
conf.setMaxEntriesPerLedger(1);
Expand All @@ -2473,19 +2473,18 @@ public void testTimestampOnWorkingLedger() throws Exception {

ml.addEntry("msg02".getBytes());

// reopen a new ml2
ml.close();
// Thread.sleep(1000);
iter = ml.getLedgersInfoAsList().iterator();
ts = -1;
while (iter.hasNext()) {
LedgerInfo i = iter.next();
if (iter.hasNext()) {
assertTrue(ts <= i.getTimestamp(), i.toString());
ts = i.getTimestamp();
} else {
assertTrue(i.getTimestamp() > 0, "well closed LedgerInfo should set a timestamp > 0");
}
}
ManagedLedgerImpl ml2 = (ManagedLedgerImpl) factory.open("my_test_ledger", conf);

List<LedgerInfo> ledgers = ml2.getLedgersInfoAsList();
// after reopen ledgers will be 2 + 1(new open, not contain any entries)
assertEquals(ledgers.size(), 3);

// the last closed ledger should be the penultimate one.
LedgerInfo lastClosedLeger = ledgers.get(ledgers.size() - 2);
assertTrue(lastClosedLeger.getTimestamp() > 0, "well closed LedgerInfo should set a timestamp > 0");
ml2.close();
}

@Test
Expand Down

0 comments on commit cdd50a4

Please sign in to comment.