You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by er...@apache.org on 2023/01/12 09:48:37 UTC

[iotdb] branch improve/iotdb-5410 created (now 10bca3d3e8)

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

ericpai pushed a change to branch improve/iotdb-5410
in repository https://gitbox.apache.org/repos/asf/iotdb.git


      at 10bca3d3e8 [IOTDB-5410] Refine IT: Refine Session and SessionPool IT

This branch includes the following new commits:

     new 6c4c54e992 Temp save optimizing session IT
     new 10bca3d3e8 [IOTDB-5410] Refine IT: Refine Session and SessionPool IT

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[iotdb] 02/02: [IOTDB-5410] Refine IT: Refine Session and SessionPool IT

Posted by er...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ericpai pushed a commit to branch improve/iotdb-5410
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 10bca3d3e81a8e31bbcdda7d40a4457bacebac2e
Author: ericpai <er...@hotmail.com>
AuthorDate: Thu Jan 12 17:48:22 2023 +0800

    [IOTDB-5410] Refine IT: Refine Session and SessionPool IT
---
 integration-test/import-control.xml                |   2 +-
 .../it/cluster/IoTDBClusterNodeErrorStartUpIT.java |  30 ----
 .../iotdb/session/it/pool/SessionPoolIT.java       | 152 +++++----------------
 .../java/org/apache/iotdb/session/TabletTest.java  |  81 +++++++++++
 .../apache/iotdb/session/pool/SessionPoolTest.java |  63 +++++++++
 5 files changed, 181 insertions(+), 147 deletions(-)

diff --git a/integration-test/import-control.xml b/integration-test/import-control.xml
index 0465588691..4c685eca80 100644
--- a/integration-test/import-control.xml
+++ b/integration-test/import-control.xml
@@ -89,7 +89,7 @@
     <allow class="org.apache.iotdb.commons.conf.IoTDBConstant" />
     <allow class="org.apache.iotdb.db.conf.IoTDBDescriptor" />
     <allow class="org.apache.iotdb.db.conf.OperationType" />
-    <allow class="org.apache.iotdb.db.utils.EnvironmentUtils" />
+    <allow class="org.apache.iotdb.commons.cluster.NodeStatus" />
     <allow class="org.apache.iotdb.tsfile.common.constant.TsFileConstant" />
     <allow class="org.apache.iotdb.service.rpc.thrift.TSConnectionInfoResp" />
     <allow class="org.apache.iotdb.service.rpc.thrift.TSConnectionType" />
diff --git a/integration-test/src/test/java/org/apache/iotdb/confignode/it/cluster/IoTDBClusterNodeErrorStartUpIT.java b/integration-test/src/test/java/org/apache/iotdb/confignode/it/cluster/IoTDBClusterNodeErrorStartUpIT.java
index 8ec75c86d3..a57a3d1570 100644
--- a/integration-test/src/test/java/org/apache/iotdb/confignode/it/cluster/IoTDBClusterNodeErrorStartUpIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/confignode/it/cluster/IoTDBClusterNodeErrorStartUpIT.java
@@ -50,8 +50,6 @@ import org.junit.Before;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 import org.junit.runner.RunWith;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import java.io.File;
 import java.io.IOException;
@@ -61,17 +59,12 @@ import java.util.Arrays;
 @Category({ClusterIT.class})
 public class IoTDBClusterNodeErrorStartUpIT {
 
-  private static final Logger logger =
-      LoggerFactory.getLogger(IoTDBClusterNodeErrorStartUpIT.class);
-
   private static final int testConfigNodeNum = 3;
   private static final int testDataNodeNum = 1;
-  private static final int testNodeNum = testConfigNodeNum + testDataNodeNum;
   private static final String testConsensusProtocolClass = ConsensusFactory.RATIS_CONSENSUS;
 
   private static final String TEST_CLUSTER_NAME = "defaultCluster";
   private static final String ERROR_CLUSTER_NAME = "errorCluster";
-  private static final int maxRetryTimes = 60;
 
   @Before
   public void setUp() throws Exception {
@@ -328,27 +321,4 @@ public class IoTDBClusterNodeErrorStartUpIT {
               Arrays.asList(NodeStatus.Running, NodeStatus.Running));
     }
   }
-
-  private String showClusterStatus(TShowClusterResp showClusterResp) {
-    StringBuilder sb = new StringBuilder();
-    showClusterResp
-        .getConfigNodeList()
-        .forEach(
-            d ->
-                sb.append("ConfigNode")
-                    .append(d.getInternalEndPoint().getPort())
-                    .append(": ")
-                    .append(showClusterResp.getNodeStatus().get(d.getConfigNodeId()))
-                    .append("\n"));
-    showClusterResp
-        .getDataNodeList()
-        .forEach(
-            d ->
-                sb.append("DataNode")
-                    .append(d.getClientRpcEndPoint().getPort())
-                    .append(": ")
-                    .append(showClusterResp.getNodeStatus().get(d.getDataNodeId()))
-                    .append("\n"));
-    return sb.toString();
-  }
 }
diff --git a/integration-test/src/test/java/org/apache/iotdb/session/it/pool/SessionPoolIT.java b/integration-test/src/test/java/org/apache/iotdb/session/it/pool/SessionPoolIT.java
index 5e729bf073..ef11420d19 100644
--- a/integration-test/src/test/java/org/apache/iotdb/session/it/pool/SessionPoolIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/session/it/pool/SessionPoolIT.java
@@ -18,39 +18,28 @@
  */
 package org.apache.iotdb.session.it.pool;
 
-import org.apache.iotdb.commons.client.exception.ClientManagerException;
-import org.apache.iotdb.commons.client.sync.SyncConfigNodeIServiceClient;
 import org.apache.iotdb.commons.cluster.NodeStatus;
-import org.apache.iotdb.confignode.rpc.thrift.TDataNodeInfo;
-import org.apache.iotdb.confignode.rpc.thrift.TShowDataNodesResp;
 import org.apache.iotdb.isession.SessionConfig;
 import org.apache.iotdb.isession.pool.ISessionPool;
 import org.apache.iotdb.isession.pool.SessionDataSetWrapper;
-import org.apache.iotdb.isession.util.Version;
 import org.apache.iotdb.it.env.EnvFactory;
-import org.apache.iotdb.it.env.cluster.DataNodeWrapper;
 import org.apache.iotdb.it.framework.IoTDBTestRunner;
 import org.apache.iotdb.itbase.category.ClusterIT;
 import org.apache.iotdb.itbase.category.LocalStandaloneIT;
+import org.apache.iotdb.itbase.env.BaseNodeWrapper;
 import org.apache.iotdb.rpc.IoTDBConnectionException;
 import org.apache.iotdb.rpc.StatementExecutionException;
-import org.apache.iotdb.session.pool.SessionPool;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
 
-import org.apache.thrift.TException;
 import org.junit.After;
-import org.junit.Assert;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 import org.junit.runner.RunWith;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.IOException;
 import java.time.ZoneId;
-import java.time.ZoneOffset;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -253,14 +242,16 @@ public class SessionPoolIT {
   }
 
   @Test
-  public void tryIfTheServerIsRestart()
-      throws InterruptedException, TException, ClientManagerException, IOException {
+  public void tryIfTheServerIsRestart() {
     ISessionPool pool = EnvFactory.getEnv().getSessionPool(3);
     SessionDataSetWrapper wrapper = null;
+    BaseNodeWrapper node = EnvFactory.getEnv().getDataNodeWrapper(0);
     try {
       wrapper = pool.executeQueryStatement("select * from root.sg1.d1 where time > 1");
-      EnvFactory.getEnv().getDataNodeWrapper(0).stop();
-      EnvFactory.getEnv().getDataNodeWrapper(0).waitingToShutDown();
+      node.stop();
+      EnvFactory.getEnv()
+          .ensureNodeStatus(
+              Collections.singletonList(node), Collections.singletonList(NodeStatus.Unknown));
       // user does not know what happens.
       while (wrapper.hasNext()) {
         wrapper.next();
@@ -268,11 +259,14 @@ public class SessionPoolIT {
     } catch (IoTDBConnectionException e) {
       pool.closeResultSet(wrapper);
       pool.close();
-      EnvFactory.getEnv().getDataNodeWrapper(0).stop();
-      EnvFactory.getEnv().getDataNodeWrapper(0).waitingToShutDown();
-      Assert.assertTrue(waitDataNodeStatusUnknown(EnvFactory.getEnv().getDataNodeWrapper(0)));
-      EnvFactory.getEnv().getDataNodeWrapper(0).start();
-      TimeUnit.SECONDS.sleep(10);
+      node.stop();
+      EnvFactory.getEnv()
+          .ensureNodeStatus(
+              Collections.singletonList(node), Collections.singletonList(NodeStatus.Unknown));
+      node.start();
+      EnvFactory.getEnv()
+          .ensureNodeStatus(
+              Collections.singletonList(node), Collections.singletonList(NodeStatus.Running));
       pool = EnvFactory.getEnv().getSessionPool(3);
       correctQuery(pool, DEFAULT_QUERY_TIMEOUT);
       pool.close();
@@ -291,10 +285,14 @@ public class SessionPoolIT {
       } catch (IoTDBConnectionException ec) {
         pool.closeResultSet(wrapper);
         pool.close();
-        EnvFactory.getEnv().getDataNodeWrapper(0).stop();
-        EnvFactory.getEnv().getDataNodeWrapper(0).waitingToShutDown();
-        Assert.assertTrue(waitDataNodeStatusUnknown(EnvFactory.getEnv().getDataNodeWrapper(0)));
-        EnvFactory.getEnv().getDataNodeWrapper(0).start();
+        node.stop();
+        EnvFactory.getEnv()
+            .ensureNodeStatus(
+                Collections.singletonList(node), Collections.singletonList(NodeStatus.Unknown));
+        node.start();
+        EnvFactory.getEnv()
+            .ensureNodeStatus(
+                Collections.singletonList(node), Collections.singletonList(NodeStatus.Running));
         pool = EnvFactory.getEnv().getSessionPool(3);
         correctQuery(pool, DEFAULT_QUERY_TIMEOUT);
         pool.close();
@@ -312,24 +310,8 @@ public class SessionPoolIT {
   }
 
   @Test
-  @Ignore
   public void tryIfTheServerIsRestartButDataIsGotten() {
-    SessionPool pool =
-        new SessionPool(
-            "127.0.0.1",
-            6667,
-            "root",
-            "root",
-            3,
-            1,
-            60000,
-            false,
-            null,
-            false,
-            SessionConfig.DEFAULT_CONNECTION_TIMEOUT_MS,
-            SessionConfig.DEFAULT_VERSION,
-            SessionConfig.DEFAULT_INITIAL_BUFFER_CAPACITY,
-            SessionConfig.DEFAULT_MAX_FRAME_SIZE);
+    ISessionPool pool = EnvFactory.getEnv().getSessionPool(3);
     write10Data(pool, true);
     assertEquals(1, pool.currentAvailableSize());
     SessionDataSetWrapper wrapper;
@@ -353,20 +335,24 @@ public class SessionPoolIT {
   }
 
   @Test
-  public void restart()
-      throws TException, ClientManagerException, IOException, InterruptedException {
+  public void restart() {
     ISessionPool pool = EnvFactory.getEnv().getSessionPool(1);
     write10Data(pool, true);
     // stop the server.
     pool.close();
-    EnvFactory.getEnv().getDataNodeWrapper(0).stop();
-    EnvFactory.getEnv().getDataNodeWrapper(0).waitingToShutDown();
+    BaseNodeWrapper node = EnvFactory.getEnv().getDataNodeWrapper(0);
+    node.stop();
+    EnvFactory.getEnv()
+        .ensureNodeStatus(
+            Collections.singletonList(node), Collections.singletonList(NodeStatus.Unknown));
     pool = EnvFactory.getEnv().getSessionPool(1);
     // all this ten data will fail.
     write10Data(pool, false);
     // restart the server
-    Assert.assertTrue(waitDataNodeStatusUnknown(EnvFactory.getEnv().getDataNodeWrapper(0)));
-    EnvFactory.getEnv().getDataNodeWrapper(0).start();
+    node.start();
+    EnvFactory.getEnv()
+        .ensureNodeStatus(
+            Collections.singletonList(node), Collections.singletonList(NodeStatus.Running));
     write10Data(pool, true);
     pool.close();
   }
@@ -410,56 +396,9 @@ public class SessionPoolIT {
     // session.
   }
 
-  @Test
-  public void testBuilder() {
-    SessionPool pool =
-        new SessionPool.Builder()
-            .host("localhost")
-            .port(1234)
-            .maxSize(10)
-            .user("abc")
-            .password("123")
-            .fetchSize(1)
-            .waitToGetSessionTimeoutInMs(2)
-            .enableRedirection(true)
-            .enableCompression(true)
-            .zoneId(ZoneOffset.UTC)
-            .connectionTimeoutInMs(3)
-            .version(Version.V_0_13)
-            .build();
-
-    assertEquals("localhost", pool.getHost());
-    assertEquals(1234, pool.getPort());
-    assertEquals("abc", pool.getUser());
-    assertEquals("123", pool.getPassword());
-    assertEquals(10, pool.getMaxSize());
-    assertEquals(1, pool.getFetchSize());
-    assertEquals(2, pool.getWaitToGetSessionTimeoutInMs());
-    assertTrue(pool.isEnableRedirection());
-    assertTrue(pool.isEnableCompression());
-    assertEquals(3, pool.getConnectionTimeoutInMs());
-    assertEquals(ZoneOffset.UTC, pool.getZoneId());
-    assertEquals(Version.V_0_13, pool.getVersion());
-  }
-
   @Test
   public void testSetters() {
-    SessionPool pool =
-        new SessionPool(
-            "127.0.0.1",
-            6667,
-            "root",
-            "root",
-            3,
-            1,
-            60000,
-            false,
-            null,
-            false,
-            SessionConfig.DEFAULT_CONNECTION_TIMEOUT_MS,
-            SessionConfig.DEFAULT_VERSION,
-            SessionConfig.DEFAULT_INITIAL_BUFFER_CAPACITY,
-            SessionConfig.DEFAULT_MAX_FRAME_SIZE);
+    ISessionPool pool = EnvFactory.getEnv().getSessionPool(3);
     try {
       pool.setEnableRedirection(true);
       assertTrue(pool.isEnableRedirection());
@@ -474,29 +413,10 @@ public class SessionPoolIT {
       pool.setFetchSize(16);
       assertEquals(16, pool.getFetchSize());
     } catch (Exception e) {
+      e.printStackTrace();
       fail(e.getMessage());
     } finally {
       pool.close();
     }
   }
-
-  private boolean waitDataNodeStatusUnknown(DataNodeWrapper dataNode)
-      throws ClientManagerException, IOException, InterruptedException, TException {
-    try (SyncConfigNodeIServiceClient client =
-        (SyncConfigNodeIServiceClient) EnvFactory.getEnv().getLeaderConfigNodeConnection()) {
-      // At least wait 20 seconds
-      for (int count = 0; count < 30; count++) {
-        TShowDataNodesResp showDataNodesResp = client.showDataNodes();
-        for (TDataNodeInfo dataNodeInfo : showDataNodesResp.getDataNodesInfoList()) {
-          if (dataNodeInfo.getRpcAddresss().equals(dataNode.getIp())
-              && dataNodeInfo.getRpcPort() == dataNode.getPort()
-              && NodeStatus.Unknown.getStatus().equals(dataNodeInfo.getStatus())) {
-            return true;
-          }
-        }
-        TimeUnit.SECONDS.sleep(1);
-      }
-    }
-    return false;
-  }
 }
diff --git a/session/src/test/java/org/apache/iotdb/session/TabletTest.java b/session/src/test/java/org/apache/iotdb/session/TabletTest.java
new file mode 100644
index 0000000000..1ab00b3c52
--- /dev/null
+++ b/session/src/test/java/org/apache/iotdb/session/TabletTest.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iotdb.session;
+
+import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
+import org.apache.iotdb.tsfile.write.record.Tablet;
+import org.apache.iotdb.tsfile.write.schema.MeasurementSchema;
+
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.junit.Assert.assertArrayEquals;
+
+public class TabletTest {
+  @Test
+  public void testSortTablet() {
+    Session session = new Session("127.0.0.1", 1234);
+    List<MeasurementSchema> schemaList = new ArrayList<>();
+    schemaList.add(new MeasurementSchema("s1", TSDataType.INT64, TSEncoding.RLE));
+    // insert three rows data
+    Tablet tablet = new Tablet("root.sg1.d1", schemaList, 3);
+    long[] timestamps = tablet.timestamps;
+    Object[] values = tablet.values;
+
+    /*
+    inorder data before inserting
+    timestamp   s1
+    2           0
+    0           1
+    1           2
+     */
+    // inorder timestamps
+    timestamps[0] = 2;
+    timestamps[1] = 0;
+    timestamps[2] = 1;
+    // just one column INT64 data
+    long[] sensor = (long[]) values[0];
+    sensor[0] = 0;
+    sensor[1] = 1;
+    sensor[2] = 2;
+    tablet.rowSize = 3;
+
+    session.sortTablet(tablet);
+
+    /*
+    After sorting, if the tablet data is sorted according to the timestamps,
+    data in tablet will be
+    timestamp   s1
+    0           1
+    1           2
+    2           0
+
+    If the data equal to above tablet, test pass, otherwise test fialed
+     */
+    long[] resTimestamps = tablet.timestamps;
+    long[] resValues = (long[]) tablet.values[0];
+    long[] expectedTimestamps = new long[] {0, 1, 2};
+    long[] expectedValues = new long[] {1, 2, 0};
+    assertArrayEquals(expectedTimestamps, resTimestamps);
+    assertArrayEquals(expectedValues, resValues);
+  }
+}
diff --git a/session/src/test/java/org/apache/iotdb/session/pool/SessionPoolTest.java b/session/src/test/java/org/apache/iotdb/session/pool/SessionPoolTest.java
new file mode 100644
index 0000000000..9e00440895
--- /dev/null
+++ b/session/src/test/java/org/apache/iotdb/session/pool/SessionPoolTest.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iotdb.session.pool;
+
+import org.apache.iotdb.isession.util.Version;
+
+import org.junit.Test;
+
+import java.time.ZoneOffset;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class SessionPoolTest {
+
+  @Test
+  public void testBuilder() {
+    SessionPool pool =
+        new SessionPool.Builder()
+            .host("localhost")
+            .port(1234)
+            .maxSize(10)
+            .user("abc")
+            .password("123")
+            .fetchSize(1)
+            .waitToGetSessionTimeoutInMs(2)
+            .enableRedirection(true)
+            .enableCompression(true)
+            .zoneId(ZoneOffset.UTC)
+            .connectionTimeoutInMs(3)
+            .version(Version.V_0_13)
+            .build();
+
+    assertEquals("localhost", pool.getHost());
+    assertEquals(1234, pool.getPort());
+    assertEquals("abc", pool.getUser());
+    assertEquals("123", pool.getPassword());
+    assertEquals(10, pool.getMaxSize());
+    assertEquals(1, pool.getFetchSize());
+    assertEquals(2, pool.getWaitToGetSessionTimeoutInMs());
+    assertTrue(pool.isEnableRedirection());
+    assertTrue(pool.isEnableCompression());
+    assertEquals(3, pool.getConnectionTimeoutInMs());
+    assertEquals(ZoneOffset.UTC, pool.getZoneId());
+    assertEquals(Version.V_0_13, pool.getVersion());
+  }
+}


[iotdb] 01/02: Temp save optimizing session IT

Posted by er...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ericpai pushed a commit to branch improve/iotdb-5410
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 6c4c54e992247da8019f1aa22d1cb51a2b360f2e
Author: ericpai <er...@hotmail.com>
AuthorDate: Thu Jan 12 10:05:22 2023 +0800

    Temp save optimizing session IT
---
 .../apache/iotdb/it/env/cluster/AbstractEnv.java   |  20 ++-
 .../iotdb/it/env/remote/RemoteServerEnv.java       |  40 +++++
 .../java/org/apache/iotdb/itbase/env/BaseEnv.java  | 117 +-------------
 .../session/it/IoTDBSessionAlignedInsertIT.java    |   2 -
 .../iotdb/session/it/IoTDBSessionComplexIT.java    |   2 -
 .../it/IoTDBSessionDisableMemControlIT.java        |   2 -
 .../iotdb/session/it/IoTDBSessionInsertNullIT.java |   2 -
 .../session/it/IoTDBSessionSchemaTemplateIT.java   |   2 -
 .../iotdb/session/it/IoTDBSessionSimpleIT.java     |   2 -
 .../session/it/IoTDBSessionSyntaxConventionIT.java |   2 -
 .../iotdb/session/it/pool/SessionPoolIT.java       | 176 ++++++++-------------
 .../src/test/resources/iotdb-datanode.properties   |  24 ---
 .../src/test/resources/logback-test.xml            |   2 +
 13 files changed, 134 insertions(+), 259 deletions(-)

diff --git a/integration-test/src/main/java/org/apache/iotdb/it/env/cluster/AbstractEnv.java b/integration-test/src/main/java/org/apache/iotdb/it/env/cluster/AbstractEnv.java
index eade9e47d0..c0b36c0049 100644
--- a/integration-test/src/main/java/org/apache/iotdb/it/env/cluster/AbstractEnv.java
+++ b/integration-test/src/main/java/org/apache/iotdb/it/env/cluster/AbstractEnv.java
@@ -30,6 +30,7 @@ import org.apache.iotdb.confignode.rpc.thrift.IConfigNodeRPCService;
 import org.apache.iotdb.confignode.rpc.thrift.TShowClusterResp;
 import org.apache.iotdb.isession.ISession;
 import org.apache.iotdb.isession.SessionConfig;
+import org.apache.iotdb.isession.pool.ISessionPool;
 import org.apache.iotdb.it.env.EnvFactory;
 import org.apache.iotdb.it.framework.IoTDBTestLogger;
 import org.apache.iotdb.itbase.env.BaseEnv;
@@ -346,7 +347,24 @@ public abstract class AbstractEnv implements BaseEnv {
   }
 
   @Override
-  public SessionPool getSessionPool(int maxSize) {
+  public ISession getSessionConnection(List<String> nodeUrls) throws IoTDBConnectionException {
+    Session session =
+        new Session(
+            nodeUrls,
+            SessionConfig.DEFAULT_USER,
+            SessionConfig.DEFAULT_PASSWORD,
+            SessionConfig.DEFAULT_FETCH_SIZE,
+            null,
+            SessionConfig.DEFAULT_INITIAL_BUFFER_CAPACITY,
+            SessionConfig.DEFAULT_MAX_FRAME_SIZE,
+            SessionConfig.DEFAULT_REDIRECTION_MODE,
+            SessionConfig.DEFAULT_VERSION);
+    session.open();
+    return session;
+  }
+
+  @Override
+  public ISessionPool getSessionPool(int maxSize) {
     DataNodeWrapper dataNode =
         this.dataNodeWrapperList.get(rand.nextInt(this.dataNodeWrapperList.size()));
     return new SessionPool(
diff --git a/integration-test/src/main/java/org/apache/iotdb/it/env/remote/RemoteServerEnv.java b/integration-test/src/main/java/org/apache/iotdb/it/env/remote/RemoteServerEnv.java
index e1844a5beb..78e88fc9d2 100644
--- a/integration-test/src/main/java/org/apache/iotdb/it/env/remote/RemoteServerEnv.java
+++ b/integration-test/src/main/java/org/apache/iotdb/it/env/remote/RemoteServerEnv.java
@@ -26,6 +26,8 @@ import org.apache.iotdb.commons.client.sync.SyncConfigNodeIServiceClient;
 import org.apache.iotdb.commons.cluster.NodeStatus;
 import org.apache.iotdb.confignode.rpc.thrift.IConfigNodeRPCService;
 import org.apache.iotdb.isession.ISession;
+import org.apache.iotdb.isession.SessionConfig;
+import org.apache.iotdb.isession.pool.ISessionPool;
 import org.apache.iotdb.it.env.EnvFactory;
 import org.apache.iotdb.it.env.cluster.ConfigNodeWrapper;
 import org.apache.iotdb.it.env.cluster.DataNodeWrapper;
@@ -36,11 +38,13 @@ import org.apache.iotdb.jdbc.Config;
 import org.apache.iotdb.jdbc.Constant;
 import org.apache.iotdb.rpc.IoTDBConnectionException;
 import org.apache.iotdb.session.Session;
+import org.apache.iotdb.session.pool.SessionPool;
 
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.SQLException;
 import java.sql.Statement;
+import java.util.Collections;
 import java.util.List;
 
 import static org.apache.iotdb.jdbc.Config.VERSION;
@@ -150,6 +154,25 @@ public class RemoteServerEnv implements BaseEnv {
     return clientManager.borrowClient(new TEndPoint(ip_addr, 10710));
   }
 
+  @Override
+  public ISessionPool getSessionPool(int maxSize) {
+    return new SessionPool(
+        SessionConfig.DEFAULT_HOST,
+        SessionConfig.DEFAULT_PORT,
+        SessionConfig.DEFAULT_USER,
+        SessionConfig.DEFAULT_PASSWORD,
+        maxSize,
+        SessionConfig.DEFAULT_FETCH_SIZE,
+        60_000,
+        false,
+        null,
+        SessionConfig.DEFAULT_REDIRECTION_MODE,
+        SessionConfig.DEFAULT_CONNECTION_TIMEOUT_MS,
+        SessionConfig.DEFAULT_VERSION,
+        SessionConfig.DEFAULT_INITIAL_BUFFER_CAPACITY,
+        SessionConfig.DEFAULT_MAX_FRAME_SIZE);
+  }
+
   @Override
   public ISession getSessionConnection() throws IoTDBConnectionException {
     Session session = new Session(ip_addr, Integer.parseInt(port));
@@ -157,6 +180,23 @@ public class RemoteServerEnv implements BaseEnv {
     return session;
   }
 
+  @Override
+  public ISession getSessionConnection(List<String> nodeUrls) throws IoTDBConnectionException {
+    Session session =
+        new Session(
+            Collections.singletonList(ip_addr + ":" + port),
+            SessionConfig.DEFAULT_USER,
+            SessionConfig.DEFAULT_PASSWORD,
+            SessionConfig.DEFAULT_FETCH_SIZE,
+            null,
+            SessionConfig.DEFAULT_INITIAL_BUFFER_CAPACITY,
+            SessionConfig.DEFAULT_MAX_FRAME_SIZE,
+            SessionConfig.DEFAULT_REDIRECTION_MODE,
+            SessionConfig.DEFAULT_VERSION);
+    session.open();
+    return session;
+  }
+
   @Override
   public int getLeaderConfigNodeIndex() {
     return -1;
diff --git a/integration-test/src/main/java/org/apache/iotdb/itbase/env/BaseEnv.java b/integration-test/src/main/java/org/apache/iotdb/itbase/env/BaseEnv.java
index 4132e7b6db..6947ea63c0 100644
--- a/integration-test/src/main/java/org/apache/iotdb/itbase/env/BaseEnv.java
+++ b/integration-test/src/main/java/org/apache/iotdb/itbase/env/BaseEnv.java
@@ -22,19 +22,15 @@ import org.apache.iotdb.commons.client.exception.ClientManagerException;
 import org.apache.iotdb.commons.cluster.NodeStatus;
 import org.apache.iotdb.confignode.rpc.thrift.IConfigNodeRPCService;
 import org.apache.iotdb.isession.ISession;
-import org.apache.iotdb.isession.SessionConfig;
-import org.apache.iotdb.isession.util.Version;
+import org.apache.iotdb.isession.pool.ISessionPool;
 import org.apache.iotdb.it.env.cluster.ConfigNodeWrapper;
 import org.apache.iotdb.it.env.cluster.DataNodeWrapper;
 import org.apache.iotdb.jdbc.Constant;
 import org.apache.iotdb.rpc.IoTDBConnectionException;
-import org.apache.iotdb.session.Session;
-import org.apache.iotdb.session.pool.SessionPool;
 
 import java.io.IOException;
 import java.sql.Connection;
 import java.sql.SQLException;
-import java.time.ZoneId;
 import java.util.List;
 
 public interface BaseEnv {
@@ -80,116 +76,11 @@ public interface BaseEnv {
   IConfigNodeRPCService.Iface getLeaderConfigNodeConnection()
       throws ClientManagerException, IOException, InterruptedException;
 
-  default ISession getSessionConnection() throws IoTDBConnectionException {
-    return getSessionConnection(
-        SessionConfig.DEFAULT_HOST,
-        SessionConfig.DEFAULT_PORT,
-        SessionConfig.DEFAULT_USER,
-        SessionConfig.DEFAULT_PASSWORD,
-        SessionConfig.DEFAULT_FETCH_SIZE,
-        null,
-        SessionConfig.DEFAULT_INITIAL_BUFFER_CAPACITY,
-        SessionConfig.DEFAULT_MAX_FRAME_SIZE,
-        SessionConfig.DEFAULT_REDIRECTION_MODE,
-        SessionConfig.DEFAULT_VERSION);
-  }
-
-  default ISession getSessionConnection(
-      String host,
-      int rpcPort,
-      String username,
-      String password,
-      int fetchSize,
-      ZoneId zoneId,
-      int thriftDefaultBufferSize,
-      int thriftMaxFrameSize,
-      boolean enableRedirection,
-      Version version)
-      throws IoTDBConnectionException {
-    Session session =
-        new Session(
-            host,
-            rpcPort,
-            username,
-            password,
-            fetchSize,
-            zoneId,
-            thriftDefaultBufferSize,
-            thriftMaxFrameSize,
-            enableRedirection,
-            version);
-
-    session.open();
-    return session;
-  }
+  ISessionPool getSessionPool(int maxSize);
 
-  default ISession getSessionConnection(List<String> nodeUrls) throws IoTDBConnectionException {
-    Session session =
-        new Session(
-            nodeUrls,
-            SessionConfig.DEFAULT_USER,
-            SessionConfig.DEFAULT_PASSWORD,
-            SessionConfig.DEFAULT_FETCH_SIZE,
-            null,
-            SessionConfig.DEFAULT_INITIAL_BUFFER_CAPACITY,
-            SessionConfig.DEFAULT_MAX_FRAME_SIZE,
-            SessionConfig.DEFAULT_REDIRECTION_MODE,
-            SessionConfig.DEFAULT_VERSION);
-    session.open();
-    return session;
-  }
+  ISession getSessionConnection() throws IoTDBConnectionException;
 
-  default SessionPool getSessionPool(int maxSize) {
-    return getSessionPool(
-        SessionConfig.DEFAULT_HOST,
-        SessionConfig.DEFAULT_PORT,
-        SessionConfig.DEFAULT_USER,
-        SessionConfig.DEFAULT_PASSWORD,
-        maxSize,
-        SessionConfig.DEFAULT_FETCH_SIZE,
-        60_000,
-        false,
-        null,
-        SessionConfig.DEFAULT_REDIRECTION_MODE,
-        SessionConfig.DEFAULT_CONNECTION_TIMEOUT_MS,
-        SessionConfig.DEFAULT_VERSION,
-        SessionConfig.DEFAULT_INITIAL_BUFFER_CAPACITY,
-        SessionConfig.DEFAULT_MAX_FRAME_SIZE);
-  }
-
-  default SessionPool getSessionPool(
-      String host,
-      int port,
-      String user,
-      String password,
-      int maxSize,
-      int fetchSize,
-      long waitToGetSessionTimeoutInMs,
-      boolean enableCompression,
-      ZoneId zoneId,
-      boolean enableRedirection,
-      int connectionTimeoutInMs,
-      Version version,
-      int thriftDefaultBufferSize,
-      int thriftMaxFrameSize) {
-    SessionPool pool =
-        new SessionPool(
-            host,
-            port,
-            user,
-            password,
-            maxSize,
-            fetchSize,
-            waitToGetSessionTimeoutInMs,
-            enableCompression,
-            zoneId,
-            enableRedirection,
-            connectionTimeoutInMs,
-            version,
-            thriftDefaultBufferSize,
-            thriftMaxFrameSize);
-    return pool;
-  }
+  ISession getSessionConnection(List<String> nodeUrls) throws IoTDBConnectionException;
 
   /**
    * Get the index of the ConfigNode leader.
diff --git a/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionAlignedInsertIT.java b/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionAlignedInsertIT.java
index 3b18212821..94046d1b22 100644
--- a/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionAlignedInsertIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionAlignedInsertIT.java
@@ -18,7 +18,6 @@
  */
 package org.apache.iotdb.session.it;
 
-import org.apache.iotdb.commons.conf.IoTDBConstant;
 import org.apache.iotdb.isession.ISession;
 import org.apache.iotdb.isession.SessionDataSet;
 import org.apache.iotdb.it.env.EnvFactory;
@@ -55,7 +54,6 @@ public class IoTDBSessionAlignedInsertIT {
 
   @Before
   public void setUp() throws Exception {
-    System.setProperty(IoTDBConstant.IOTDB_CONF, "src/test/resources/");
     EnvFactory.getEnv().getConfig().getCommonConfig().setMaxDegreeOfIndexNode(3);
     EnvFactory.getEnv().initClusterEnvironment();
   }
diff --git a/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionComplexIT.java b/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionComplexIT.java
index 19e49c7904..e44c40ce99 100644
--- a/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionComplexIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionComplexIT.java
@@ -18,7 +18,6 @@
  */
 package org.apache.iotdb.session.it;
 
-import org.apache.iotdb.commons.conf.IoTDBConstant;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.isession.ISession;
 import org.apache.iotdb.isession.SessionDataSet;
@@ -62,7 +61,6 @@ import static org.junit.Assert.fail;
 public class IoTDBSessionComplexIT {
   @Before
   public void setUp() throws Exception {
-    System.setProperty(IoTDBConstant.IOTDB_CONF, "src/test/resources/");
     EnvFactory.getEnv().initClusterEnvironment();
   }
 
diff --git a/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionDisableMemControlIT.java b/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionDisableMemControlIT.java
index 3317a44678..aec033b3dc 100644
--- a/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionDisableMemControlIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionDisableMemControlIT.java
@@ -18,7 +18,6 @@
  */
 package org.apache.iotdb.session.it;
 
-import org.apache.iotdb.commons.conf.IoTDBConstant;
 import org.apache.iotdb.isession.ISession;
 import org.apache.iotdb.isession.SessionDataSet;
 import org.apache.iotdb.it.env.EnvFactory;
@@ -61,7 +60,6 @@ public class IoTDBSessionDisableMemControlIT {
 
   @Before
   public void setUp() throws Exception {
-    System.setProperty(IoTDBConstant.IOTDB_CONF, "src/test/resources/");
     EnvFactory.getEnv().getConfig().getCommonConfig().setEnableMemControl(false);
     EnvFactory.getEnv().initClusterEnvironment();
   }
diff --git a/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionInsertNullIT.java b/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionInsertNullIT.java
index 67b5e8d486..a77cf3e52c 100644
--- a/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionInsertNullIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionInsertNullIT.java
@@ -18,7 +18,6 @@
  */
 package org.apache.iotdb.session.it;
 
-import org.apache.iotdb.commons.conf.IoTDBConstant;
 import org.apache.iotdb.isession.ISession;
 import org.apache.iotdb.isession.SessionDataSet;
 import org.apache.iotdb.it.env.EnvFactory;
@@ -57,7 +56,6 @@ public class IoTDBSessionInsertNullIT {
 
   @Before
   public void setUp() throws Exception {
-    System.setProperty(IoTDBConstant.IOTDB_CONF, "src/test/resources/");
     EnvFactory.getEnv().initClusterEnvironment();
   }
 
diff --git a/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionSchemaTemplateIT.java b/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionSchemaTemplateIT.java
index 8e4988305f..42a33747a0 100644
--- a/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionSchemaTemplateIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionSchemaTemplateIT.java
@@ -19,7 +19,6 @@
 
 package org.apache.iotdb.session.it;
 
-import org.apache.iotdb.commons.conf.IoTDBConstant;
 import org.apache.iotdb.isession.ISession;
 import org.apache.iotdb.isession.template.Template;
 import org.apache.iotdb.isession.template.TemplateNode;
@@ -57,7 +56,6 @@ public class IoTDBSessionSchemaTemplateIT {
 
   @Before
   public void setUp() throws Exception {
-    System.setProperty(IoTDBConstant.IOTDB_CONF, "src/test/resources/");
     EnvFactory.getEnv().initClusterEnvironment();
     session = EnvFactory.getEnv().getSessionConnection();
   }
diff --git a/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionSimpleIT.java b/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionSimpleIT.java
index b7b9bd6090..bf9f07ea2e 100644
--- a/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionSimpleIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionSimpleIT.java
@@ -18,7 +18,6 @@
  */
 package org.apache.iotdb.session.it;
 
-import org.apache.iotdb.commons.conf.IoTDBConstant;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.conf.OperationType;
 import org.apache.iotdb.isession.ISession;
@@ -76,7 +75,6 @@ public class IoTDBSessionSimpleIT {
 
   @Before
   public void setUp() throws Exception {
-    System.setProperty(IoTDBConstant.IOTDB_CONF, "src/test/resources/");
     EnvFactory.getEnv().initClusterEnvironment();
   }
 
diff --git a/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionSyntaxConventionIT.java b/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionSyntaxConventionIT.java
index de7605d1c6..1940efc8c6 100644
--- a/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionSyntaxConventionIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionSyntaxConventionIT.java
@@ -18,7 +18,6 @@
  */
 package org.apache.iotdb.session.it;
 
-import org.apache.iotdb.commons.conf.IoTDBConstant;
 import org.apache.iotdb.isession.ISession;
 import org.apache.iotdb.isession.SessionDataSet;
 import org.apache.iotdb.it.env.EnvFactory;
@@ -54,7 +53,6 @@ public class IoTDBSessionSyntaxConventionIT {
 
   @Before
   public void setUp() throws Exception {
-    System.setProperty(IoTDBConstant.IOTDB_CONF, "src/test/resources/");
     EnvFactory.getEnv().initClusterEnvironment();
   }
 
diff --git a/integration-test/src/test/java/org/apache/iotdb/session/it/pool/SessionPoolIT.java b/integration-test/src/test/java/org/apache/iotdb/session/it/pool/SessionPoolIT.java
index 2e90cfe16b..5e729bf073 100644
--- a/integration-test/src/test/java/org/apache/iotdb/session/it/pool/SessionPoolIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/session/it/pool/SessionPoolIT.java
@@ -18,25 +18,37 @@
  */
 package org.apache.iotdb.session.it.pool;
 
-import org.apache.iotdb.db.utils.EnvironmentUtils;
+import org.apache.iotdb.commons.client.exception.ClientManagerException;
+import org.apache.iotdb.commons.client.sync.SyncConfigNodeIServiceClient;
+import org.apache.iotdb.commons.cluster.NodeStatus;
+import org.apache.iotdb.confignode.rpc.thrift.TDataNodeInfo;
+import org.apache.iotdb.confignode.rpc.thrift.TShowDataNodesResp;
 import org.apache.iotdb.isession.SessionConfig;
+import org.apache.iotdb.isession.pool.ISessionPool;
 import org.apache.iotdb.isession.pool.SessionDataSetWrapper;
 import org.apache.iotdb.isession.util.Version;
 import org.apache.iotdb.it.env.EnvFactory;
+import org.apache.iotdb.it.env.cluster.DataNodeWrapper;
 import org.apache.iotdb.it.framework.IoTDBTestRunner;
+import org.apache.iotdb.itbase.category.ClusterIT;
+import org.apache.iotdb.itbase.category.LocalStandaloneIT;
 import org.apache.iotdb.rpc.IoTDBConnectionException;
 import org.apache.iotdb.rpc.StatementExecutionException;
 import org.apache.iotdb.session.pool.SessionPool;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
 
+import org.apache.thrift.TException;
 import org.junit.After;
+import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
+import org.junit.experimental.categories.Category;
 import org.junit.runner.RunWith;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.io.IOException;
 import java.time.ZoneId;
 import java.time.ZoneOffset;
 import java.util.ArrayList;
@@ -53,6 +65,7 @@ import static org.junit.Assert.fail;
 
 // this test is not for testing the correctness of Session API. So we just implement one of the API.
 @RunWith(IoTDBTestRunner.class)
+@Category({LocalStandaloneIT.class, ClusterIT.class})
 public class SessionPoolIT {
 
   private static final Logger logger = LoggerFactory.getLogger(SessionPoolIT.class);
@@ -60,19 +73,18 @@ public class SessionPoolIT {
 
   @Before
   public void setUp() throws Exception {
-    EnvFactory.getEnv().initClusterEnvironment();
-    EnvironmentUtils.envSetUp();
+    // As this IT is only testing SessionPool itself, there's no need to launch a large cluster
+    EnvFactory.getEnv().initClusterEnvironment(1, 1);
   }
 
   @After
   public void tearDown() throws Exception {
-    EnvironmentUtils.cleanEnv();
     EnvFactory.getEnv().cleanClusterEnvironment();
   }
 
   @Test
   public void insert() {
-    SessionPool pool = EnvFactory.getEnv().getSessionPool(3);
+    ISessionPool pool = EnvFactory.getEnv().getSessionPool(3);
     ExecutorService service = Executors.newFixedThreadPool(10);
     for (int i = 0; i < 10; i++) {
       final int no = i;
@@ -105,7 +117,7 @@ public class SessionPoolIT {
 
   @Test
   public void incorrectSQL() {
-    SessionPool pool = EnvFactory.getEnv().getSessionPool(3);
+    ISessionPool pool = EnvFactory.getEnv().getSessionPool(3);
     assertEquals(0, pool.currentAvailableSize());
     try {
       pool.insertRecord(
@@ -124,7 +136,7 @@ public class SessionPoolIT {
 
   @Test
   public void incorrectExecuteQueryStatement() {
-    SessionPool pool = EnvFactory.getEnv().getSessionPool(3);
+    ISessionPool pool = EnvFactory.getEnv().getSessionPool(3);
     ExecutorService service = Executors.newFixedThreadPool(10);
     write10Data(pool, true);
     // now let's query
@@ -157,19 +169,19 @@ public class SessionPoolIT {
 
   @Test
   public void executeQueryStatement() {
-    SessionPool pool = EnvFactory.getEnv().getSessionPool(3);
+    ISessionPool pool = EnvFactory.getEnv().getSessionPool(3);
     correctQuery(pool, DEFAULT_QUERY_TIMEOUT);
     pool.close();
   }
 
   @Test
   public void executeQueryStatementWithTimeout() {
-    SessionPool pool = EnvFactory.getEnv().getSessionPool(3);
+    ISessionPool pool = EnvFactory.getEnv().getSessionPool(3);
     correctQuery(pool, 2000);
     pool.close();
   }
 
-  private void correctQuery(SessionPool pool, long timeoutInMs) {
+  private void correctQuery(ISessionPool pool, long timeoutInMs) {
     ExecutorService service = Executors.newFixedThreadPool(10);
     write10Data(pool, true);
     // now let's query
@@ -207,7 +219,7 @@ public class SessionPoolIT {
 
   @Test
   public void executeRawDataQuery() {
-    SessionPool pool = EnvFactory.getEnv().getSessionPool(3);
+    ISessionPool pool = EnvFactory.getEnv().getSessionPool(3);
     ExecutorService service = Executors.newFixedThreadPool(10);
     write10Data(pool, true);
     List<String> pathList = new ArrayList<>();
@@ -241,30 +253,14 @@ public class SessionPoolIT {
   }
 
   @Test
-  @Ignore
-  public void tryIfTheServerIsRestart() {
-    SessionPool pool =
-        new SessionPool(
-            "127.0.0.1",
-            6667,
-            "root",
-            "root",
-            3,
-            1,
-            6000,
-            false,
-            null,
-            false,
-            SessionConfig.DEFAULT_CONNECTION_TIMEOUT_MS,
-            SessionConfig.DEFAULT_VERSION,
-            SessionConfig.DEFAULT_INITIAL_BUFFER_CAPACITY,
-            SessionConfig.DEFAULT_MAX_FRAME_SIZE);
-    write10Data(pool, true);
+  public void tryIfTheServerIsRestart()
+      throws InterruptedException, TException, ClientManagerException, IOException {
+    ISessionPool pool = EnvFactory.getEnv().getSessionPool(3);
     SessionDataSetWrapper wrapper = null;
     try {
       wrapper = pool.executeQueryStatement("select * from root.sg1.d1 where time > 1");
-      // TODO: replace stopDaemon() and restartDaemon() with new methods in Env.
-      EnvironmentUtils.stopDaemon();
+      EnvFactory.getEnv().getDataNodeWrapper(0).stop();
+      EnvFactory.getEnv().getDataNodeWrapper(0).waitingToShutDown();
       // user does not know what happens.
       while (wrapper.hasNext()) {
         wrapper.next();
@@ -272,25 +268,12 @@ public class SessionPoolIT {
     } catch (IoTDBConnectionException e) {
       pool.closeResultSet(wrapper);
       pool.close();
-      EnvironmentUtils.stopDaemon();
-
-      EnvironmentUtils.reactiveDaemon();
-      pool =
-          new SessionPool(
-              "127.0.0.1",
-              6667,
-              "root",
-              "root",
-              3,
-              1,
-              6000,
-              false,
-              null,
-              false,
-              SessionConfig.DEFAULT_CONNECTION_TIMEOUT_MS,
-              SessionConfig.DEFAULT_VERSION,
-              SessionConfig.DEFAULT_INITIAL_BUFFER_CAPACITY,
-              SessionConfig.DEFAULT_MAX_FRAME_SIZE);
+      EnvFactory.getEnv().getDataNodeWrapper(0).stop();
+      EnvFactory.getEnv().getDataNodeWrapper(0).waitingToShutDown();
+      Assert.assertTrue(waitDataNodeStatusUnknown(EnvFactory.getEnv().getDataNodeWrapper(0)));
+      EnvFactory.getEnv().getDataNodeWrapper(0).start();
+      TimeUnit.SECONDS.sleep(10);
+      pool = EnvFactory.getEnv().getSessionPool(3);
       correctQuery(pool, DEFAULT_QUERY_TIMEOUT);
       pool.close();
       return;
@@ -308,24 +291,11 @@ public class SessionPoolIT {
       } catch (IoTDBConnectionException ec) {
         pool.closeResultSet(wrapper);
         pool.close();
-        EnvironmentUtils.stopDaemon();
-        EnvironmentUtils.reactiveDaemon();
-        pool =
-            new SessionPool(
-                "127.0.0.1",
-                6667,
-                "root",
-                "root",
-                3,
-                1,
-                6000,
-                false,
-                null,
-                false,
-                SessionConfig.DEFAULT_CONNECTION_TIMEOUT_MS,
-                SessionConfig.DEFAULT_VERSION,
-                SessionConfig.DEFAULT_INITIAL_BUFFER_CAPACITY,
-                SessionConfig.DEFAULT_MAX_FRAME_SIZE);
+        EnvFactory.getEnv().getDataNodeWrapper(0).stop();
+        EnvFactory.getEnv().getDataNodeWrapper(0).waitingToShutDown();
+        Assert.assertTrue(waitDataNodeStatusUnknown(EnvFactory.getEnv().getDataNodeWrapper(0)));
+        EnvFactory.getEnv().getDataNodeWrapper(0).start();
+        pool = EnvFactory.getEnv().getSessionPool(3);
         correctQuery(pool, DEFAULT_QUERY_TIMEOUT);
         pool.close();
       } catch (StatementExecutionException es) {
@@ -383,53 +353,25 @@ public class SessionPoolIT {
   }
 
   @Test
-  @Ignore
-  public void restart() {
-    SessionPool pool =
-        new SessionPool(
-            "127.0.0.1",
-            6667,
-            "root",
-            "root",
-            1,
-            1,
-            1000,
-            false,
-            null,
-            false,
-            SessionConfig.DEFAULT_CONNECTION_TIMEOUT_MS,
-            SessionConfig.DEFAULT_VERSION,
-            SessionConfig.DEFAULT_INITIAL_BUFFER_CAPACITY,
-            SessionConfig.DEFAULT_MAX_FRAME_SIZE);
+  public void restart()
+      throws TException, ClientManagerException, IOException, InterruptedException {
+    ISessionPool pool = EnvFactory.getEnv().getSessionPool(1);
     write10Data(pool, true);
     // stop the server.
     pool.close();
-    EnvironmentUtils.stopDaemon();
-    pool =
-        new SessionPool(
-            "127.0.0.1",
-            6667,
-            "root",
-            "root",
-            1,
-            1,
-            1000,
-            false,
-            null,
-            false,
-            SessionConfig.DEFAULT_CONNECTION_TIMEOUT_MS,
-            SessionConfig.DEFAULT_VERSION,
-            SessionConfig.DEFAULT_INITIAL_BUFFER_CAPACITY,
-            SessionConfig.DEFAULT_MAX_FRAME_SIZE);
+    EnvFactory.getEnv().getDataNodeWrapper(0).stop();
+    EnvFactory.getEnv().getDataNodeWrapper(0).waitingToShutDown();
+    pool = EnvFactory.getEnv().getSessionPool(1);
     // all this ten data will fail.
     write10Data(pool, false);
     // restart the server
-    EnvironmentUtils.reactiveDaemon();
+    Assert.assertTrue(waitDataNodeStatusUnknown(EnvFactory.getEnv().getDataNodeWrapper(0)));
+    EnvFactory.getEnv().getDataNodeWrapper(0).start();
     write10Data(pool, true);
     pool.close();
   }
 
-  private void write10Data(SessionPool pool, boolean failWhenThrowException) {
+  private void write10Data(ISessionPool pool, boolean failWhenThrowException) {
     for (int i = 0; i < 10; i++) {
       try {
         pool.insertRecord(
@@ -449,7 +391,7 @@ public class SessionPoolIT {
 
   @Test
   public void testClose() {
-    SessionPool pool = EnvFactory.getEnv().getSessionPool(3);
+    ISessionPool pool = EnvFactory.getEnv().getSessionPool(3);
     pool.close();
     try {
       pool.insertRecord(
@@ -537,4 +479,24 @@ public class SessionPoolIT {
       pool.close();
     }
   }
+
+  private boolean waitDataNodeStatusUnknown(DataNodeWrapper dataNode)
+      throws ClientManagerException, IOException, InterruptedException, TException {
+    try (SyncConfigNodeIServiceClient client =
+        (SyncConfigNodeIServiceClient) EnvFactory.getEnv().getLeaderConfigNodeConnection()) {
+      // At least wait 20 seconds
+      for (int count = 0; count < 30; count++) {
+        TShowDataNodesResp showDataNodesResp = client.showDataNodes();
+        for (TDataNodeInfo dataNodeInfo : showDataNodesResp.getDataNodesInfoList()) {
+          if (dataNodeInfo.getRpcAddresss().equals(dataNode.getIp())
+              && dataNodeInfo.getRpcPort() == dataNode.getPort()
+              && NodeStatus.Unknown.getStatus().equals(dataNodeInfo.getStatus())) {
+            return true;
+          }
+        }
+        TimeUnit.SECONDS.sleep(1);
+      }
+    }
+    return false;
+  }
 }
diff --git a/integration-test/src/test/resources/iotdb-datanode.properties b/integration-test/src/test/resources/iotdb-datanode.properties
deleted file mode 100644
index cc01ac1336..0000000000
--- a/integration-test/src/test/resources/iotdb-datanode.properties
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-
-base_dir=target/tmp
-dn_data_dirs=target/data
-dn_wal_dirs=target/wal
-sync_dir=target/sync
\ No newline at end of file
diff --git a/integration-test/src/test/resources/logback-test.xml b/integration-test/src/test/resources/logback-test.xml
index e73d764256..a1cce6aefe 100644
--- a/integration-test/src/test/resources/logback-test.xml
+++ b/integration-test/src/test/resources/logback-test.xml
@@ -51,6 +51,8 @@
     <logger name="org.apache.iotdb.db.service.DataNode" level="WARN"/>
     <logger name="org.apache.iotdb.db.service.RPCService" level="INFO"/>
     <logger name="org.apache.iotdb.db.service.MQTTService" level="INFO"/>
+    <logger name="org.apache.iotdb.db.conf.IoTDBDescriptor" level="WARN"/>
+    <logger name="org.apache.iotdb.db.conf.TSFileDescriptor" level="WARN"/>
     <logger name="DETAILED_FAILURE_QUERY_TRACE" level="ERROR"/>
     <root level="INFO">
         <appender-ref ref="stdout"/>