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

chihsuan 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 2fd905b25c5 HDDS-17091. Stabilize and speed up 
TestStorageContainerManager#testCloseContainerCommandOnRestart (#11592)
2fd905b25c5 is described below

commit 2fd905b25c5c6e63ffb09ae5bb3523e9563089b8
Author: Shuo Huang <[email protected]>
AuthorDate: Sun Oct 18 14:33:55 2026 +0800

    HDDS-17091. Stabilize and speed up 
TestStorageContainerManager#testCloseContainerCommandOnRestart (#11592)
---
 .../hdds/scm/TestStorageContainerManager.java      | 42 +++++++++++-----------
 1 file changed, 20 insertions(+), 22 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 da93072e40c..4eae67ae3c7 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
@@ -83,6 +83,7 @@
 import org.apache.hadoop.hdds.ratis.RatisHelper;
 import org.apache.hadoop.hdds.scm.block.DeletedBlockLog;
 import org.apache.hadoop.hdds.scm.block.SCMBlockDeletingService;
+import org.apache.hadoop.hdds.scm.container.ContainerID;
 import org.apache.hadoop.hdds.scm.container.ContainerInfo;
 import org.apache.hadoop.hdds.scm.container.ContainerNotFoundException;
 import org.apache.hadoop.hdds.scm.container.ContainerReportHandler;
@@ -92,7 +93,6 @@
 import org.apache.hadoop.hdds.scm.events.SCMEvents;
 import org.apache.hadoop.hdds.scm.exceptions.SCMException;
 import org.apache.hadoop.hdds.scm.ha.RatisUtil;
-import org.apache.hadoop.hdds.scm.ha.SCMContext;
 import org.apache.hadoop.hdds.scm.ha.SCMHAUtils;
 import org.apache.hadoop.hdds.scm.ha.SCMRatisServerImpl;
 import org.apache.hadoop.hdds.scm.node.DatanodeInfo;
@@ -662,16 +662,14 @@ public void testCloseContainerCommandOnRestart() throws 
Exception {
       cluster.waitForClusterToBeReady();
       cluster.waitForPipelineTobeReady(HddsProtos.ReplicationFactor.ONE, 
30000);
 
-      DataTestUtil.createKeys(cluster, 10);
-      GenericTestUtils.waitFor(() ->
-          cluster.getStorageContainerManager().getContainerManager()
-              .getContainers() != null, 1000, 10000);
+      OmKeyInfo key = DataTestUtil.createKeys(cluster, 10)
+          .values().iterator().next();
+      long containerID = key.getLatestVersionLocations()
+          .createLocationList().get(0).getContainerID();
 
       StorageContainerManager scm = cluster.getStorageContainerManager();
-      List<ContainerInfo> containers = cluster.getStorageContainerManager()
-          .getContainerManager().getContainers();
-      assertNotNull(containers);
-      ContainerInfo selectedContainer = containers.iterator().next();
+      ContainerInfo selectedContainer = scm.getContainerManager()
+          .getContainer(ContainerID.valueOf(containerID));
 
       // Stop processing HB
       scm.getDatanodeProtocolServer().stop();
@@ -689,9 +687,10 @@ public void testCloseContainerCommandOnRestart() throws 
Exception {
       }
 
       cluster.restartStorageContainerManager(false);
-      scm = cluster.getStorageContainerManager();
+      StorageContainerManager restartedScm =
+          cluster.getStorageContainerManager();
 
-      ReplicationManager rm = scm.getReplicationManager();
+      ReplicationManager rm = restartedScm.getReplicationManager();
 
       NodeManager nodeManager = mock(NodeManager.class);
       setInternalState(rm, "nodeManager", nodeManager);
@@ -703,18 +702,17 @@ public void testCloseContainerCommandOnRestart() throws 
Exception {
           new CloseContainerCommand(selectedContainer.getContainerID(),
               selectedContainer.getPipelineID(), false);
 
+      // processAll cannot send the close command until ReplicationManager is 
ready
+      // and SCM has received the replica report.
       GenericTestUtils.waitFor(() -> {
-        SCMContext scmContext
-            = cluster.getStorageContainerManager().getScmContext();
-        return !scmContext.isInSafeMode() && scmContext.isLeader();
-      }, 1000, 25000);
-
-      // After safe mode is off, ReplicationManager starts to run with a delay.
-      Thread.sleep(5000);
-      // Give ReplicationManager some time to process the containers.
-      cluster.getStorageContainerManager()
-          .getReplicationManager().processAll();
-      Thread.sleep(5000);
+        try {
+          return rm.shouldRun() && !restartedScm.getContainerManager()
+              .getContainerReplicas(selectedContainer.containerID()).isEmpty();
+        } catch (ContainerNotFoundException e) {
+          return false;
+        }
+      }, 100, 30000);
+      rm.processAll();
       verify(nodeManager).addDatanodeCommand(dnUuid, closeContainerCommand);
     }
   }


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

Reply via email to