adoroszlai commented on code in PR #5516:
URL: https://github.com/apache/ozone/pull/5516#discussion_r1382949475


##########
hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/node/TestSCMNodeManager.java:
##########
@@ -217,6 +219,7 @@ SCMNodeManager createNodeManager(OzoneConfiguration config)
   @Test
   public void testScmHeartbeat()
       throws IOException, InterruptedException, AuthenticationException {
+    TestClock testClock = TestClock.newInstance();

Review Comment:
   `SCMNodeManager` does not know about this `testClock`, its `systemClock` is 
always a real one.  So SCM sees the actual time, even if the test fast-forwards 
its test clock.
   
   We need to allow the test to pass its `TestClock` to 
`StorageContainerManager`.  This can be achieved by the following:
   
   1. add a `Clock` to `SCMConfigurator`
   
   2. set `systemClock` in `StorageContainerManager` conditionally similar to 
how it takes other objects from the configurator (i.e. set from the 
configurator, if it has a clock, otherwise using the existing code)
   
   
https://github.com/apache/ozone/blob/08131b9addc719551a8e4d8c1846f8c8f11bd62c/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/StorageContainerManager.java#L637-L643
   
   Example:
   
   ```
    if (configurator.getClock() != null) {
      systemClock = configurator.getClock();
    } else {
      // Use SystemClock when data is persisted
      // and used again after system restarts.
      systemClock = Clock.system(ZoneOffset.UTC);
    }
   ```
   
   3. Add a new version of `HddsTestUtils.getScm()` to allow passing a `Clock`:
   
   
https://github.com/apache/ozone/blob/08131b9addc719551a8e4d8c1846f8c8f11bd62c/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/HddsTestUtils.java#L617



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