未验证 提交 7458f4d3 编写于 作者: X Xiangdong Huang 提交者: GitHub

[IOTDB-1310] Enable docker, docker-compose and testcontainer for End to end test (#3024)

* enable TestCongtainer for E2E test for (singleNode and cluster)

* remove duplicated operations in integration-test phase

* move spotless:apply to a profile `spotless`, which is enabled by default.
Co-authored-by: Nxiangdong huang <sainthxd@gmail.com>
上级 f2e53d7d
......@@ -39,11 +39,11 @@ jobs:
restore-keys: ${{ runner.os }}-m2
- name: Build Distribution Zip
run: ./mvnw.sh -B -DskipTests clean package
run: ./mvnw.sh -B -DskipTests clean install
- name: Build Docker Image
run: |
docker build . -f docker/src/main/Dockerfile -t "iotdb:$GITHUB_SHA"
docker build . -f docker/src/main/Dockerfile-single -t "iotdb:$GITHUB_SHA"
docker images
- name: Run Test Case ${{ matrix.case }}
......@@ -52,3 +52,7 @@ jobs:
- name: Clean Up
if: ${{ always() }}
run: bash test/e2e/cases/${{ matrix.case }}/cleanup.sh
- name: TestContainer
run: |
mvn -B integration-test -pl testcontainer
......@@ -96,7 +96,6 @@
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
......
......@@ -202,7 +202,6 @@
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
......
......@@ -29,6 +29,7 @@
#-------------------------------------------IMPORTANT---------------------------------------------#
# used for communication between cluster nodes, eg heartbeat、raft logs and snapshots etc.
# if this parameter is commented, then the IP that binded by the hostname will be used.
internal_ip=127.0.0.1
# port for metadata service
......@@ -51,7 +52,8 @@ internal_data_port=40010
# nodes that already in the cluster, unnecessary to be the nodes that were used to build the
# initial cluster by start-node.sh(.bat). Several nodes will be picked randomly to send the
# request, the number of nodes picked depends on the number of retries.
seed_nodes=127.0.0.1:9003,127.0.0.1:9005,127.0.0.1:9007
#seed_nodes=127.0.0.1:9003,127.0.0.1:9005,127.0.0.1:9007
seed_nodes=127.0.0.1:9003
# whether to use thrift compressed protocol for internal communications. If you want to change
# compression settings for external clients, please modify 'rpc_thrift_compression_enable' in
......
......@@ -157,6 +157,7 @@ public class ClusterMain {
config.getSeedNodeUrls().size(), quorum);
throw new StartupException(metaServer.getMember().getName(), message);
}
// assert not duplicated nodes
Set<Node> seedNodes = new HashSet<>();
for (String url : config.getSeedNodeUrls()) {
......
......@@ -21,22 +21,26 @@ package org.apache.iotdb.cluster.config;
import org.apache.iotdb.cluster.utils.ClusterConsistent;
import org.apache.iotdb.db.conf.IoTDBDescriptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;
public class ClusterConfig {
private static Logger logger = LoggerFactory.getLogger(ClusterConfig.class);
static final String CONFIG_NAME = "iotdb-cluster.properties";
private String internalIp = "127.0.0.1";
private String internalIp;
private int internalMetaPort = 9003;
private int internalDataPort = 40010;
private int clusterRpcPort = IoTDBDescriptor.getInstance().getConfig().getRpcPort();
/** each one is a {internalIp | domain name}:{meta port} string tuple. */
private List<String> seedNodeUrls =
Arrays.asList(String.format("%s:%d", internalIp, internalMetaPort));
private List<String> seedNodeUrls;
@ClusterConsistent private boolean isRpcThriftCompressionEnabled = false;
private int maxConcurrentClientNum = 10000;
......@@ -164,6 +168,21 @@ public class ClusterConfig {
private boolean openServerRpcPort = false;
/**
* create a clusterConfig class. The internalIP will be set according to the server's hostname. If
* there is something error for getting the ip of the hostname, then set the internalIp as
* localhost.
*/
public ClusterConfig() {
try {
internalIp = InetAddress.getLocalHost().getHostAddress();
} catch (UnknownHostException e) {
logger.error(e.getMessage());
internalIp = "127.0.0.1";
}
seedNodeUrls = Arrays.asList(String.format("%s:%d", internalIp, internalMetaPort));
}
public int getSelectorNumOfClientPool() {
return selectorNumOfClientPool;
}
......
......@@ -73,7 +73,6 @@
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
......
#
# 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.
#
# docker build context is the root path of the repository
FROM openjdk:11-jre-slim
ADD distribution/target/apache-iotdb-*-cluster-bin.zip /
RUN apt update \
&& apt install lsof procps unzip -y \
&& unzip /apache-iotdb-*-bin.zip -d / \
&& rm /apache-iotdb-*-bin.zip \
&& mv /apache-iotdb-* /iotdb \
&& apt remove unzip -y \
&& apt autoremove -y \
&& apt purge --auto-remove -y \
&& apt clean -y
EXPOSE 6667
EXPOSE 31999
EXPOSE 5555
EXPOSE 8181
VOLUME /iotdb/data
VOLUME /iotdb/logs
ENV PATH="/iotdb/sbin/:/iotdb/tools/:${PATH}"
ENTRYPOINT ["/iotdb/sbin/start-node.sh"]
......@@ -21,7 +21,7 @@
FROM openjdk:11-jre-slim
ADD distribution/target/apache-iotdb-*-all-bin.zip /
ADD distribution/target/apache-iotdb-*-server-bin.zip /
RUN apt update \
&& apt install lsof procps unzip -y \
......
......@@ -197,7 +197,6 @@
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
......
......@@ -116,7 +116,6 @@
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
......
......@@ -159,7 +159,6 @@
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
......
......@@ -509,6 +509,12 @@
<artifactId>mockito-all</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>1.15.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
......@@ -913,6 +919,10 @@
<!-- Include integration tests within integration-test phase. -->
<include>src/test/**/*IT.java</include>
</includes>
<excludes>
<!-- Exclude unit tests within (unit) test phase. -->
<exclude>src/test/**/*Test.java</exclude>
</excludes>
</configuration>
</execution>
</executions>
......@@ -932,13 +942,27 @@
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<!-- spotless is too slow, so we put it into a profile to skip it if needed -->
<profile>
<id>spotless</id>
<activation>
<!-- activeByDefault does not take effect-->
<file>
<exists>.</exists>
</file>
</activation>
<build>
<plugins>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<profiles>
</profile>
<!--
A set of profiles defining the different properties needed to download and run thrift
They are automatically activated depending on the OS you are using.
......@@ -992,6 +1016,30 @@
<thrift.exec-cmd.args>+x ${project.build.directory}/tools/${thrift.executable}</thrift.exec-cmd.args>
</properties>
</profile>
<!-- for TestContainer. As it requires docker, we have to detect whether docker exists.-->
<profile>
<!-- Mac and Unix-->
<id>unixDockerCheck</id>
<activation>
<file>
<exists>/var/run/docker.sock</exists>
</file>
</activation>
<modules>
<module>testcontainer</module>
</modules>
</profile>
<profile>
<id>WinDockerCheck</id>
<activation>
<file>
<exists>C:\Program Files\Docker\Docker\resources\bin\docker.exe</exists>
</file>
</activation>
<modules>
<module>testcontainer</module>
</modules>
</profile>
<!-- Some APIs were removed in Java 11, so we need to add replacements -->
<profile>
<id>java-11-and-above</id>
......
......@@ -231,7 +231,6 @@
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
......
#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.
......@@ -114,7 +114,6 @@
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
......
......@@ -54,7 +54,6 @@
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
......
......@@ -23,7 +23,7 @@ services:
server-prototype:
build:
context: ../../..
dockerfile: docker/src/main/Dockerfile
dockerfile: docker/src/main/Dockerfile-single
ports:
- 6667:6667
networks:
......@@ -37,7 +37,7 @@ services:
initializer:
build:
context: ../../..
dockerfile: docker/src/main/Dockerfile
dockerfile: docker/src/main/Dockerfile-single
networks:
iotdb:
entrypoint:
......
文件模式从 100644 更改为 100755
文件模式从 100644 更改为 100755
<!--
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.
-->
# Description
This module is for using Docker and TestContainer for end to end test.
## Requirements
You have to install Docker before you runn this module.
See [Docker Version Requirement](https://www.testcontainers.org/supported_docker_environment/).
IoTDB project will detect whether a Docker is installed (but do not check the docker's version).
The logic is, for Unix-like system, it checks whether `/var/run/docker.sock` exists.
For Window system, it checks whether `C:\Program Files\Docker\Docker\resources\bin\docker.exe` exists.
If you are sure you have installed the Docker but `testcontainer` module is not loaed, use `-P unixDockerCheck`
in your maven command, which also works on Windows OS.
## Behavior
Before running `integration-test` in this module, binaries must be generated in the `distribution` module,
e.g, call `mvn package -Dmaven.test.skip=true`.
In this module, when running `mvn pre-integration-test` (or `mvn integration-test`, `mvn post-integration-test`),
the module will build two docker images, `apache/iotdb:maven-development`, and `apache/iotdb:cluster-maven-development`.
In the `post-integration-test` phase, the above images will be removed.
In the `integration-test` phase, all `src/test/java/**/*IT.java` will be tested.
## How it runs
`apache/iotdb:maven-development` is generated following the Dockerfile `${basedir}/docker/src/main/Dockerfile-single`, and
`apache/iotdb:cluster-maven-development` is generated following the Dockerfile `${basedir}/docker/src/main/Dockerfile-cluster`.
For testing a cluster, we use `docker-compose` and `testcontainer`.
The docker-compose file is located at `src/test/resources/1nodes`, `src/test/resources/3nodes` and `src/test/resources/5nodes`,
in which one is for 1 node with replica number =1 , 3 nodes with replica number=3, and the last one is for 5 nodes with replica number =3.
TestContainer can start the docker (or docker compose) automatically.
But these docker compose files can also be used independently.
e.g., `docker-compose up`.
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.apache.iotdb</groupId>
<artifactId>iotdb-parent</artifactId>
<version>0.13.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>testcontainer</artifactId>
<properties>
<docker.test.skip>false</docker.test.skip>
<docker.build.executable>docker</docker.build.executable>
<docker.build.single.argument>build -t apache/iotdb:maven-development -f ${basedir}/../docker/src/main/Dockerfile-single ${basedir}/../.</docker.build.single.argument>
<docker.clean.single.argument>image rm apache/iotdb:maven-development</docker.clean.single.argument>
<docker.build.cluster.argument>build -t apache/iotdb:cluster-maven-development -f ${basedir}/../docker/src/main/Dockerfile-cluster ${basedir}/../.</docker.build.cluster.argument>
<docker.clean.cluster.argument>image rm apache/iotdb:cluster-maven-development</docker.clean.cluster.argument>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.iotdb</groupId>
<artifactId>iotdb-jdbc</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.iotdb</groupId>
<artifactId>iotdb-session</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.iotdb</groupId>
<artifactId>iotdb-cli</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>testcontainer</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<!-- before integration test, we build the docker image -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<id>build-docker-image</id>
<phase>pre-integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<skip>${docker.test.skip}</skip>
<executable>${docker.build.executable}</executable>
<commandlineArgs>${docker.build.single.argument}</commandlineArgs>
</configuration>
</execution>
<execution>
<id>build-cluster-docker-image</id>
<phase>pre-integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<skip>${docker.test.skip}</skip>
<executable>${docker.build.executable}</executable>
<commandlineArgs>${docker.build.cluster.argument}</commandlineArgs>
</configuration>
</execution>
<execution>
<id>clean-docker-image</id>
<phase>post-integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<skip>${docker.test.skip}</skip>
<executable>${docker.build.executable}</executable>
<commandlineArgs>${docker.clean.single.argument}</commandlineArgs>
</configuration>
</execution>
<execution>
<id>clean-cluster-docker-image</id>
<phase>post-integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<skip>${docker.test.skip}</skip>
<executable>${docker.build.executable}</executable>
<commandlineArgs>${docker.clean.cluster.argument}</commandlineArgs>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>add-test-container-source</id>
<phase>generate-test-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>${basedir}/src/test/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<id>run-integration-tests</id>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
/*
* 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.db.sql;
import org.apache.iotdb.jdbc.Config;
import org.junit.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.containers.DockerComposeContainer;
import org.testcontainers.containers.NoProjectNameDockerComposeContainer;
import org.testcontainers.containers.output.Slf4jLogConsumer;
import org.testcontainers.containers.wait.strategy.Wait;
import java.io.File;
import java.sql.*;
import java.util.HashSet;
import java.util.Set;
public class ClusterIT {
private static Logger logger = LoggerFactory.getLogger(ClusterIT.class);
private static Logger node1Logger = LoggerFactory.getLogger("iotdb-server_1");
private static Logger node2Logger = LoggerFactory.getLogger("iotdb-server_2");
private static Logger node3Logger = LoggerFactory.getLogger("iotdb-server_3");
private Statement statement;
private Connection connection;
// in TestContainer's document, it is @ClassRule, and the environment is `public static`
// I am not sure the difference now.
@Rule
public DockerComposeContainer environment =
new NoProjectNameDockerComposeContainer(
"3nodes", new File("src/test/resources/3nodes/docker-compose.yaml"))
.withExposedService("iotdb-server_1", 6667, Wait.forListeningPort())
.withLogConsumer("iotdb-server_1", new Slf4jLogConsumer(node1Logger))
.withExposedService("iotdb-server_2", 6667, Wait.forListeningPort())
.withLogConsumer("iotdb-server_2", new Slf4jLogConsumer(node2Logger))
.withExposedService("iotdb-server_3", 6667, Wait.forListeningPort())
.withLogConsumer("iotdb-server_3", new Slf4jLogConsumer(node3Logger))
.withLocalCompose(true);
int rpcPort = 6667;
@Before
public void setUp() throws Exception {
String ip = environment.getServiceHost("iotdb-server_1", 6667);
rpcPort = environment.getServicePort("iotdb-server_1", 6667);
Class.forName(Config.JDBC_DRIVER_NAME);
connection = DriverManager.getConnection("jdbc:iotdb://" + ip + ":" + rpcPort, "root", "root");
statement = connection.createStatement();
}
@After
public void tearDown() throws Exception {
statement.close();
connection.close();
}
@Test
public void testSimplePutAndGet() throws SQLException {
String[] timeSeriesArray = {"root.sg1.aa.bb", "root.sg1.aa.bb.cc", "root.sg1.aa"};
for (String timeSeries : timeSeriesArray) {
statement.execute(
String.format(
"create timeseries %s with datatype=INT64, encoding=PLAIN, compression=SNAPPY",
timeSeries));
}
ResultSet resultSet = null;
resultSet = statement.executeQuery("show timeseries");
Set<String> result = new HashSet<>();
while (resultSet.next()) {
result.add(resultSet.getString(1));
}
Assert.assertEquals(3, result.size());
for (String timeseries : timeSeriesArray) {
Assert.assertTrue(result.contains(timeseries));
}
}
}
/*
* 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.db.sql;
import org.apache.iotdb.jdbc.Config;
import org.junit.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.containers.BindMode;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.output.Slf4jLogConsumer;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.images.PullPolicy;
import org.testcontainers.utility.DockerImageName;
import java.io.File;
import java.sql.*;
import java.util.HashSet;
import java.util.Set;
public class SingleNodeIT {
private static Logger logger = LoggerFactory.getLogger(SingleNodeIT.class);
private Statement statement;
private Connection connection;
@Rule
public GenericContainer dslContainer =
new GenericContainer(DockerImageName.parse("apache/iotdb:maven-development"))
.withImagePullPolicy(PullPolicy.defaultPolicy())
// mount another properties for changing parameters, e.g., open 5555 port (sync module)
.withFileSystemBind(
new File("src/test/resources/iotdb-engine.properties").getAbsolutePath(),
"/iotdb/conf/iotdb-engine.properties",
BindMode.READ_ONLY)
.withFileSystemBind(
new File("src/test/resources/logback-container.xml").getAbsolutePath(),
"/iotdb/conf/logback.xml",
BindMode.READ_ONLY)
.withLogConsumer(new Slf4jLogConsumer(logger))
.withExposedPorts(6667)
.waitingFor(Wait.forListeningPort());
int rpcPort = 6667;
int syncPort = 5555;
@Before
public void setUp() throws Exception {
rpcPort = dslContainer.getMappedPort(6667);
syncPort = dslContainer.getMappedPort(5555);
Class.forName(Config.JDBC_DRIVER_NAME);
connection = DriverManager.getConnection("jdbc:iotdb://127.0.0.1:" + rpcPort, "root", "root");
statement = connection.createStatement();
}
@After
public void tearDown() throws Exception {
statement.close();
connection.close();
}
@Test
public void testSimplePutAndGet() throws SQLException {
String[] timeSeriesArray = {"root.sg1.aa.bb", "root.sg1.aa.bb.cc", "root.sg1.aa"};
for (String timeSeries : timeSeriesArray) {
statement.execute(
String.format(
"create timeseries %s with datatype=INT64, encoding=PLAIN, compression=SNAPPY",
timeSeries));
}
ResultSet resultSet = null;
resultSet = statement.executeQuery("show timeseries");
Set<String> result = new HashSet<>();
while (resultSet.next()) {
result.add(resultSet.getString(1));
}
Assert.assertEquals(3, result.size());
for (String timeseries : timeSeriesArray) {
Assert.assertTrue(result.contains(timeseries));
}
}
}
/*
* 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.testcontainers.containers;
import java.io.File;
import java.lang.reflect.Field;
public class NoProjectNameDockerComposeContainer extends DockerComposeContainer {
public NoProjectNameDockerComposeContainer(String identifier, File... composeFiles) {
super(identifier, composeFiles);
Field project = null;
try {
project = DockerComposeContainer.class.getDeclaredField("project");
project.setAccessible(true);
project.set(this, "");
} catch (NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
}
}
}
#
# 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.
#
version: '3.8'
services:
iotdb-server:
image: apache/iotdb:cluster-maven-development
expose:
- 6667
- 9003
- 40010
networks:
- iotdb
healthcheck:
test: [ "CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/6667" ]
interval: 5s
timeout: 60s
retries: 120
volumes:
- ./iotdb-cluster.properties:/iotdb/conf/iotdb-cluster.properties
- ../logback-container.xml:/iotdb/conf/logback.xml
scale: 1
networks:
iotdb:
driver: bridge
#
# 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.
internal_meta_port=9003
internal_data_port=40010
seed_nodes=3nodes_iotdb-server_1:9003
default_replica_num=1
consistency_level=mid
connection_timeout_ms=20000
write_operation_timeout_ms=30000
read_operation_timeout_ms=30000
catch_up_timeout_ms=300000
use_batch_in_catch_up=true
min_num_of_logs_in_mem=1000
max_num_of_logs_in_mem=2000
log_deletion_check_interval_second=-1
is_use_async_server=false
is_use_async_applier=true
is_enable_raft_log_persistence=true
open_server_rpc_port=false
#
# 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.
#
version: '3.8'
services:
iotdb-server:
image: apache/iotdb:cluster-maven-development
expose:
- 6667
- 9003
- 40010
networks:
- iotdb
healthcheck:
test: [ "CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/6667" ]
interval: 5s
timeout: 60s
retries: 120
volumes:
- ./iotdb-cluster.properties:/iotdb/conf/iotdb-cluster.properties
- ../logback-container.xml:/iotdb/conf/logback.xml
scale: 3
networks:
iotdb:
driver: bridge
#
# 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.
internal_meta_port=9003
internal_data_port=40010
seed_nodes=3nodes_iotdb-server_1:9003,3nodes_iotdb-server_2:9003,3nodes_iotdb-server_3:9003
default_replica_num=3
consistency_level=mid
connection_timeout_ms=20000
write_operation_timeout_ms=30000
read_operation_timeout_ms=30000
catch_up_timeout_ms=300000
use_batch_in_catch_up=true
min_num_of_logs_in_mem=1000
max_num_of_logs_in_mem=2000
log_deletion_check_interval_second=-1
is_use_async_server=false
is_use_async_applier=true
is_enable_raft_log_persistence=true
open_server_rpc_port=false
#
# 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.
#
version: '3.8'
services:
iotdb-server:
image: apache/iotdb:cluster-maven-development
expose:
- 6667
- 9003
- 40010
networks:
- iotdb
healthcheck:
test: [ "CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/6667" ]
interval: 5s
timeout: 60s
retries: 120
volumes:
- ./iotdb-cluster.properties:/iotdb/conf/iotdb-cluster.properties
- ../logback-container.xml:/iotdb/conf/logback.xml
scale: 5
networks:
iotdb:
driver: bridge
#
# 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.
internal_meta_port=9003
internal_data_port=40010
seed_nodes=5nodes_iotdb-server_1:9003,5nodes_iotdb-server_2:9003,5nodes_iotdb-server_3:9003,5nodes_iotdb-server_4:9003,5nodes_iotdb-server_5:9003
default_replica_num=3
consistency_level=mid
connection_timeout_ms=20000
write_operation_timeout_ms=30000
read_operation_timeout_ms=30000
catch_up_timeout_ms=300000
use_batch_in_catch_up=true
min_num_of_logs_in_mem=1000
max_num_of_logs_in_mem=2000
log_deletion_check_interval_second=-1
is_use_async_server=false
is_use_async_applier=true
is_enable_raft_log_persistence=true
open_server_rpc_port=false
#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
data_dirs=target/data
wal_dir=target/wal
index_root_dir=target/index
udf_root_dir=target/ext
tracing_dir=target/data/tracing
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<configuration debug="false">
<property name="LOG_PATH" value="target/logs"/>
<!-- prevent logback from outputting its own status at the start of every log -->
<statusListener class="ch.qos.logback.core.status.NopStatusListener"/>
<appender class="ch.qos.logback.core.ConsoleAppender" name="stdout">
<Target>System.out</Target>
<encoder>
<pattern>%-5p [%d] [%thread] %C{25}:%L - %m %n</pattern>
<charset>utf-8</charset>
</encoder>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>DEBUG</level>
</filter>
</appender>
<root level="INFO">
<appender-ref ref="stdout"/>
</root>
</configuration>
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<configuration debug="false">
<property name="LOG_PATH" value="target/logs"/>
<!-- prevent logback from outputting its own status at the start of every log -->
<statusListener class="ch.qos.logback.core.status.NopStatusListener"/>
<appender class="ch.qos.logback.core.ConsoleAppender" name="stdout">
<Target>System.out</Target>
<encoder>
<pattern>%-5p [%d] [%thread] %C{25}:%L - %m %n</pattern>
<charset>utf-8</charset>
</encoder>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>DEBUG</level>
</filter>
</appender>
<appender class="ch.qos.logback.core.ConsoleAppender" name="stdout">
<Target>System.out</Target>
<encoder>
<pattern>[%thread] %m %n</pattern>
<charset>utf-8</charset>
</encoder>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>DEBUG</level>
</filter>
</appender>
<logger name="org.testcontainers.containers.output.Slf4jLogConsumer" level="INFO">
<appender-ref ref="Container"/>
</logger>
<root level="INFO">
<appender-ref ref="stdout"/>
</root>
</configuration>
......@@ -115,7 +115,6 @@
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册