This is an automated email from the ASF dual-hosted git repository.

adoroszlai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new f8a1e3cc3a HDDS-10090. Clean up TestStorageContainerManager (#6347)
f8a1e3cc3a is described below

commit f8a1e3cc3ac692b20a7a52dc996ded3914310f6f
Author: Will Xiao <[email protected]>
AuthorDate: Sat Mar 9 03:31:07 2024 +0800

    HDDS-10090. Clean up TestStorageContainerManager (#6347)
---
 .../hdds/scm/TestStorageContainerManager.java      | 263 +++++++--------------
 1 file changed, 84 insertions(+), 179 deletions(-)

diff --git 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/scm/TestStorageContainerManager.java
 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/scm/TestStorageContainerManager.java
index f64736ac88..dec706ac9e 100644
--- 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/scm/TestStorageContainerManager.java
+++ 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/scm/TestStorageContainerManager.java
@@ -20,8 +20,6 @@ package org.apache.hadoop.hdds.scm;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
-import java.util.concurrent.ConcurrentHashMap;
-import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang3.RandomUtils;
 import org.apache.hadoop.hdds.HddsConfigKeys;
 import org.apache.hadoop.hdds.HddsUtils;
@@ -67,12 +65,12 @@ import org.apache.hadoop.hdds.utils.HddsVersionInfo;
 import org.apache.hadoop.net.DNSToSwitchMapping;
 import org.apache.hadoop.net.NetUtils;
 import org.apache.hadoop.net.StaticMapping;
+import org.apache.hadoop.ozone.HddsDatanodeService;
 import org.apache.hadoop.ozone.MiniOzoneCluster;
 import org.apache.hadoop.ozone.OzoneConfigKeys;
 import org.apache.hadoop.ozone.OzoneConsts;
 import org.apache.hadoop.ozone.OzoneTestUtils;
 import org.apache.hadoop.ozone.container.ContainerTestHelper;
-import org.apache.hadoop.ozone.HddsDatanodeService;
 import 
org.apache.hadoop.ozone.container.common.statemachine.DatanodeConfiguration;
 import 
org.apache.hadoop.ozone.container.common.statemachine.DatanodeStateMachine;
 import 
org.apache.hadoop.ozone.container.common.statemachine.EndpointStateMachine;
@@ -94,11 +92,12 @@ import org.apache.ozone.test.GenericTestUtils;
 import org.apache.ratis.conf.RaftProperties;
 import org.apache.ratis.protocol.RaftGroupId;
 import org.apache.ratis.server.RaftServerConfigKeys;
-import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.Timeout;
+import org.junit.jupiter.api.io.TempDir;
 import org.mockito.ArgumentMatcher;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -106,11 +105,9 @@ import org.slf4j.LoggerFactory;
 import java.io.File;
 import java.io.IOException;
 import java.nio.file.Path;
-import java.nio.file.Paths;
 import java.time.Duration;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -119,6 +116,7 @@ import java.util.Optional;
 import java.util.Set;
 import java.util.UUID;
 import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.Semaphore;
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
@@ -128,14 +126,15 @@ import java.util.function.Predicate;
 import java.util.stream.Stream;
 
 import static 
org.apache.hadoop.fs.CommonConfigurationKeysPublic.NET_TOPOLOGY_NODE_SWITCH_MAPPING_IMPL_KEY;
+import static 
org.apache.hadoop.hdds.HddsConfigKeys.HDDS_COMMAND_STATUS_REPORT_INTERVAL;
 import static 
org.apache.hadoop.hdds.HddsConfigKeys.HDDS_CONTAINER_REPORT_INTERVAL;
 import static org.apache.hadoop.hdds.HddsConfigKeys.HDDS_HEARTBEAT_INTERVAL;
 import static 
org.apache.hadoop.hdds.HddsConfigKeys.HDDS_SCM_SAFEMODE_PIPELINE_CREATION;
-import static 
org.apache.hadoop.hdds.HddsConfigKeys.HDDS_COMMAND_STATUS_REPORT_INTERVAL;
-import static 
org.apache.hadoop.hdds.scm.HddsWhiteboxTestUtils.setInternalState;
 import static org.apache.hadoop.hdds.scm.HddsTestUtils.mockRemoteUser;
+import static 
org.apache.hadoop.hdds.scm.HddsWhiteboxTestUtils.setInternalState;
 import static 
org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_BLOCK_DELETING_SERVICE_INTERVAL;
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertInstanceOf;
@@ -144,7 +143,6 @@ import static 
org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
 import static org.mockito.Mockito.any;
 import static org.mockito.Mockito.argThat;
 import static org.mockito.Mockito.doAnswer;
@@ -160,7 +158,7 @@ import static org.mockito.Mockito.verify;
 public class TestStorageContainerManager {
   private static XceiverClientManager xceiverClientManager;
   private static final Logger LOG = LoggerFactory.getLogger(
-            TestStorageContainerManager.class);
+      TestStorageContainerManager.class);
 
   @BeforeAll
   public static void setup() throws IOException {
@@ -199,16 +197,13 @@ public class TestStorageContainerManager {
       OzoneConfiguration ozoneConf,
       Predicate<String> isAdmin,
       String... usernames) throws Exception {
-    MiniOzoneCluster cluster = MiniOzoneCluster.newBuilder(ozoneConf).build();
-    try {
+    try (MiniOzoneCluster cluster = 
MiniOzoneCluster.newBuilder(ozoneConf).build()) {
       cluster.waitForClusterToBeReady();
       for (String username : usernames) {
         testRpcPermission(cluster, username,
             !isAdmin.test(username));
       }
-    } finally {
-      cluster.shutdown();
-    }
+    } // The cluster is automatically closed here
   }
 
   private void testRpcPermission(MiniOzoneCluster cluster,
@@ -227,17 +222,17 @@ public class TestStorageContainerManager {
       assertInstanceOf(ContainerNotFoundException.class, ex);
     }
 
-    try {
-      ContainerWithPipeline container2 = mockClientServer.allocateContainer(
-          HddsProtos.ReplicationType.RATIS,
-          HddsProtos.ReplicationFactor.ONE, OzoneConsts.OZONE);
-      if (expectPermissionDenied) {
-        fail("Operation should fail, expecting an IOException here.");
-      } else {
-        assertEquals(1, container2.getPipeline().getNodes().size());
-      }
-    } catch (Exception e) {
-      verifyPermissionDeniedException(e, fakeRemoteUsername);
+    if (expectPermissionDenied) {
+      Exception allocateException = assertThrows(Exception.class, () ->
+          mockClientServer.allocateContainer(HddsProtos.ReplicationType.RATIS,
+              HddsProtos.ReplicationFactor.ONE, OzoneConsts.OZONE));
+      verifyPermissionDeniedException(allocateException, fakeRemoteUsername);
+    } else {
+      // If not expecting permission denied, validate the successful 
operation's result
+      ContainerWithPipeline container2 = assertDoesNotThrow(() ->
+          mockClientServer.allocateContainer(HddsProtos.ReplicationType.RATIS,
+              HddsProtos.ReplicationFactor.ONE, OzoneConsts.OZONE));
+      assertEquals(1, container2.getPipeline().getNodes().size());
     }
 
     Exception e = assertThrows(Exception.class, () -> 
mockClientServer.getContainer(
@@ -290,11 +285,9 @@ public class TestStorageContainerManager {
     conf.setInt(ScmConfigKeys.OZONE_SCM_PIPELINE_OWNER_CONTAINER_COUNT,
         numKeys);
 
-    MiniOzoneCluster cluster = MiniOzoneCluster.newBuilder(conf)
-        .build();
-    cluster.waitForClusterToBeReady();
-
-    try {
+    try (MiniOzoneCluster cluster = MiniOzoneCluster.newBuilder(conf)
+        .build()) {
+      cluster.waitForClusterToBeReady();
       DeletedBlockLog delLog = cluster.getStorageContainerManager()
           .getScmBlockManager().getDeletedBlockLog();
       assertEquals(0, delLog.getNumOfValidTransactions());
@@ -362,8 +355,6 @@ public class TestStorageContainerManager {
           return false;
         }
       }, 1000, 20000);
-    } finally {
-      cluster.shutdown();
     }
   }
 
@@ -372,12 +363,13 @@ public class TestStorageContainerManager {
     OzoneConfiguration conf = new OzoneConfiguration();
     conf.setTimeDuration(HDDS_HEARTBEAT_INTERVAL, 1000, TimeUnit.MILLISECONDS);
     conf.setTimeDuration(ScmConfigKeys.OZONE_SCM_HEARTBEAT_PROCESS_INTERVAL, 
3000, TimeUnit.MILLISECONDS);
-    MiniOzoneCluster cluster = MiniOzoneCluster.newBuilder(conf)
-        .setNumDatanodes(1)
-        .build();
-    cluster.waitForClusterToBeReady();
 
-    try {
+
+
+    try (MiniOzoneCluster cluster = MiniOzoneCluster.newBuilder(conf)
+        .setNumDatanodes(1)
+        .build()) {
+      cluster.waitForClusterToBeReady();
       HddsDatanodeService datanode = cluster.getHddsDatanodes().get(0);
       StorageContainerManager scm = cluster.getStorageContainerManager();
       scm.stop();
@@ -443,8 +435,6 @@ public class TestStorageContainerManager {
       assertThat(versionEndPointTaskLog.getOutput()).contains(
           "org.apache.hadoop.ozone.common" +
               ".InconsistentStorageStateException: Mismatched ClusterIDs");
-    } finally {
-      cluster.shutdown();
     }
   }
 
@@ -465,13 +455,11 @@ public class TestStorageContainerManager {
     conf.setTimeDuration(HDDS_HEARTBEAT_INTERVAL, 1000, TimeUnit.MILLISECONDS);
     conf.setTimeDuration(ScmConfigKeys.OZONE_SCM_HEARTBEAT_PROCESS_INTERVAL, 
3000, TimeUnit.MILLISECONDS);
 
-    MiniOzoneCluster cluster = MiniOzoneCluster.newBuilder(conf)
+    try (MiniOzoneCluster cluster = MiniOzoneCluster.newBuilder(conf)
         .setNumDatanodes(1)
-        .build();
-    cluster.waitForClusterToBeReady();
-    cluster.waitForPipelineTobeReady(HddsProtos.ReplicationFactor.ONE, 30000);
-
-    try {
+        .build()) {
+      cluster.waitForClusterToBeReady();
+      cluster.waitForPipelineTobeReady(HddsProtos.ReplicationFactor.ONE, 
30000);
       DeletedBlockLog delLog = cluster.getStorageContainerManager()
           .getScmBlockManager().getDeletedBlockLog();
       assertEquals(0, delLog.getNumOfValidTransactions());
@@ -516,8 +504,6 @@ public class TestStorageContainerManager {
         }
         return false;
       }, 500, 10000);
-    } finally {
-      cluster.shutdown();
     }
   }
 
@@ -568,11 +554,9 @@ public class TestStorageContainerManager {
   }
 
   @Test
-  public void testSCMInitialization() throws Exception {
+  public void testSCMInitialization(@TempDir Path tempDir) throws Exception {
     OzoneConfiguration conf = new OzoneConfiguration();
-    final String path = GenericTestUtils.getTempPath(
-        UUID.randomUUID().toString());
-    Path scmPath = Paths.get(path, "scm-meta");
+    Path scmPath = tempDir.resolve("scm-meta");
     conf.set(HddsConfigKeys.OZONE_METADATA_DIRS, scmPath.toString());
 
     UUID clusterId = UUID.randomUUID();
@@ -590,13 +574,11 @@ public class TestStorageContainerManager {
   }
 
   @Test
-  public void testSCMInitializationWithHAEnabled() throws Exception {
+  public void testSCMInitializationWithHAEnabled(@TempDir Path tempDir) throws 
Exception {
     OzoneConfiguration conf = new OzoneConfiguration();
     conf.setBoolean(ScmConfigKeys.OZONE_SCM_HA_ENABLE_KEY, true);
     conf.set(ScmConfigKeys.OZONE_SCM_PIPELINE_CREATION_INTERVAL, "10s");
-    final String path = GenericTestUtils.getTempPath(
-        UUID.randomUUID().toString());
-    Path scmPath = Paths.get(path, "scm-meta");
+    Path scmPath = tempDir.resolve("scm-meta");
     conf.set(HddsConfigKeys.OZONE_METADATA_DIRS, scmPath.toString());
 
     final UUID clusterId = UUID.randomUUID();
@@ -608,54 +590,26 @@ public class TestStorageContainerManager {
   }
 
   @Test
-  public void testSCMReinitialization() throws Exception {
+  public void testSCMReinitialization(@TempDir Path tempDir) throws Exception {
     OzoneConfiguration conf = new OzoneConfiguration();
-    final String path = GenericTestUtils.getTempPath(
-        UUID.randomUUID().toString());
-    Path scmPath = Paths.get(path, "scm-meta");
+    Path scmPath = tempDir.resolve("scm-meta");
     conf.set(HddsConfigKeys.OZONE_METADATA_DIRS, scmPath.toString());
     //This will set the cluster id in the version file
-    MiniOzoneCluster cluster =
-        MiniOzoneCluster.newBuilder(conf).setNumDatanodes(3).build();
-    cluster.waitForClusterToBeReady();
-    cluster.getStorageContainerManager().stop();
-    try {
+
+
+    try (MiniOzoneCluster cluster =
+             MiniOzoneCluster.newBuilder(conf).setNumDatanodes(3).build()) {
+      cluster.waitForClusterToBeReady();
+      cluster.getStorageContainerManager().stop();
       final UUID clusterId = UUID.randomUUID();
       // This will initialize SCM
       StorageContainerManager.scmInit(conf, clusterId.toString());
       SCMStorageConfig scmStore = new SCMStorageConfig(conf);
       assertNotEquals(clusterId.toString(), scmStore.getClusterID());
       assertTrue(scmStore.isSCMHAEnabled());
-    } finally {
-      cluster.shutdown();
     }
   }
 
-  // Unsupported Test case. Non Ratis SCM -> Ratis SCM not supported
-  //@Test
-  public void testSCMReinitializationWithHAUpgrade() throws Exception {
-    OzoneConfiguration conf = new OzoneConfiguration();
-    final String path = GenericTestUtils.getTempPath(
-        UUID.randomUUID().toString());
-    Path scmPath = Paths.get(path, "scm-meta");
-    conf.set(HddsConfigKeys.OZONE_METADATA_DIRS, scmPath.toString());
-    //This will set the cluster id in the version file
-    final UUID clusterId = UUID.randomUUID();
-      // This will initialize SCM
-
-    StorageContainerManager.scmInit(conf, clusterId.toString());
-    SCMStorageConfig scmStore = new SCMStorageConfig(conf);
-    assertEquals(clusterId.toString(), scmStore.getClusterID());
-    assertFalse(scmStore.isSCMHAEnabled());
-
-    conf.setBoolean(ScmConfigKeys.OZONE_SCM_HA_ENABLE_KEY, true);
-    StorageContainerManager.scmInit(conf, clusterId.toString());
-    scmStore = new SCMStorageConfig(conf);
-    assertTrue(scmStore.isSCMHAEnabled());
-    validateRatisGroupExists(conf, clusterId.toString());
-
-  }
-
   @VisibleForTesting
   public static void validateRatisGroupExists(OzoneConfiguration conf,
       String clusterId) throws IOException {
@@ -696,45 +650,10 @@ public class TestStorageContainerManager {
     }
   }
 
-  // Non Ratis SCM -> Ratis SCM is not supported {@see HDDS-6695}
-  // Invalid Testcase
-  // @Test
-  public void testSCMReinitializationWithHAEnabled() throws Exception {
-    OzoneConfiguration conf = new OzoneConfiguration();
-    conf.setBoolean(ScmConfigKeys.OZONE_SCM_HA_ENABLE_KEY, false);
-    final String path = GenericTestUtils.getTempPath(
-        UUID.randomUUID().toString());
-    Path scmPath = Paths.get(path, "scm-meta");
-    conf.set(HddsConfigKeys.OZONE_METADATA_DIRS, scmPath.toString());
-    //This will set the cluster id in the version file
-    MiniOzoneCluster cluster =
-        MiniOzoneCluster.newBuilder(conf).setNumDatanodes(3).build();
-    cluster.waitForClusterToBeReady();
-    try {
-      final String clusterId =
-          cluster.getStorageContainerManager().getClusterId();
-      // validate there is no ratis group pre existing
-      assertThrows(IOException.class, () -> validateRatisGroupExists(conf, 
clusterId));
-
-      conf.setBoolean(ScmConfigKeys.OZONE_SCM_HA_ENABLE_KEY, true);
-      // This will re-initialize SCM
-      StorageContainerManager.scmInit(conf, clusterId);
-      cluster.getStorageContainerManager().start();
-      // Ratis group with cluster id exists now
-      validateRatisGroupExists(conf, clusterId);
-      SCMStorageConfig scmStore = new SCMStorageConfig(conf);
-      assertTrue(scmStore.isSCMHAEnabled());
-    } finally {
-      cluster.shutdown();
-    }
-  }
-
   @Test
-  void testSCMInitializationFailure() {
+  void testSCMInitializationFailure(@TempDir Path tempDir) {
     OzoneConfiguration conf = new OzoneConfiguration();
-    final String path =
-        GenericTestUtils.getTempPath(UUID.randomUUID().toString());
-    Path scmPath = Paths.get(path, "scm-meta");
+    Path scmPath = tempDir.resolve("scm-meta");
     conf.set(HddsConfigKeys.OZONE_METADATA_DIRS, scmPath.toString());
 
     Exception e = assertThrows(SCMException.class, () -> 
HddsTestUtils.getScmSimple(conf));
@@ -742,32 +661,27 @@ public class TestStorageContainerManager {
   }
 
   @Test
-  public void testScmInfo() throws Exception {
+  public void testScmInfo(@TempDir Path tempDir) throws Exception {
     OzoneConfiguration conf = new OzoneConfiguration();
-    final String path =
-        GenericTestUtils.getTempPath(UUID.randomUUID().toString());
-    try {
-      Path scmPath = Paths.get(path, "scm-meta");
-      conf.set(HddsConfigKeys.OZONE_METADATA_DIRS, scmPath.toString());
-      SCMStorageConfig scmStore = new SCMStorageConfig(conf);
-      String clusterId = UUID.randomUUID().toString();
-      String scmId = UUID.randomUUID().toString();
-      scmStore.setClusterId(clusterId);
-      scmStore.setScmId(scmId);
-      // writes the version file properties
-      scmStore.initialize();
-      StorageContainerManager scm = HddsTestUtils.getScmSimple(conf);
-      //Reads the SCM Info from SCM instance
-      ScmInfo scmInfo = scm.getClientProtocolServer().getScmInfo();
-      assertEquals(clusterId, scmInfo.getClusterId());
-      assertEquals(scmId, scmInfo.getScmId());
-
-      String expectedVersion = HddsVersionInfo.HDDS_VERSION_INFO.getVersion();
-      String actualVersion = scm.getSoftwareVersion();
-      assertEquals(expectedVersion, actualVersion);
-    } finally {
-      FileUtils.deleteQuietly(new File(path));
-    }
+    Path scmPath = tempDir.resolve("scm-meta");
+
+    conf.set(HddsConfigKeys.OZONE_METADATA_DIRS, scmPath.toString());
+    SCMStorageConfig scmStore = new SCMStorageConfig(conf);
+    String clusterId = UUID.randomUUID().toString();
+    String scmId = UUID.randomUUID().toString();
+    scmStore.setClusterId(clusterId);
+    scmStore.setScmId(scmId);
+    // writes the version file properties
+    scmStore.initialize();
+    StorageContainerManager scm = HddsTestUtils.getScmSimple(conf);
+    //Reads the SCM Info from SCM instance
+    ScmInfo scmInfo = scm.getClientProtocolServer().getScmInfo();
+    assertEquals(clusterId, scmInfo.getClusterId());
+    assertEquals(scmId, scmInfo.getScmId());
+
+    String expectedVersion = HddsVersionInfo.HDDS_VERSION_INFO.getVersion();
+    String actualVersion = scm.getSoftwareVersion();
+    assertEquals(expectedVersion, actualVersion);
   }
 
   /**
@@ -778,18 +692,16 @@ public class TestStorageContainerManager {
     OzoneConfiguration conf = new OzoneConfiguration();
     conf.setClass(NET_TOPOLOGY_NODE_SWITCH_MAPPING_IMPL_KEY,
         StaticMapping.class, DNSToSwitchMapping.class);
-    StaticMapping.addNodeToRack(NetUtils.normalizeHostNames(
-        Collections.singleton(HddsUtils.getHostName(conf))).get(0),
+    
StaticMapping.addNodeToRack(NetUtils.normalizeHostName(HddsUtils.getHostName(conf)),
         "/rack1");
 
     final int datanodeNum = 3;
-    MiniOzoneCluster cluster = MiniOzoneCluster.newBuilder(conf)
-        .setNumDatanodes(datanodeNum)
-        .build();
-    cluster.waitForClusterToBeReady();
-    StorageContainerManager scm = cluster.getStorageContainerManager();
 
-    try {
+    try (MiniOzoneCluster cluster = MiniOzoneCluster.newBuilder(conf)
+        .setNumDatanodes(datanodeNum)
+        .build()) {
+      cluster.waitForClusterToBeReady();
+      StorageContainerManager scm = cluster.getStorageContainerManager();
       // first sleep 10s
       Thread.sleep(10000);
       // verify datanode heartbeats are well processed
@@ -809,8 +721,6 @@ public class TestStorageContainerManager {
             datanodeInfo.getNetworkName());
         assertEquals("/rack1", datanodeInfo.getNetworkLocation());
       }
-    } finally {
-      cluster.shutdown();
     }
   }
 
@@ -829,13 +739,11 @@ public class TestStorageContainerManager {
     conf.setTimeDuration(HDDS_HEARTBEAT_INTERVAL, 1000, TimeUnit.MILLISECONDS);
     conf.setTimeDuration(ScmConfigKeys.OZONE_SCM_HEARTBEAT_PROCESS_INTERVAL, 
3000, TimeUnit.MILLISECONDS);
 
-    MiniOzoneCluster cluster = MiniOzoneCluster.newBuilder(conf)
+    try (MiniOzoneCluster cluster = MiniOzoneCluster.newBuilder(conf)
         .setNumDatanodes(1)
-        .build();
-    cluster.waitForClusterToBeReady();
-    cluster.waitForPipelineTobeReady(HddsProtos.ReplicationFactor.ONE, 30000);
-
-    try {
+        .build()) {
+      cluster.waitForClusterToBeReady();
+      cluster.waitForPipelineTobeReady(HddsProtos.ReplicationFactor.ONE, 
30000);
       TestStorageContainerManagerHelper helper =
           new TestStorageContainerManagerHelper(cluster, conf);
 
@@ -905,8 +813,6 @@ public class TestStorageContainerManager {
       } else {
         verify(nodeManager).addDatanodeCommand(dnUuid, closeContainerCommand);
       }
-    } finally {
-      cluster.shutdown();
     }
   }
 
@@ -926,7 +832,7 @@ public class TestStorageContainerManager {
     ContainerReportHandler containerReportHandler =
         mock(ContainerReportHandler.class);
     doAnswer((inv) -> {
-      Thread.currentThread().sleep(500);
+      Thread.sleep(500);
       return null;
     }).when(containerReportHandler).onMessage(dndata, eventQueue);
     List<ThreadPoolExecutor> executors = FixedThreadPoolWithAffinityExecutor
@@ -948,7 +854,7 @@ public class TestStorageContainerManager {
     eventQueue.fireEvent(SCMEvents.CONTAINER_REPORT, dndata);
     eventQueue.fireEvent(SCMEvents.CONTAINER_REPORT, dndata);
     assertThat(containerReportExecutors.droppedEvents()).isGreaterThan(1);
-    Thread.currentThread().sleep(1000);
+    Thread.sleep(1000);
     assertEquals(containerReportExecutors.droppedEvents()
             + containerReportExecutors.scheduledEvents(),
         containerReportExecutors.queuedEvents());
@@ -968,7 +874,7 @@ public class TestStorageContainerManager {
     ContainerReportHandler containerReportHandler =
         mock(ContainerReportHandler.class);
     doAnswer((inv) -> {
-      Thread.currentThread().sleep(1000);
+      Thread.sleep(1000);
       semaphore.release(1);
       return null;
     }).when(containerReportHandler).onMessage(any(), eq(eventQueue));
@@ -987,7 +893,7 @@ public class TestStorageContainerManager {
             reportExecutorMap);
     containerReportExecutors.setQueueWaitThreshold(800);
     containerReportExecutors.setExecWaitThreshold(800);
-    
+
     eventQueue.addHandler(SCMEvents.CONTAINER_REPORT, containerReportExecutors,
         containerReportHandler);
     ContainerReportsProto report = ContainerReportsProto.getDefaultInstance();
@@ -1026,7 +932,7 @@ public class TestStorageContainerManager {
     IncrementalContainerReportHandler icr =
         mock(IncrementalContainerReportHandler.class);
     doAnswer((inv) -> {
-      Thread.currentThread().sleep(500);
+      Thread.sleep(500);
       return null;
     }).when(icr).onMessage(dndata, eventQueue);
     List<ThreadPoolExecutor> executors = FixedThreadPoolWithAffinityExecutor
@@ -1048,7 +954,7 @@ public class TestStorageContainerManager {
     eventQueue.fireEvent(SCMEvents.INCREMENTAL_CONTAINER_REPORT, dndata);
     eventQueue.fireEvent(SCMEvents.INCREMENTAL_CONTAINER_REPORT, dndata);
     assertEquals(0, containerReportExecutors.droppedEvents());
-    Thread.currentThread().sleep(3000);
+    Thread.sleep(3000);
     assertEquals(containerReportExecutors.scheduledEvents(),
         containerReportExecutors.queuedEvents());
     containerReportExecutors.close();
@@ -1078,7 +984,6 @@ public class TestStorageContainerManager {
           .getStorageContainerManager();
       assertNotNull(ratisSCM.getScmHAManager().getRatisServer());
       assertTrue(ratisSCM.getScmStorageConfig().isSCMHAEnabled());
-
     }
   }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to