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/13 09:04:32 UTC
[iotdb] branch master updated: [IOTDB-5410] Refine IT: Refine Session and SessionPool IT (#8860)
This is an automated email from the ASF dual-hosted git repository.
ericpai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 2684767547 [IOTDB-5410] Refine IT: Refine Session and SessionPool IT (#8860)
2684767547 is described below
commit 268476754779e7f5303423d6bc2187496e4267c8
Author: BaiJian <er...@hotmail.com>
AuthorDate: Fri Jan 13 17:04:26 2023 +0800
[IOTDB-5410] Refine IT: Refine Session and SessionPool IT (#8860)
---
integration-test/import-control.xml | 2 +-
.../apache/iotdb/it/env/cluster/AbstractEnv.java | 20 +-
.../iotdb/it/env/remote/RemoteServerEnv.java | 40 ++++
.../java/org/apache/iotdb/itbase/env/BaseEnv.java | 117 +----------
.../it/cluster/IoTDBClusterNodeErrorStartUpIT.java | 30 ---
.../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 -
.../org/apache/iotdb/session/it/SessionIT.java | 83 +-------
.../iotdb/session/it/pool/SessionPoolIT.java | 230 +++++----------------
.../src/test/resources/iotdb-datanode.properties | 24 ---
.../src/test/resources/logback-test.xml | 2 +
.../java/org/apache/iotdb/session/TabletTest.java | 81 ++++++++
.../apache/iotdb/session/pool/SessionPoolTest.java | 63 ++++++
18 files changed, 277 insertions(+), 429 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/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/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/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/SessionIT.java b/integration-test/src/test/java/org/apache/iotdb/session/it/SessionIT.java
index 56c62a62e7..d4d9333ebf 100644
--- a/integration-test/src/test/java/org/apache/iotdb/session/it/SessionIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/session/it/SessionIT.java
@@ -22,7 +22,8 @@ import org.apache.iotdb.isession.ISession;
import org.apache.iotdb.isession.SessionDataSet;
import org.apache.iotdb.it.env.EnvFactory;
import org.apache.iotdb.it.framework.IoTDBTestRunner;
-import org.apache.iotdb.rpc.IoTDBConnectionException;
+import org.apache.iotdb.itbase.category.ClusterIT;
+import org.apache.iotdb.itbase.category.LocalStandaloneIT;
import org.apache.iotdb.rpc.StatementExecutionException;
import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
@@ -33,18 +34,19 @@ import org.apache.iotdb.tsfile.write.record.Tablet;
import org.apache.iotdb.tsfile.write.schema.MeasurementSchema;
import org.junit.After;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import java.util.ArrayList;
import java.util.List;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
@RunWith(IoTDBTestRunner.class)
+@Category({LocalStandaloneIT.class, ClusterIT.class})
public class SessionIT {
@Before
@@ -57,64 +59,6 @@ public class SessionIT {
EnvFactory.getEnv().cleanClusterEnvironment();
}
- @Test
- public void testSortTablet() {
- try (ISession session = EnvFactory.getEnv().getSessionConnection()) {
- /*
- To test sortTablet in Class Session
- !!!
- Before testing, change the sortTablet from private method to public method
- !!!
- */
- 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);
- } catch (IoTDBConnectionException e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
@Test
public void testInsertByStrAndSelectFailedData() {
try (ISession session = EnvFactory.getEnv().getSessionConnection()) {
@@ -160,20 +104,15 @@ public class SessionIT {
// ignore
}
- SessionDataSet dataSet = session.executeQueryStatement("select * from root.sg1.d1");
+ SessionDataSet dataSet =
+ session.executeQueryStatement("select s1, s2, s3, s4 from root.sg1.d1");
int i = 0;
while (dataSet.hasNext()) {
RowRecord record = dataSet.next();
- int nullCount = 0;
- for (int j = 0; j < 4; ++j) {
- if (record.getFields().get(j) == null
- || record.getFields().get(j).getDataType() == null) {
- ++nullCount;
- } else {
- assertEquals(i, record.getFields().get(j).getLongV());
- }
- }
- assertEquals(3, nullCount);
+ Assert.assertEquals(i, record.getFields().get(0).getLongV());
+ Assert.assertNull(record.getFields().get(1).getDataType());
+ Assert.assertNull(record.getFields().get(2).getDataType());
+ Assert.assertEquals(i, record.getFields().get(3).getDoubleV(), 0.00001);
i++;
}
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..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,27 +18,28 @@
*/
package org.apache.iotdb.session.it.pool;
-import org.apache.iotdb.db.utils.EnvironmentUtils;
+import org.apache.iotdb.commons.cluster.NodeStatus;
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.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.junit.After;
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.time.ZoneId;
-import java.time.ZoneOffset;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -53,6 +54,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 +62,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 +106,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 +125,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 +158,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 +208,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 +242,16 @@ 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);
+ 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");
- // TODO: replace stopDaemon() and restartDaemon() with new methods in Env.
- EnvironmentUtils.stopDaemon();
+ node.stop();
+ EnvFactory.getEnv()
+ .ensureNodeStatus(
+ Collections.singletonList(node), Collections.singletonList(NodeStatus.Unknown));
// user does not know what happens.
while (wrapper.hasNext()) {
wrapper.next();
@@ -272,25 +259,15 @@ 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);
+ 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();
return;
@@ -308,24 +285,15 @@ 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);
+ 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();
} catch (StatementExecutionException es) {
@@ -342,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;
@@ -383,53 +335,29 @@ 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);
+ 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);
+ 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
- EnvironmentUtils.reactiveDaemon();
+ node.start();
+ EnvFactory.getEnv()
+ .ensureNodeStatus(
+ Collections.singletonList(node), Collections.singletonList(NodeStatus.Running));
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 +377,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(
@@ -468,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());
@@ -532,6 +413,7 @@ public class SessionPoolIT {
pool.setFetchSize(16);
assertEquals(16, pool.getFetchSize());
} catch (Exception e) {
+ e.printStackTrace();
fail(e.getMessage());
} finally {
pool.close();
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..3c5b0815ee 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.tsfile.common.conf.TSFileDescriptor" level="WARN"/>
<logger name="DETAILED_FAILURE_QUERY_TRACE" level="ERROR"/>
<root level="INFO">
<appender-ref ref="stdout"/>
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());
+ }
+}