liuml07 commented on a change in pull request #3235:
URL: https://github.com/apache/hadoop/pull/3235#discussion_r693319627



##########
File path: 
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestEditLogTailer.java
##########
@@ -429,19 +431,31 @@ public void 
testStandbyTriggersLogRollsWhenTailInProgressEdits()
       waitForStandbyToCatchUpWithInProgressEdits(standby, activeTxId,
           standbyCatchupWaitTime);
 
+      long curTime = standby.getNamesystem().getEditLogTailer().getTimer()
+          .monotonicNow();
+      long inSufficientTimeForLogRoll =
+          TimeUnit.SECONDS.toMillis(logRollPeriod / 3);

Review comment:
       A few places changing this `logRollPeriod` from seconds to milliseconds. 
It seems clearer to jut rename it to `logRollPeriodMs` and use values in 
milliseconds.

##########
File path: 
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestEditLogTailer.java
##########
@@ -488,4 +509,19 @@ private static MiniDFSCluster 
createMiniDFSCluster(Configuration conf,
         .build();
     return cluster;
   }
+
+  private static final class TestTimer extends Timer {

Review comment:
       I think the common faker timer would be better if we create a new public 
constructor? Using `advance` would be more clearer when reading.
   ```
   FakeTimer fakeTimer = new 
FakeTimer(standby.getNamesystem().getEditLogTailer().getTimer().monotonicNow());
   standby.getNamesystem().getEditLogTailer().setTimerForTest(fakerTimer);
   ...
   fakeTimer.advance(inSufficientTimeForLogRoll);
   try {
       checkForLogRoll(active, origTxId, noLogRollWaitTime);
       fail("Expected to timeout");
   }
   ....
   fakeTimer.advance(sufficientTimeForLogRoll);
   checkForLogRoll(active, origTxId, logRollWaitTime);
   ```

##########
File path: 
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestEditLogTailer.java
##########
@@ -429,19 +431,31 @@ public void 
testStandbyTriggersLogRollsWhenTailInProgressEdits()
       waitForStandbyToCatchUpWithInProgressEdits(standby, activeTxId,
           standbyCatchupWaitTime);
 
+      long curTime = standby.getNamesystem().getEditLogTailer().getTimer()
+          .monotonicNow();
+      long inSufficientTimeForLogRoll =
+          TimeUnit.SECONDS.toMillis(logRollPeriod / 3);
+      TestTimer testTimer = new TestTimer(curTime + 
inSufficientTimeForLogRoll);
+      standby.getNamesystem().getEditLogTailer().setTimerForTest(testTimer);
+
       for (int i = DIRS_TO_MAKE / 2; i < DIRS_TO_MAKE; i++) {
         NameNodeAdapter.mkdirs(active, getDirPath(i),
             new PermissionStatus("test", "test",
             new FsPermission((short)00755)), true);
       }
 
-      boolean exceptionThrown = false;
       try {
         checkForLogRoll(active, origTxId, noLogRollWaitTime);
+        fail("Expected to timeout");
       } catch (TimeoutException e) {
-        exceptionThrown = true;
+        // expected
       }
-      assertTrue(exceptionThrown);
+
+      long curTimeNew = standby.getNamesystem().getEditLogTailer().getTimer()

Review comment:
       It this the `testTimer.monotinicNow()`? 




-- 
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]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to