umamaheswararao commented on code in PR #3939:
URL: https://github.com/apache/ozone/pull/3939#discussion_r1028838454


##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/TestECContainerRecovery.java:
##########
@@ -239,6 +254,96 @@ public void 
testContainerRecoveryOverReplicationProcessing()
     waitForContainerCount(5, container.containerID(), scm);
   }
 
+  @Test
+  public void testECContainerRecoveryWithTimedOutRecovery() throws Exception {
+    byte[] inputData = getInputBytes(3);
+    final OzoneBucket bucket = getOzoneBucket();
+    String keyName = UUID.randomUUID().toString();
+    final Pipeline pipeline;
+    ECReplicationConfig repConfig =
+            new ECReplicationConfig(3, 2,
+                    ECReplicationConfig.EcCodec.RS, chunkSize);
+    try (OzoneOutputStream out = bucket
+            .createKey(keyName, 1024, repConfig, new HashMap<>())) {
+      out.write(inputData);
+      pipeline = ((ECKeyOutputStream) out.getOutputStream())
+              .getStreamEntries().get(0).getPipeline();
+    } catch (IOException e) {
+      throw new RuntimeException(e);
+    }
+
+    List<ContainerInfo> containers =
+            cluster.getStorageContainerManager().getContainerManager()
+                    .getContainers();
+    ContainerInfo container = null;
+    for (ContainerInfo info : containers) {
+      if (info.getPipelineID().getId().equals(pipeline.getId().getId())) {
+        container = info;
+      }
+    }
+    StorageContainerManager scm = cluster.getStorageContainerManager();
+    AtomicReference<HddsDatanodeService> reconstructedDN =
+            new AtomicReference<>();
+    ContainerInfo finalContainer = container;
+    Map<HddsDatanodeService, Long> recoveryTimeoutMap = new HashMap<>();
+    for (HddsDatanodeService dn : cluster.getHddsDatanodes()) {
+      recoveryTimeoutMap.put(dn, dn.getDatanodeStateMachine().getContainer()
+              .getContainerSet().getRecoveringTimeout());
+      dn.getDatanodeStateMachine().getContainer()
+              .getContainerSet().setRecoveringTimeout(100);
+
+      ECReconstructionSupervisor ecReconstructionSupervisor =
+              GenericTestUtils.getFieldReflection(dn.getDatanodeStateMachine(),
+                      "ecReconstructionSupervisor");
+      ECReconstructionCoordinator coordinator = GenericTestUtils
+              .mockFieldReflection(ecReconstructionSupervisor,
+                      "reconstructionCoordinator");
+
+      Mockito.doAnswer(invocation -> {
+        GenericTestUtils.waitFor(() ->
+                        dn.getDatanodeStateMachine()
+                                .getContainer()
+                                .getContainerSet()
+                                .getContainer(finalContainer.getContainerID())
+                                .getContainerState() ==
+                        ContainerProtos.ContainerDataProto.State.UNHEALTHY,
+                1000, 100000);
+        reconstructedDN.set(dn);
+        invocation.callRealMethod();
+        return null;
+      }).when(coordinator).reconstructECBlockGroup(Mockito.any(), 
Mockito.any(),
+              Mockito.any());
+    }
+

Review Comment:
   I am still thinking that whether we can just have tests similar to 
TestStaleRecoveringContainerScrubbingService
   The advantage is to avoid sleeps. You can have your own timeouts and move 
forward and make sure container is moved to unhealthy, rather than deleted.
   
   ```
   @Test
     public void testScrubbingStaleRecoveringContainers()
         throws Exception {
       ContainerSet containerSet = new ContainerSet(10);
       containerSet.setClock(testClock);
       StaleRecoveringContainerScrubbingService srcss =
           new StaleRecoveringContainerScrubbingService(
               50, TimeUnit.MILLISECONDS, 10,
               Duration.ofSeconds(300).toMillis(),
               containerSet);
       testClock.fastForward(1000L);
       createTestContainers(containerSet, 5, CLOSED);
       testClock.fastForward(1000L);
       srcss.runPeriodicalTaskNow();
       //closed container should not be scrubbed
       Assert.assertTrue(containerSet.containerCount() == 5);
   
       createTestContainers(containerSet, 5, RECOVERING);
       testClock.fastForward(1000L);
       srcss.runPeriodicalTaskNow();
       //recovering container should be scrubbed since recovering timeout
       Assert.assertTrue(containerSet.containerCount() == 5);
       Iterator<Container<?>> it = containerSet.getContainerIterator();
       while (it.hasNext()) {
         Container<?> entry = it.next();
         Assert.assertTrue(entry.getContainerState().equals(CLOSED));
       }
   
       //increase recovering timeout
       containerSet.setRecoveringTimeout(2000L);
       createTestContainers(containerSet, 5, RECOVERING);
       testClock.fastForward(1000L);
       srcss.runPeriodicalTaskNow();
       //recovering container should not be scrubbed
       Assert.assertTrue(containerSet.containerCount() == 10);
     }
   }
   ```



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