Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix][test] Flaky-test: ManagedLedgerTest.testTimestampOnWorkingLedger #22600

Merged
merged 2 commits into from Apr 27, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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,17 @@ 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);
shibd marked this conversation as resolved.
Show resolved Hide resolved

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");
}

@Test
Expand Down