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

tanvipenumudy 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 15f966e0ac HDDS-11005. TestEndPoint#testRegisterRpcTimeout fails when 
run in itself (#6806)
15f966e0ac is described below

commit 15f966e0acffe12db2f4309bfde40913b62b1948
Author: Tejaskriya <[email protected]>
AuthorDate: Thu Jun 13 13:32:35 2024 +0530

    HDDS-11005. TestEndPoint#testRegisterRpcTimeout fails when run in itself 
(#6806)
---
 .../ozone/container/common/TestEndPoint.java       | 45 ++++++++++++++--------
 1 file changed, 29 insertions(+), 16 deletions(-)

diff --git 
a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/ozone/container/common/TestEndPoint.java
 
b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/ozone/container/common/TestEndPoint.java
index 6a4cebe9c7..2b78b73bcd 100644
--- 
a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/ozone/container/common/TestEndPoint.java
+++ 
b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/ozone/container/common/TestEndPoint.java
@@ -405,14 +405,8 @@ public class TestEndPoint {
         null);
   }
 
-  private EndpointStateMachine registerTaskHelper(InetSocketAddress scmAddress,
-      int rpcTimeout, boolean clearDatanodeDetails
-  ) throws Exception {
-    OzoneConfiguration conf = SCMTestUtils.getConf(tempDir);
-    EndpointStateMachine rpcEndPoint =
-        createEndpoint(conf,
-            scmAddress, rpcTimeout);
-    rpcEndPoint.setState(EndpointStateMachine.EndPointStates.REGISTER);
+  private RegisterEndpointTask getRegisterEndpointTask(boolean 
clearDatanodeDetails, OzoneConfiguration conf,
+                                                       EndpointStateMachine 
rpcEndPoint) throws Exception {
     OzoneContainer ozoneContainer = mock(OzoneContainer.class);
     UUID datanodeID = UUID.randomUUID();
     when(ozoneContainer.getNodeReport()).thenReturn(HddsTestUtils
@@ -437,6 +431,16 @@ public class TestEndPoint {
       DatanodeDetails datanodeDetails = randomDatanodeDetails();
       endpointTask.setDatanodeDetails(datanodeDetails);
     }
+    return endpointTask;
+  }
+
+  private EndpointStateMachine registerTaskHelper(InetSocketAddress scmAddress,
+      int rpcTimeout, boolean clearDatanodeDetails
+  ) throws Exception {
+    OzoneConfiguration conf = SCMTestUtils.getConf(tempDir);
+    EndpointStateMachine rpcEndPoint = createEndpoint(conf, scmAddress, 
rpcTimeout);
+    rpcEndPoint.setState(EndpointStateMachine.EndPointStates.REGISTER);
+    RegisterEndpointTask endpointTask = 
getRegisterEndpointTask(clearDatanodeDetails, conf, rpcEndPoint);
     endpointTask.call();
     return rpcEndPoint;
   }
@@ -472,14 +476,23 @@ public class TestEndPoint {
 
   @Test
   public void testRegisterRpcTimeout() throws Exception {
-    final long rpcTimeout = 1000;
-    final long tolerance = 200;
-    scmServerImpl.setRpcResponseDelay(1500);
-    long start = Time.monotonicNow();
-    registerTaskHelper(serverAddress, 1000, false).close();
-    long end = Time.monotonicNow();
-    scmServerImpl.setRpcResponseDelay(0);
-    assertThat(end - start).isLessThanOrEqualTo(rpcTimeout + tolerance);
+    final int rpcTimeout = 1000;
+    final int tolerance = 200;
+    scmServerImpl.setRpcResponseDelay(rpcTimeout + tolerance * 2);
+    OzoneConfiguration conf = SCMTestUtils.getConf(tempDir);
+
+    try (EndpointStateMachine rpcEndPoint = createEndpoint(conf, 
serverAddress, rpcTimeout)) {
+      rpcEndPoint.setState(EndpointStateMachine.EndPointStates.REGISTER);
+      RegisterEndpointTask endpointTask = getRegisterEndpointTask(false, conf, 
rpcEndPoint);
+      long start = Time.monotonicNow();
+      endpointTask.call();
+      long end = Time.monotonicNow();
+      assertThat(end - start)
+          .isGreaterThanOrEqualTo(rpcTimeout)
+          .isLessThanOrEqualTo(rpcTimeout + tolerance);
+    } finally {
+      scmServerImpl.setRpcResponseDelay(0);
+    }
   }
 
   @Test


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

Reply via email to