arunsarin85 commented on code in PR #9889:
URL: https://github.com/apache/ozone/pull/9889#discussion_r2905249870


##########
hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/upgrade/TestDatanodeUpgradeToContainerIdsTable.java:
##########
@@ -66,12 +68,23 @@ private void initTests() throws Exception {
   }
 
   private void setup() throws Exception {
-    address = SCMTestUtils.getReuseableAddress();
-    conf.setSocketAddr(ScmConfigKeys.OZONE_SCM_NAMES, address);
     conf.set(HddsConfigKeys.OZONE_METADATA_DIRS,
         tempFolder.toString());
   }
 
+  /**
+   * Starts the mock SCM RPC server on an OS-assigned port (port 0) to avoid
+   * the TOCTOU race that causes intermittent BindException when a pre-reserved
+   * port is grabbed by another process between reservation and bind.
+   */
+  private void startScm() throws IOException {
+    scmRpcServer = SCMTestUtils.startScmRpcServer(conf,
+        new ScmTestMock(CLUSTER_ID),
+        new InetSocketAddress(InetAddress.getLoopbackAddress(), 0), 10);
+    address = scmRpcServer.getListenerAddress();
+    conf.setSocketAddr(ScmConfigKeys.OZONE_SCM_NAMES, address);
+  }

Review Comment:
   Addressed the review comment in[Commit 2]



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