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


##########
hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/ec/reconstruction/TestECReconstructionSupervisor.java:
##########
@@ -17,37 +17,57 @@
  */
 package org.apache.hadoop.ozone.container.ec.reconstruction;
 
+import com.google.common.collect.ImmutableList;
+import org.apache.hadoop.hdds.client.ECReplicationConfig;
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.apache.hadoop.hdds.protocol.DatanodeDetails;
 import org.apache.ozone.test.GenericTestUtils;
+import org.junit.Assert;
 import org.junit.Test;
 
+import java.io.IOException;
+import java.util.SortedMap;
 import java.util.concurrent.TimeoutException;
 
 /**
  * Tests the ECReconstructionSupervisor.
  */
 public class TestECReconstructionSupervisor {
 
-  private final ECReconstructionSupervisor supervisor =
-      new ECReconstructionSupervisor(null, null, 5, null);
-
   @Test
   public void testAddTaskShouldExecuteTheGivenTask()
-      throws InterruptedException, TimeoutException {
-    FakeTask task = new FakeTask(null);
-    supervisor.addTask(task);
-    GenericTestUtils.waitFor(() -> task.isExecuted, 100, 15000);
-  }
-
-  static class FakeTask extends ECReconstructionCoordinatorTask {
-    private boolean isExecuted = false;
-
-    FakeTask(ECReconstructionCommandInfo reconstructionCommandInfo) {
-      super(null, reconstructionCommandInfo);
-    }
-
-    @Override
-    public void run() {
-      isExecuted = true;
-    }
+      throws InterruptedException, TimeoutException, IOException {
+    final boolean[] reconstructInvoked = {false};

Review Comment:
   Why are these arrays? I guess its because a Boolean is immutable and we 
cannot change it if its a final, and the variable has to be final to be use in 
the run block.
   
   I think it would be more clear to use a pair of CountDownLatch objects here. 
Then we can get rid of most of the waitFor() calls, eg
   
   ```
   CountDownLatch runnableInvoked = new CountDownLatch(1);
   CountDownLatch holdProcessing = new CountDownLatch(1);
   
   // Inside the reconstructECContainerGroup
   ...
   runnableInvoked.countDown();
   holdProcessing.await();
   ...
   
   // In the main test method:
       supervisor.addTask(
           new ECReconstructionCommandInfo(1, new ECReplicationConfig(3, 2),
               new byte[0], ImmutableList.of(), ImmutableList.of()));
       runnableInvoked.await()
       Assert.assertEquals(1, supervisor.getInFlightReplications());
       holdProcessing.countDown();
       GenericTestUtils
           .waitFor(() -> supervisor.getInFlightReplications() == 0, 100, 
15000);
   ```



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