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

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


The following commit(s) were added to refs/heads/testcontainer by this push:
     new 9aad4b1  done 1.
9aad4b1 is described below

commit 9aad4b14e6d09bf2e96c794f7e1a58b77bf586ce
Author: xiangdong huang <[email protected]>
AuthorDate: Fri Apr 9 14:57:40 2021 +0800

    done 1.
---
 docker/src/main/Dockerfile                         |   2 +-
 pom.xml                                            |  36 +----
 testcontainer/pom.xml                              | 179 +++++++++------------
 .../test/java}/org/apache/iotdb/db/sql/SqlE2E.java |  24 +--
 4 files changed, 97 insertions(+), 144 deletions(-)

diff --git a/docker/src/main/Dockerfile b/docker/src/main/Dockerfile
index 402227c..c0e00a9 100644
--- a/docker/src/main/Dockerfile
+++ b/docker/src/main/Dockerfile
@@ -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/pom.xml b/pom.xml
index 383db7f..eb27a42 100644
--- a/pom.xml
+++ b/pom.xml
@@ -104,7 +104,6 @@
         <module>client-py</module>
         <module>compile-tools</module>
         <module>client-cpp</module>
-        <module>testcontainer</module>
     </modules>
     <!-- Properties Management -->
     <properties>
@@ -156,8 +155,6 @@
         <!-- disable enforcer by default-->
         <enforcer.skip>true</enforcer.skip>
         <spotless.version>2.4.2</spotless.version>
-        <!-- we will concat ${basedir}/src/test/${docker.test.folder} as the 
test source folder-->
-        <docker.test.folder>java</docker.test.folder>
     </properties>
     <!--
         if we claim dependencies in dependencyManagement, then we do not claim
@@ -950,27 +947,6 @@
                 <groupId>com.diffplug.spotless</groupId>
                 <artifactId>spotless-maven-plugin</artifactId>
             </plugin>
-            <!-- If docker exist, we add src/test/container as the test source 
folder.
-        Otherwise, we just add src/test/java as the test source folder, which 
does not take any effect.-->
-            <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/${docker.test.folder}</source>
-                            </sources>
-                        </configuration>
-                    </execution>
-                </executions>
-            </plugin>
         </plugins>
     </build>
     <profiles>
@@ -1036,9 +1012,9 @@
                     <exists>/var/run/docker.sock</exists>
                 </file>
             </activation>
-            <properties>
-                <docker.test.folder>container</docker.test.folder>
-            </properties>
+            <modules>
+                <module>testcontainer</module>
+            </modules>
         </profile>
         <profile>
             <id>WinDockerCheck</id>
@@ -1047,9 +1023,9 @@
                     <exists>C:\Program 
Files\Docker\Docker\resources\bin\docker.exe</exists>
                 </file>
             </activation>
-            <properties>
-                <docker.test.folder>container</docker.test.folder>
-            </properties>
+            <modules>
+                <module>testcontainer</module>
+            </modules>
         </profile>
         <!-- Some APIs were removed in Java 11, so we need to add replacements 
-->
         <profile>
diff --git a/testcontainer/pom.xml b/testcontainer/pom.xml
index acc332c..23088dd 100644
--- a/testcontainer/pom.xml
+++ b/testcontainer/pom.xml
@@ -14,108 +14,79 @@
         <docker.build.argument>build -t apache/iotdb:maven-development -f 
${basedir}/../docker/src/main/Dockerfile ${basedir}/../.</docker.build.argument>
         <docker.clean.argument>image rm 
apache/iotdb:maven-development</docker.clean.argument>
     </properties>
-    <!-- If docker exist, we add src/test/container as the test source folder.
-            Otherwise, we just add src/test/java as the test source folder, 
which does not take any effect.-->
-    <profiles>
-        <profile>
-            <id>dockerTest</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.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.argument}</commandlineArgs>
-                                </configuration>
-                            </execution>
-                        </executions>
-                    </plugin>
-                    <!--                    <plugin>-->
-                    <!--                        
<groupId>io.fabric8</groupId>-->
-                    <!--                        
<artifactId>docker-maven-plugin</artifactId>-->
-                    <!--                        <version>0.35.0</version>-->
-                    <!--                        <configuration>-->
-                    <!--                            <images>-->
-                    <!--                                <image>-->
-                    <!--                                    &lt;!&ndash;image 
name&ndash;&gt;-->
-                    <!--                                    
<name>apache/iotdb:maven-development</name>-->
-                    <!--                                    &lt;!&ndash;alias 
is for naming the container and find the container in 
docker-compose.yml&ndash;&gt;-->
-                    <!--                                    
<alias>iotdb-server</alias>-->
-                    <!--                                    <build>-->
-                    <!--                                        
<dockerFile>${project.basedir}/../docker/src/main/Dockerfile</dockerFile>-->
-                    <!--                                        
<contextDir>${project.basedir}/..</contextDir>-->
-                    <!--                                        <assembly>-->
-                    <!--                                            
<descriptorRef>rootWar</descriptorRef>-->
-                    <!--                                        </assembly>-->
-                    <!--                                    </build>-->
-                    <!--                                    
&lt;!&ndash;docker-compose file&ndash;&gt;-->
-                    <!--                                    &lt;!&ndash;       
                             <external>&ndash;&gt;-->
-                    <!--                                    &lt;!&ndash;       
                                 <type>compose</type>&ndash;&gt;-->
-                    <!--                                    &lt;!&ndash;       
                                 
<basedir>../docker/src/main</basedir>&ndash;&gt;-->
-                    <!--                                    &lt;!&ndash;       
                                 
<composeFile>docker-compose.yaml</composeFile>&ndash;&gt;-->
-                    <!--                                    &lt;!&ndash;       
                             </external>&ndash;&gt;-->
-                    <!--                                    &lt;!&ndash;run 
the container&ndash;&gt;-->
-                    <!--                                    <run>-->
-                    <!--                                        
&lt;!&ndash;using alias as the container name; if not set, then will use random 
string as name&ndash;&gt;-->
-                    <!--                                        
<namingStrategy>alias</namingStrategy>-->
-                    <!--                                    </run>-->
-                    <!--                                </image>-->
-                    <!--                            </images>-->
-                    <!--                        </configuration>-->
-                    <!--                        <executions>-->
-                    <!--                            <execution>-->
-                    <!--                                
<id>build-docker-for-test</id>-->
-                    <!--                                
<phase>pre-integration-test</phase>-->
-                    <!--                                <goals>-->
-                    <!--                                    
<goal>build</goal>-->
-                    <!--                                </goals>-->
-                    <!--                            </execution>-->
-                    <!--                            <execution>-->
-                    <!--                                
<id>remove-docker-for-test</id>-->
-                    <!--                                
<phase>post-integration-test</phase>-->
-                    <!--                                <goals>-->
-                    <!--                                    
<goal>remove</goal>-->
-                    <!--                                </goals>-->
-                    <!--                            </execution>-->
-                    <!--                        </executions>-->
-                    <!--                        <dependencies>-->
-                    <!--                            &lt;!&ndash;The plugin 
depends on this plugin&ndash;&gt;-->
-                    <!--                            <dependency>-->
-                    <!--                                
<groupId>commons-codec</groupId>-->
-                    <!--                                
<artifactId>commons-codec</artifactId>-->
-                    <!--                                
<version>1.11</version>-->
-                    <!--                            </dependency>-->
-                    <!--                        </dependencies>-->
-                    <!--                    </plugin>-->
-                    <!-- after integration test, we remove the docker image-->
-                </plugins>
-            </build>
-        </profile>
-    </profiles>
+    <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>
+    <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.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.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>
+        </plugins>
+    </build>
 </project>
diff --git a/server/src/test/container/org/apache/iotdb/db/sql/SqlE2E.java 
b/testcontainer/src/test/java/org/apache/iotdb/db/sql/SqlE2E.java
similarity index 78%
rename from server/src/test/container/org/apache/iotdb/db/sql/SqlE2E.java
rename to testcontainer/src/test/java/org/apache/iotdb/db/sql/SqlE2E.java
index c1a16ac..25cefea 100644
--- a/server/src/test/container/org/apache/iotdb/db/sql/SqlE2E.java
+++ b/testcontainer/src/test/java/org/apache/iotdb/db/sql/SqlE2E.java
@@ -19,14 +19,16 @@
 package org.apache.iotdb.db.sql;
 
 import org.apache.iotdb.jdbc.Config;
+
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.testcontainers.containers.GenericContainer;
-import org.testcontainers.images.builder.ImageFromDockerfile;
+import org.testcontainers.containers.wait.strategy.Wait;
+import org.testcontainers.images.PullPolicy;
+import org.testcontainers.utility.DockerImageName;
 
-import java.io.File;
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.SQLException;
@@ -38,17 +40,21 @@ public class SqlE2E {
 
   @Rule
   public GenericContainer dslContainer =
-      new GenericContainer(
-          new ImageFromDockerfile()
-              .withDockerfile(
-                  new File("../distribution/target/DockerfileForTestContainer")
-                      .getAbsoluteFile()
-                      .toPath()));
+      new 
GenericContainer(DockerImageName.parse("apache/iotdb:maven-development"))
+          .withImagePullPolicy(PullPolicy.defaultPolicy())
+          .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:6667/", 
"root", "root");
+    connection = DriverManager.getConnection("jdbc:iotdb://127.0.0.1:" + 
rpcPort, "root", "root");
     statement = connection.createStatement();
   }
 

Reply via email to