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

tanxinyu pushed a commit to branch fix_client_manager_test
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit e5e14b3da2fa134b9efb821558459cd0828b0033
Author: LebronAl <[email protected]>
AuthorDate: Mon Jun 13 14:17:13 2022 +0800

    fix test
---
 .../iotdb/commons/client/ClientManagerTest.java    | 24 ++++++++++++++--------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git 
a/node-commons/src/test/java/org/apache/iotdb/commons/client/ClientManagerTest.java
 
b/node-commons/src/test/java/org/apache/iotdb/commons/client/ClientManagerTest.java
index 2f8f4cca56..3a428cbc4f 100644
--- 
a/node-commons/src/test/java/org/apache/iotdb/commons/client/ClientManagerTest.java
+++ 
b/node-commons/src/test/java/org/apache/iotdb/commons/client/ClientManagerTest.java
@@ -20,7 +20,6 @@
 package org.apache.iotdb.commons.client;
 
 import org.apache.iotdb.common.rpc.thrift.TEndPoint;
-import org.apache.iotdb.commons.client.ClientPoolProperty.DefaultProperty;
 import 
org.apache.iotdb.commons.client.async.AsyncDataNodeInternalServiceClient;
 import org.apache.iotdb.commons.client.mock.MockInternalRPCService;
 import org.apache.iotdb.commons.client.sync.SyncDataNodeInternalServiceClient;
@@ -35,6 +34,7 @@ import org.junit.Before;
 import org.junit.Test;
 
 import java.io.IOException;
+import java.util.concurrent.TimeUnit;
 
 import static org.mockito.Mockito.mock;
 
@@ -57,6 +57,16 @@ public class ClientManagerTest {
   }
 
   @Test
+  public void allTest() throws Exception {
+    normalSyncClientManagersTest();
+    normalAsyncClientManagersTest();
+    MaxIdleClientManagersTest();
+    MaxTotalClientManagersTest();
+    MaxWaitClientTimeoutClientManagersTest();
+    InvalidSyncClientReturnClientManagersTest();
+    InvalidAsyncClientReturnClientManagersTest();
+  }
+
   public void normalSyncClientManagersTest() throws Exception {
     // init syncClientManager
     ClientManager<TEndPoint, SyncDataNodeInternalServiceClient> 
syncClusterManager =
@@ -100,7 +110,6 @@ public class ClientManagerTest {
     Assert.assertFalse(syncClient2.getInputProtocol().getTransport().isOpen());
   }
 
-  @Test
   public void normalAsyncClientManagersTest() throws Exception {
     // init asyncClientManager
     ClientManager<TEndPoint, AsyncDataNodeInternalServiceClient> 
asyncClusterManager =
@@ -142,7 +151,6 @@ public class ClientManagerTest {
     Assert.assertEquals(0, asyncClusterManager.getPool().getNumIdle(endPoint));
   }
 
-  @Test
   public void MaxIdleClientManagersTest() throws Exception {
     int maxIdleClientForEachNode = 1;
 
@@ -202,9 +210,9 @@ public class ClientManagerTest {
     Assert.assertFalse(syncClient1.getInputProtocol().getTransport().isOpen());
   }
 
-  @Test
   public void MaxTotalClientManagersTest() throws Exception {
     int maxTotalClientForEachNode = 1;
+    long waitClientTimeoutMs = TimeUnit.SECONDS.toMillis(1);
 
     // init syncClientManager and set maxTotalClientForEachNode to 1
     ClientManager<TEndPoint, SyncDataNodeInternalServiceClient> 
syncClusterManager =
@@ -221,6 +229,7 @@ public class ClientManagerTest {
                                 manager, new 
ClientFactoryProperty.Builder().build()),
                             new 
ClientPoolProperty.Builder<SyncDataNodeInternalServiceClient>()
                                 
.setMaxTotalClientForEachNode(maxTotalClientForEachNode)
+                                .setWaitClientTimeoutMS(waitClientTimeoutMs)
                                 .build()
                                 .getConfig());
                       }
@@ -243,7 +252,7 @@ public class ClientManagerTest {
       syncClient2 = syncClusterManager.borrowClient(endPoint);
     } catch (IOException e) {
       end = System.nanoTime();
-      Assert.assertTrue(end - start >= DefaultProperty.WAIT_CLIENT_TIMEOUT_MS 
* 1_000_000);
+      Assert.assertTrue(end - start >= waitClientTimeoutMs * 1_000_000);
       Assert.assertTrue(e.getMessage().startsWith("Borrow client from pool for 
node"));
     }
     Assert.assertNull(syncClient2);
@@ -272,9 +281,8 @@ public class ClientManagerTest {
     Assert.assertFalse(syncClient2.getInputProtocol().getTransport().isOpen());
   }
 
-  @Test
   public void MaxWaitClientTimeoutClientManagersTest() throws Exception {
-    long waitClientTimeoutMS = DefaultProperty.WAIT_CLIENT_TIMEOUT_MS * 2;
+    long waitClientTimeoutMS = TimeUnit.SECONDS.toMillis(2);
     int maxTotalClientForEachNode = 1;
 
     // init syncClientManager and set maxTotalClientForEachNode to 1, set 
waitClientTimeoutMS to
@@ -331,7 +339,6 @@ public class ClientManagerTest {
     Assert.assertFalse(syncClient1.getInputProtocol().getTransport().isOpen());
   }
 
-  @Test
   public void InvalidSyncClientReturnClientManagersTest() throws Exception {
     // init syncClientManager
     ClientManager<TEndPoint, SyncDataNodeInternalServiceClient> 
syncClusterManager =
@@ -375,7 +382,6 @@ public class ClientManagerTest {
     Assert.assertFalse(syncClient2.getInputProtocol().getTransport().isOpen());
   }
 
-  @Test
   public void InvalidAsyncClientReturnClientManagersTest() throws Exception {
     // init asyncClientManager
     ClientManager<TEndPoint, AsyncDataNodeInternalServiceClient> 
asyncClusterManager =

Reply via email to