siddhantsangwan commented on code in PR #3751:
URL: https://github.com/apache/ozone/pull/3751#discussion_r978314884
##########
hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/balancer/TestContainerBalancer.java:
##########
@@ -779,7 +780,52 @@ public void
checkIterationResultTimeoutFromReplicationManager()
.getNumContainerMovesTimeoutInLatestIteration() > 0);
stopBalancer();
}
-
+
+ @Test
+ public void checkIterationResultException()
+ throws NodeNotFoundException, IOException,
+ IllegalContainerBalancerStateException,
+ InvalidContainerBalancerConfigurationException,
+ TimeoutException {
+
+ CompletableFuture<MoveResult> f = new CompletableFuture();
+ f.completeExceptionally(new RuntimeException("Runtime Exception"));
+ Mockito.when(replicationManager.move(Mockito.any(ContainerID.class),
+ Mockito.any(DatanodeDetails.class),
+ Mockito.any(DatanodeDetails.class)))
+ .thenThrow(new ContainerNotFoundException("Test Container not found"),
+ new NodeNotFoundException("Test Node not found"))
+ .thenReturn(f).thenReturn(CompletableFuture.supplyAsync(() -> {
+ try {
+ Thread.sleep(1000);
Review Comment:
NIT: Is this deliberately set to a high value? Maybe we can reduce it to
something like 5ms.
##########
hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/balancer/TestContainerBalancer.java:
##########
@@ -779,7 +780,52 @@ public void
checkIterationResultTimeoutFromReplicationManager()
.getNumContainerMovesTimeoutInLatestIteration() > 0);
stopBalancer();
}
-
+
+ @Test
+ public void checkIterationResultException()
+ throws NodeNotFoundException, IOException,
+ IllegalContainerBalancerStateException,
+ InvalidContainerBalancerConfigurationException,
+ TimeoutException {
+
+ CompletableFuture<MoveResult> f = new CompletableFuture();
+ f.completeExceptionally(new RuntimeException("Runtime Exception"));
+ Mockito.when(replicationManager.move(Mockito.any(ContainerID.class),
+ Mockito.any(DatanodeDetails.class),
+ Mockito.any(DatanodeDetails.class)))
+ .thenThrow(new ContainerNotFoundException("Test Container not found"),
+ new NodeNotFoundException("Test Node not found"))
+ .thenReturn(f).thenReturn(CompletableFuture.supplyAsync(() -> {
+ try {
+ Thread.sleep(1000);
+ } catch (Exception ex) {
+ }
+ throw new RuntimeException("Throw");
+ }));
+
+ balancerConfiguration.setThreshold(10);
+ balancerConfiguration.setIterations(1);
+ balancerConfiguration.setMaxSizeEnteringTarget(10 * STORAGE_UNIT);
+ balancerConfiguration.setMaxSizeToMovePerIteration(100 * STORAGE_UNIT);
+ balancerConfiguration.setMaxDatanodesPercentageToInvolvePerIteration(100);
+ balancerConfiguration.setMoveTimeout(Duration.ofMillis(2000));
+
+ startBalancer(balancerConfiguration);
+ sleepWhileBalancing(2000);
+
+ /*
+ Immediate failure count is 2 and timeout count is 4 together
+ */
Review Comment:
NIT: This comment can be removed now since we aren't counting timeouts.
##########
hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/balancer/TestContainerBalancer.java:
##########
@@ -779,7 +780,52 @@ public void
checkIterationResultTimeoutFromReplicationManager()
.getNumContainerMovesTimeoutInLatestIteration() > 0);
stopBalancer();
}
-
+
+ @Test
+ public void checkIterationResultException()
+ throws NodeNotFoundException, IOException,
+ IllegalContainerBalancerStateException,
+ InvalidContainerBalancerConfigurationException,
+ TimeoutException {
+
+ CompletableFuture<MoveResult> f = new CompletableFuture();
+ f.completeExceptionally(new RuntimeException("Runtime Exception"));
+ Mockito.when(replicationManager.move(Mockito.any(ContainerID.class),
+ Mockito.any(DatanodeDetails.class),
+ Mockito.any(DatanodeDetails.class)))
+ .thenThrow(new ContainerNotFoundException("Test Container not found"),
+ new NodeNotFoundException("Test Node not found"))
+ .thenReturn(f).thenReturn(CompletableFuture.supplyAsync(() -> {
+ try {
+ Thread.sleep(1000);
+ } catch (Exception ex) {
+ }
+ throw new RuntimeException("Throw");
+ }));
+
+ balancerConfiguration.setThreshold(10);
+ balancerConfiguration.setIterations(1);
+ balancerConfiguration.setMaxSizeEnteringTarget(10 * STORAGE_UNIT);
+ balancerConfiguration.setMaxSizeToMovePerIteration(100 * STORAGE_UNIT);
+ balancerConfiguration.setMaxDatanodesPercentageToInvolvePerIteration(100);
+ balancerConfiguration.setMoveTimeout(Duration.ofMillis(2000));
+
+ startBalancer(balancerConfiguration);
+ sleepWhileBalancing(2000);
Review Comment:
Same as above. Can be reduced to 500ms.
--
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]