diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 6a0e21f21f51e..b668c5e138e19 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -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 diff --git a/cli/pom.xml b/cli/pom.xml index 1d692b94cbafa..166231b544fc2 100644 --- a/cli/pom.xml +++ b/cli/pom.xml @@ -96,7 +96,6 @@ integration-test integration-test - verify diff --git a/cluster/pom.xml b/cluster/pom.xml index bffe9b312bc8f..303a26f0b028e 100644 --- a/cluster/pom.xml +++ b/cluster/pom.xml @@ -202,7 +202,6 @@ integration-test integration-test - verify diff --git a/cluster/src/assembly/resources/conf/iotdb-cluster.properties b/cluster/src/assembly/resources/conf/iotdb-cluster.properties index 62014ca2a9995..5fb14578e3c7d 100644 --- a/cluster/src/assembly/resources/conf/iotdb-cluster.properties +++ b/cluster/src/assembly/resources/conf/iotdb-cluster.properties @@ -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 diff --git a/cluster/src/main/java/org/apache/iotdb/cluster/ClusterMain.java b/cluster/src/main/java/org/apache/iotdb/cluster/ClusterMain.java index f39e9a6f5cdc9..dc3e767bd8ddb 100644 --- a/cluster/src/main/java/org/apache/iotdb/cluster/ClusterMain.java +++ b/cluster/src/main/java/org/apache/iotdb/cluster/ClusterMain.java @@ -157,6 +157,7 @@ private static void startServerCheck() throws StartupException { config.getSeedNodeUrls().size(), quorum); throw new StartupException(metaServer.getMember().getName(), message); } + // assert not duplicated nodes Set seedNodes = new HashSet<>(); for (String url : config.getSeedNodeUrls()) { diff --git a/cluster/src/main/java/org/apache/iotdb/cluster/config/ClusterConfig.java b/cluster/src/main/java/org/apache/iotdb/cluster/config/ClusterConfig.java index 43e2ee5b5cadd..7d3e42a5a0db3 100644 --- a/cluster/src/main/java/org/apache/iotdb/cluster/config/ClusterConfig.java +++ b/cluster/src/main/java/org/apache/iotdb/cluster/config/ClusterConfig.java @@ -21,22 +21,26 @@ 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 seedNodeUrls = - Arrays.asList(String.format("%s:%d", internalIp, internalMetaPort)); + private List 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; } diff --git a/cross-tests/pom.xml b/cross-tests/pom.xml index e377150b1441a..a2cf524b575ad 100644 --- a/cross-tests/pom.xml +++ b/cross-tests/pom.xml @@ -73,7 +73,6 @@ integration-test integration-test - verify diff --git a/docker/src/main/Dockerfile-cluster b/docker/src/main/Dockerfile-cluster new file mode 100644 index 0000000000000..277132b6eab2c --- /dev/null +++ b/docker/src/main/Dockerfile-cluster @@ -0,0 +1,43 @@ +# +# 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"] diff --git a/docker/src/main/Dockerfile b/docker/src/main/Dockerfile-single similarity index 95% rename from docker/src/main/Dockerfile rename to docker/src/main/Dockerfile-single index 402227c64d185..c0e00a9517603 100644 --- a/docker/src/main/Dockerfile +++ b/docker/src/main/Dockerfile-single @@ -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 \ diff --git a/grafana/pom.xml b/grafana/pom.xml index d535c50f7e548..5b4362b66013a 100644 --- a/grafana/pom.xml +++ b/grafana/pom.xml @@ -197,7 +197,6 @@ integration-test integration-test - verify diff --git a/hadoop/pom.xml b/hadoop/pom.xml index 09d3c4db18ef0..c2f7fd5ebdee5 100644 --- a/hadoop/pom.xml +++ b/hadoop/pom.xml @@ -116,7 +116,6 @@ integration-test integration-test - verify diff --git a/jdbc/pom.xml b/jdbc/pom.xml index 63f60b6e8b009..92a0e43e48227 100644 --- a/jdbc/pom.xml +++ b/jdbc/pom.xml @@ -159,7 +159,6 @@ integration-test integration-test - verify diff --git a/pom.xml b/pom.xml index c0df5d4e5d6cd..aed72aecd6af3 100644 --- a/pom.xml +++ b/pom.xml @@ -509,6 +509,12 @@ mockito-all test + + org.testcontainers + testcontainers + 1.15.2 + test + @@ -913,6 +919,10 @@ src/test/**/*IT.java + + + src/test/**/*Test.java + @@ -932,13 +942,27 @@ - - com.diffplug.spotless - spotless-maven-plugin - + + + spotless + + + + . + + + + + + com.diffplug.spotless + spotless-maven-plugin + + + + + + + unixDockerCheck + + + /var/run/docker.sock + + + + testcontainer + + + + WinDockerCheck + + + C:\Program Files\Docker\Docker\resources\bin\docker.exe + + + + testcontainer + + java-11-and-above diff --git a/server/pom.xml b/server/pom.xml index 5b7abbaf49e95..0df99934c5ad6 100644 --- a/server/pom.xml +++ b/server/pom.xml @@ -231,7 +231,6 @@ integration-test integration-test - verify diff --git a/server/src/test/resources/testcontainers.properties b/server/src/test/resources/testcontainers.properties new file mode 100644 index 0000000000000..af6effe66acd0 --- /dev/null +++ b/server/src/test/resources/testcontainers.properties @@ -0,0 +1,17 @@ +#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. + diff --git a/service-rpc/pom.xml b/service-rpc/pom.xml index 73aa2ce0a6152..591a9d5385706 100644 --- a/service-rpc/pom.xml +++ b/service-rpc/pom.xml @@ -114,7 +114,6 @@ integration-test integration-test - verify diff --git a/session/pom.xml b/session/pom.xml index b79f4a376e964..fe0dfc443bd19 100644 --- a/session/pom.xml +++ b/session/pom.xml @@ -54,7 +54,6 @@ integration-test integration-test - verify diff --git a/test/e2e/base/docker-compose.yaml b/test/e2e/base/docker-compose.yaml index d4970d45adbc6..f536ec696620d 100644 --- a/test/e2e/base/docker-compose.yaml +++ b/test/e2e/base/docker-compose.yaml @@ -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: diff --git a/test/e2e/cases/cli/cleanup.sh b/test/e2e/cases/cli/cleanup.sh old mode 100644 new mode 100755 diff --git a/test/e2e/cases/cli/run.sh b/test/e2e/cases/cli/run.sh old mode 100644 new mode 100755 diff --git a/testcontainer/Readme.md b/testcontainer/Readme.md new file mode 100644 index 0000000000000..234c6861b65e7 --- /dev/null +++ b/testcontainer/Readme.md @@ -0,0 +1,66 @@ + + +# 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`. + + diff --git a/testcontainer/pom.xml b/testcontainer/pom.xml new file mode 100644 index 0000000000000..ecd16b7808915 --- /dev/null +++ b/testcontainer/pom.xml @@ -0,0 +1,159 @@ + + + + + org.apache.iotdb + iotdb-parent + 0.13.0-SNAPSHOT + ../pom.xml + + 4.0.0 + testcontainer + + false + docker + build -t apache/iotdb:maven-development -f ${basedir}/../docker/src/main/Dockerfile-single ${basedir}/../. + image rm apache/iotdb:maven-development + build -t apache/iotdb:cluster-maven-development -f ${basedir}/../docker/src/main/Dockerfile-cluster ${basedir}/../. + image rm apache/iotdb:cluster-maven-development + + + + org.apache.iotdb + iotdb-jdbc + ${project.version} + test + + + org.apache.iotdb + iotdb-session + ${project.version} + test + + + org.apache.iotdb + iotdb-cli + ${project.version} + test + + + + + testcontainer + + true + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.6.0 + + + build-docker-image + pre-integration-test + + exec + + + ${docker.test.skip} + ${docker.build.executable} + ${docker.build.single.argument} + + + + build-cluster-docker-image + pre-integration-test + + exec + + + ${docker.test.skip} + ${docker.build.executable} + ${docker.build.cluster.argument} + + + + clean-docker-image + post-integration-test + + exec + + + ${docker.test.skip} + ${docker.build.executable} + ${docker.clean.single.argument} + + + + clean-cluster-docker-image + post-integration-test + + exec + + + ${docker.test.skip} + ${docker.build.executable} + ${docker.clean.cluster.argument} + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 3.2.0 + + + add-test-container-source + generate-test-sources + + add-test-source + + + + ${basedir}/src/test/java + + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + run-integration-tests + integration-test + + integration-test + + + + + + + + + diff --git a/testcontainer/src/test/java/org/apache/iotdb/db/sql/ClusterIT.java b/testcontainer/src/test/java/org/apache/iotdb/db/sql/ClusterIT.java new file mode 100644 index 0000000000000..72dd62bc16b81 --- /dev/null +++ b/testcontainer/src/test/java/org/apache/iotdb/db/sql/ClusterIT.java @@ -0,0 +1,100 @@ +/* + * 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 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)); + } + } +} diff --git a/testcontainer/src/test/java/org/apache/iotdb/db/sql/SingleNodeIT.java b/testcontainer/src/test/java/org/apache/iotdb/db/sql/SingleNodeIT.java new file mode 100644 index 0000000000000..65b32ecc6b46d --- /dev/null +++ b/testcontainer/src/test/java/org/apache/iotdb/db/sql/SingleNodeIT.java @@ -0,0 +1,100 @@ +/* + * 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 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)); + } + } +} diff --git a/testcontainer/src/test/java/org/testcontainers/containers/NoProjectNameDockerComposeContainer.java b/testcontainer/src/test/java/org/testcontainers/containers/NoProjectNameDockerComposeContainer.java new file mode 100644 index 0000000000000..0d1fa76a83372 --- /dev/null +++ b/testcontainer/src/test/java/org/testcontainers/containers/NoProjectNameDockerComposeContainer.java @@ -0,0 +1,38 @@ +/* + * 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(); + } + } +} diff --git a/testcontainer/src/test/resources/1node/docker-compose.yaml b/testcontainer/src/test/resources/1node/docker-compose.yaml new file mode 100644 index 0000000000000..e1308beb22213 --- /dev/null +++ b/testcontainer/src/test/resources/1node/docker-compose.yaml @@ -0,0 +1,44 @@ +# +# 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 diff --git a/testcontainer/src/test/resources/1node/iotdb-cluster.properties b/testcontainer/src/test/resources/1node/iotdb-cluster.properties new file mode 100644 index 0000000000000..2df52cce86cc2 --- /dev/null +++ b/testcontainer/src/test/resources/1node/iotdb-cluster.properties @@ -0,0 +1,35 @@ +# +# 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 diff --git a/testcontainer/src/test/resources/3nodes/docker-compose.yaml b/testcontainer/src/test/resources/3nodes/docker-compose.yaml new file mode 100644 index 0000000000000..9349e1c216231 --- /dev/null +++ b/testcontainer/src/test/resources/3nodes/docker-compose.yaml @@ -0,0 +1,44 @@ +# +# 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 diff --git a/testcontainer/src/test/resources/3nodes/iotdb-cluster.properties b/testcontainer/src/test/resources/3nodes/iotdb-cluster.properties new file mode 100644 index 0000000000000..fe6133d5e0ff8 --- /dev/null +++ b/testcontainer/src/test/resources/3nodes/iotdb-cluster.properties @@ -0,0 +1,35 @@ +# +# 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 diff --git a/testcontainer/src/test/resources/5nodes/docker-compose.yaml b/testcontainer/src/test/resources/5nodes/docker-compose.yaml new file mode 100644 index 0000000000000..5ca9bd1b82cb7 --- /dev/null +++ b/testcontainer/src/test/resources/5nodes/docker-compose.yaml @@ -0,0 +1,43 @@ +# +# 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 diff --git a/testcontainer/src/test/resources/5nodes/iotdb-cluster.properties b/testcontainer/src/test/resources/5nodes/iotdb-cluster.properties new file mode 100644 index 0000000000000..705cca6d1354b --- /dev/null +++ b/testcontainer/src/test/resources/5nodes/iotdb-cluster.properties @@ -0,0 +1,35 @@ +# +# 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 diff --git a/testcontainer/src/test/resources/iotdb-engine.properties b/testcontainer/src/test/resources/iotdb-engine.properties new file mode 100644 index 0000000000000..960aa13b97f53 --- /dev/null +++ b/testcontainer/src/test/resources/iotdb-engine.properties @@ -0,0 +1,24 @@ +#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 diff --git a/testcontainer/src/test/resources/logback-container.xml b/testcontainer/src/test/resources/logback-container.xml new file mode 100644 index 0000000000000..e897fe24cb4df --- /dev/null +++ b/testcontainer/src/test/resources/logback-container.xml @@ -0,0 +1,39 @@ + + + + + + + + System.out + + %-5p [%d] [%thread] %C{25}:%L - %m %n + utf-8 + + + DEBUG + + + + + + diff --git a/testcontainer/src/test/resources/logback.xml b/testcontainer/src/test/resources/logback.xml new file mode 100644 index 0000000000000..098f463a66d3d --- /dev/null +++ b/testcontainer/src/test/resources/logback.xml @@ -0,0 +1,52 @@ + + + + + + + + System.out + + %-5p [%d] [%thread] %C{25}:%L - %m %n + utf-8 + + + DEBUG + + + + System.out + + [%thread] %m %n + utf-8 + + + DEBUG + + + + + + + + + diff --git a/tsfile/pom.xml b/tsfile/pom.xml index d48a9ac13b152..67e3b2456d78a 100644 --- a/tsfile/pom.xml +++ b/tsfile/pom.xml @@ -115,7 +115,6 @@ integration-test integration-test - verify