sijie commented on a change in pull request #873: Issue280: Add StateManager to
manage Bookie's state, and use it to turn bookie into readonly when
sortedLedgerStorage failed to flush data
URL: https://github.com/apache/bookkeeper/pull/873#discussion_r158770457
##########
File path:
bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/LedgerCacheTest.java
##########
@@ -552,6 +555,53 @@ public void testEntryMemTableFlushFailure() throws
Exception {
memTable.snapshot.isEmpty());
}
+ @Test
+ public void testSortedLedgerFlushFailure() throws Exception {
+ // most of the code is same to the testEntryMemTableFlushFailure
+ File tmpDir = createTempDir("bkTest", ".dir");
+ File curDir = Bookie.getCurrentDirectory(tmpDir);
+ Bookie.checkDirectoryStructure(curDir);
+
+ int gcWaitTime = 1000;
+ ServerConfiguration conf =
TestBKConfiguration.newServerConfiguration();
+ conf.setGcWaitTime(gcWaitTime)
+ .setLedgerDirNames(new String[] { tmpDir.toString() })
+ .setJournalDirName(tmpDir.toString())
+
.setLedgerStorageClass(FlushTestSortedLedgerStorage.class.getName());
+
+ Bookie bookie = new Bookie(conf);
+ bookie.start();
+ FlushTestSortedLedgerStorage flushTestSortedLedgerStorage =
(FlushTestSortedLedgerStorage) bookie.ledgerStorage;
+ EntryMemTable memTable = flushTestSortedLedgerStorage.memTable;
+
+ bookie.addEntry(generateEntry(1, 1), new Bookie.NopWriteCallback(),
null, "passwd".getBytes());
+ flushTestSortedLedgerStorage.addEntry(generateEntry(1, 2));
+ assertFalse("Bookie is expected to be in ReadWrite mode",
bookie.isReadOnly());
+ assertTrue("EntryMemTable SnapShot is expected to be empty",
memTable.snapshot.isEmpty());
+
+ // set flags, so that FlushTestSortedLedgerStorage simulates
FlushFailure scenario
+ flushTestSortedLedgerStorage.setInjectMemTableSizeLimitReached(true);
+ flushTestSortedLedgerStorage.setInjectFlushException(true);
+ flushTestSortedLedgerStorage.addEntry(generateEntry(1, 2));
+ Thread.sleep(1000);
Review comment:
do we need to `sleep(1000)` here? can we make this test sequence more
deterministic rather than depending on time, to reduce flakiness?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services