sodonnel commented on code in PR #3497:
URL: https://github.com/apache/ozone/pull/3497#discussion_r1040956216


##########
hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/replication/TestReplicationSupervisor.java:
##########
@@ -227,6 +227,34 @@ public void slowDownload() {
     }
   }
 
+  @Test
+  public void testTimeoutTask() {
+    // GIVEN
+    ReplicationSupervisor supervisor = supervisorWith(__ -> slowReplicator,
+        new ThreadPoolExecutor(1, 1, 60, TimeUnit.SECONDS,
+            new LinkedBlockingQueue<>()));
+
+    try {
+      //WHEN
+      supervisor.addTask(new ReplicationTask(1L, emptyList()));
+      supervisor.addTask(new ReplicationTask(2L, emptyList(), 100L));
+      supervisor.addTask(new ReplicationTask(3L, emptyList(), 100L));
+
+      //THEN
+      Assert.assertEquals(3, supervisor.getInFlightReplications());
+      Assert.assertEquals(2, supervisor.getQueueSize());
+      // Sleep 2s, wait all tasks processed
+      try {
+        Thread.sleep(2000);

Review Comment:
   If we inject the MontonicClock into the Supervisor, then we can create it 
with a instance of `TestClock` that we can use to avoid the sleep calls and 
make the tests faster.



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