sodonnel commented on a change in pull request #2382:
URL: https://github.com/apache/ozone/pull/2382#discussion_r671312241



##########
File path: 
hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/TestReplicationManager.java
##########
@@ -897,6 +1061,63 @@ public void 
testOverReplicatedAndPolicyUnSatisfiedAndDeleted() throws
     Thread.sleep(100L);
     Assert.assertEquals(currentDeleteCommandCount + 2, datanodeCommandHandler
         .getInvocationCount(SCMCommandProto.Type.deleteContainerCommand));
+    Assert.assertEquals(currentDeleteCommandCount + 2,
+        replicationManager.getMetrics().getNumDeletionCmdsSent());
+    Assert.assertEquals(1, replicationManager.getInflightDeletion().size());
+    Assert.assertEquals(1, replicationManager.getMetrics()
+        .getInflightDeletion());
+  }
+
+  @Test
+  public void testReplicateCommandTimeout() throws
+      SCMException, ContainerNotFoundException, InterruptedException {
+    replicationManager.stop();
+    ReplicationManagerConfiguration newConf =
+        new ReplicationManagerConfiguration();
+    // Set a short timeout
+    newConf.setEventTimeout(Duration.ofSeconds(1));
+    createReplicationManager(newConf);
+    final ContainerInfo container = createContainer(LifeCycleState.CLOSED);
+    addReplica(container, new NodeStatus(IN_SERVICE, HEALTHY), CLOSED);
+    addReplica(container, new NodeStatus(IN_SERVICE, HEALTHY), CLOSED);
+    assertReplicaScheduled(1);
+
+    // Make a timeout
+    Thread.sleep(2000);
+
+    replicationManager.processContainersNow();
+    // Wait for EventQueue to call the event handler
+    Thread.sleep(100L);
+
+    Assert.assertEquals(1, replicationManager.getMetrics()
+        .getNumReplicationCmdsTimeout());
+  }
+
+  @Test
+  public void testDeleteCommandTimeout() throws
+      SCMException, ContainerNotFoundException, InterruptedException {
+    replicationManager.stop();
+    ReplicationManagerConfiguration newConf =
+        new ReplicationManagerConfiguration();
+    // Set a short timeout
+    newConf.setEventTimeout(Duration.ofSeconds(1));
+    createReplicationManager(newConf);
+    final ContainerInfo container = createContainer(LifeCycleState.CLOSED);
+    addReplica(container, new NodeStatus(IN_SERVICE, HEALTHY), CLOSED);
+    addReplica(container, new NodeStatus(IN_SERVICE, HEALTHY), CLOSED);
+    addReplica(container, new NodeStatus(IN_SERVICE, HEALTHY), CLOSED);
+    addReplica(container, new NodeStatus(IN_SERVICE, HEALTHY), CLOSED);
+    assertDeleteScheduled(1);
+
+    // Make a timeout
+    Thread.sleep(2000);

Review comment:
       I'd like to avoid these sleeps in the tests. I have created #2425 to add 
a Clock into Replication Manager. If we can get that reviewed and committed 
then we can rebase this patch and remove the timeouts.




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