You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by hx...@apache.org on 2021/05/06 06:39:30 UTC

[iotdb] branch test_container updated: add case for one node cluster

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

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


The following commit(s) were added to refs/heads/test_container by this push:
     new 205ef78  add case for one node cluster
205ef78 is described below

commit 205ef7805506094f6b135ddd536713ae20877a74
Author: xiangdong huang <sa...@gmail.com>
AuthorDate: Thu May 6 14:38:54 2021 +0800

    add case for one node cluster
---
 .../iotdb/db/sql/node1/OneNodeClusterIT.java       | 54 ++++++++++++++++++++++
 1 file changed, 54 insertions(+)

diff --git a/testcontainer/src/test/java/org/apache/iotdb/db/sql/node1/OneNodeClusterIT.java b/testcontainer/src/test/java/org/apache/iotdb/db/sql/node1/OneNodeClusterIT.java
new file mode 100644
index 0000000..daa7161
--- /dev/null
+++ b/testcontainer/src/test/java/org/apache/iotdb/db/sql/node1/OneNodeClusterIT.java
@@ -0,0 +1,54 @@
+/*
+ * 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.node1;
+
+import org.apache.iotdb.db.sql.ClusterIT;
+
+import org.junit.Rule;
+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;
+
+// a cluster with only one node.
+// in this case, the read and write connection must be on the same node,
+// the data is also
+public class OneNodeClusterIT extends ClusterIT {
+  private static Logger node1Logger = LoggerFactory.getLogger("iotdb-server_1");
+
+  // 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(
+              "1node", new File("src/test/resources/1node/docker-compose.yaml"))
+          .withExposedService("iotdb-server_1", 6667, Wait.forListeningPort())
+          .withLogConsumer("iotdb-server_1", new Slf4jLogConsumer(node1Logger))
+          .withLocalCompose(true);
+
+  @Override
+  protected DockerComposeContainer getContainer() {
+    return environment;
+  }
+}