This is an automated email from the ASF dual-hosted git repository.
baodi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/master by this push:
new 5d9ccd48520 [fix][test] Flaky-test:
ManagedLedgerTest.testTimestampOnWorkingLedger (#22600)
5d9ccd48520 is described below
commit 5d9ccd48520e0a0aa0aeb7c918f7b8ee6c866471
Author: Baodi Shi <[email protected]>
AuthorDate: Sat Apr 27 19:16:31 2024 +0800
[fix][test] Flaky-test: ManagedLedgerTest.testTimestampOnWorkingLedger
(#22600)
---
.../bookkeeper/mledger/impl/ManagedLedgerTest.java | 25 +++++++++++-----------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git
a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerTest.java
b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerTest.java
index 22cf4d8b7a7..e983523c1b6 100644
---
a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerTest.java
+++
b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerTest.java
@@ -2446,7 +2446,7 @@ public class ManagedLedgerTest extends
MockedBookKeeperTestCase {
});
}
- @Test(groups = "flaky")
+ @Test
public void testTimestampOnWorkingLedger() throws Exception {
ManagedLedgerConfig conf = new ManagedLedgerConfig();
conf.setMaxEntriesPerLedger(1);
@@ -2473,19 +2473,18 @@ public class ManagedLedgerTest extends
MockedBookKeeperTestCase {
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