hangc0276 commented on code in PR #3212:
URL: https://github.com/apache/bookkeeper/pull/3212#discussion_r857122652
##########
bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/LedgerDirsManagerTest.java:
##########
@@ -240,6 +240,76 @@ private void testLedgerDirsMonitorDuringTransition(boolean
highPriorityWritesAll
assertTrue(mockLedgerDirsListener.highPriorityWritesAllowed);
}
+ @Test
+ public void testIsReadOnlyModeOnAnyDiskFullEnabled() throws Exception {
+ testAnyLedgerFullTransitToReadOnly(true);
+ testAnyLedgerFullTransitToReadOnly(false);
+ }
+
+ public void testAnyLedgerFullTransitToReadOnly(boolean
isReadOnlyModeOnAnyDiskFullEnabled) throws Exception {
+ ledgerMonitor.shutdown();
+
+ final float nospace = 0.90f;
+ final float lwm = 0.80f;
+ HashMap<File, Float> usageMap;
+
+ File tmpDir1 = createTempDir("bkTest", ".dir");
+ File curDir1 = BookieImpl.getCurrentDirectory(tmpDir1);
+ BookieImpl.checkDirectoryStructure(curDir1);
+
+ File tmpDir2 = createTempDir("bkTest", ".dir");
+ File curDir2 = BookieImpl.getCurrentDirectory(tmpDir2);
+ BookieImpl.checkDirectoryStructure(curDir2);
+
+ conf.setDiskUsageThreshold(nospace);
+ conf.setDiskLowWaterMarkUsageThreshold(lwm);
+ conf.setDiskUsageWarnThreshold(nospace);
+
conf.setReadOnlyModeOnAnyDiskFullEnabled(isReadOnlyModeOnAnyDiskFullEnabled);
+ conf.setLedgerDirNames(new String[] { tmpDir1.toString(),
tmpDir2.toString() });
+
+ mockDiskChecker = new MockDiskChecker(nospace, warnThreshold);
+ dirsManager = new LedgerDirsManager(conf, conf.getLedgerDirs(),
+ new DiskChecker(conf.getDiskUsageThreshold(),
conf.getDiskUsageWarnThreshold()), statsLogger);
+ ledgerMonitor = new LedgerDirsMonitor(conf, mockDiskChecker,
Collections.singletonList(dirsManager));
+ usageMap = new HashMap<>();
+ usageMap.put(curDir1, 0.1f);
+ usageMap.put(curDir2, 0.1f);
+ mockDiskChecker.setUsageMap(usageMap);
+ ledgerMonitor.init();
+ final MockLedgerDirsListener mockLedgerDirsListener = new
MockLedgerDirsListener();
+ dirsManager.addLedgerDirsListener(mockLedgerDirsListener);
+ ledgerMonitor.start();
+
+ Thread.sleep((diskCheckInterval * 2) + 100);
+ assertFalse(mockLedgerDirsListener.readOnly);
Review Comment:
In BookKeeper code, there are a lot of `Thread.sleep`. I will use another PR
to introduce awaitility to make all tests get ride of `Thread.sleep`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]