You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by pa...@apache.org on 2020/10/13 07:49:08 UTC

[shardingsphere] branch master updated: #5301, use MySQL and PostgreSQL for integration test on travis (#7769)

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

panjuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new 6866d74  #5301, use MySQL and PostgreSQL for integration test on travis (#7769)
6866d74 is described below

commit 6866d748f0e5fb5b27dff251caf98e4773e71cef
Author: Zhang Yonglun <zh...@apache.org>
AuthorDate: Tue Oct 13 15:48:43 2020 +0800

    #5301, use MySQL and PostgreSQL for integration test on travis (#7769)
    
    * add mysql env to travis
    
    * add mysql env to travis
    
    * add postgresql env to travis
    
    * add ci profile
---
 .travis.yml                                                | 14 +++++++++++++-
 .../features/test-engine/integration-test-engine.cn.md     |  6 +++---
 .../features/test-engine/integration-test-engine.en.md     |  4 ++--
 .../shardingsphere-test-suite/pom.xml                      | 10 ++++++++--
 .../dbtest/env/IntegrateTestEnvironment.java               | 12 +++++++++++-
 .../integrate/{env.properties => env-jdbc-ci.properties}   |  6 +++---
 .../{env.properties => env-jdbc-local.properties}          |  0
 7 files changed, 40 insertions(+), 12 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index ab511a2..d121a81 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,7 +1,12 @@
 language: java
+
 jdk:
   - openjdk8
 
+services:
+  - mysql
+  - postgresql
+
 install: true
 
 cache:
@@ -10,9 +15,16 @@ cache:
 
 before_script:
   - echo "MAVEN_OPTS='-Xmx1024m -XX:MaxMetaspaceSize=256m'" > ~/.mavenrc
+  - wget https://repo.mysql.com//mysql-apt-config_0.8.10-1_all.deb
+  - sudo dpkg -i mysql-apt-config_0.8.10-1_all.deb
+  - sudo apt-get update -q
+  - sudo apt-get install -q -y --allow-unauthenticated -o Dpkg::Options::=--force-confnew mysql-server
+  - sudo systemctl restart mysql
+  - sudo mysql_upgrade
+  - mysql --version
 
 script:
-  - travis_wait 30 ./mvnw --batch-mode --no-transfer-progress clean install cobertura:cobertura -Dmaven.javadoc.skip=true
+  - travis_wait 120 ./mvnw --batch-mode --no-transfer-progress clean install cobertura:cobertura -Dmaven.javadoc.skip=true -Pit-jdbc-ci
 
 after_success:
   - bash <(curl -s https://codecov.io/bash)
diff --git a/docs/document/content/features/test-engine/integration-test-engine.cn.md b/docs/document/content/features/test-engine/integration-test-engine.cn.md
index 764a0e5..31664fc 100644
--- a/docs/document/content/features/test-engine/integration-test-engine.cn.md
+++ b/docs/document/content/features/test-engine/integration-test-engine.cn.md
@@ -13,7 +13,7 @@ Junit 中的 `Parameterized` 会聚合起所有的测试数据,并将测试数
 ### 配置
 
   - 环境类文件
-    - /shardingsphere-test-suite/src/test/resources/integrate/env.properties
+    - /shardingsphere-test-suite/src/test/resources/integrate/env-jdbc-local.properties
     - /shardingsphere-test-suite/src/test/resources/integrate/env/`SQL-TYPE`/dataset.xml
     - /shardingsphere-test-suite/src/test/resources/integrate/env/`SQL-TYPE`/schema.xml
   - 测试用例类文件
@@ -26,7 +26,7 @@ Junit 中的 `Parameterized` 会聚合起所有的测试数据,并将测试数
 
 集成测试需要真实的数据库环境,根据相应的配置文件创建测试环境:
 
-首先,修改配置文件 `/shardingsphere-test-suite/src/test/resources/integrate/env.properties` ,例子如下:
+首先,修改配置文件 `/shardingsphere-test-suite/src/test/resources/integrate/env-jdbc-local.properties` ,例子如下:
 
 ```properties
 # 测试主键,并发,column index等的开关
@@ -90,7 +90,7 @@ oracle.password=jdbc
 
 ### 断言配置
 
-`env.properties` 与 `dataset.xml ` 确定了什么SQL在什么环境执行,下面是断言数据的配置:
+`env-jdbc-local.properties` 与 `dataset.xml ` 确定了什么SQL在什么环境执行,下面是断言数据的配置:
 
 断言的配置,需要两种文件,第一类文件位于 `/shardingsphere-test-suite/src/test/resources/integrate/cases/SQL-TYPE/SQL-TYPE-integrate-test-cases.xml`
 这个文件类似于一个索引,定义了要执行的SQL,参数以及期待的数据的文件位置。这里的 test-case 引用的就是`sharding-sql-test`中 SQL 对应的`sql-case-id`,例子如下:
diff --git a/docs/document/content/features/test-engine/integration-test-engine.en.md b/docs/document/content/features/test-engine/integration-test-engine.en.md
index 63e79ff..b1e3438 100644
--- a/docs/document/content/features/test-engine/integration-test-engine.en.md
+++ b/docs/document/content/features/test-engine/integration-test-engine.en.md
@@ -12,7 +12,7 @@ The `Parameterized` in JUnit will collect all test data, and pass to test method
 ### Configuration
  
   - environment type
-    - /shardingsphere-test-suite/src/test/resources/integrate/env.properties
+    - /shardingsphere-test-suite/src/test/resources/integrate/env-jdbc-local.properties
     - /shardingsphere-test-suite/src/test/resources/integrate/env/`SQL-TYPE`/dataset.xml
     - /shardingsphere-test-suite/src/test/resources/integrate/env/`SQL-TYPE`/schema.xml
   - test case type
@@ -25,7 +25,7 @@ The `Parameterized` in JUnit will collect all test data, and pass to test method
 
 Integration test depends on existed database environment, developer need to setup the configuration file for corresponding database to test: 
 
-Firstly, setup configuration file `/shardingsphere-test-suite/src/test/resources/integrate/env.properties`, for example: 
+Firstly, setup configuration file `/shardingsphere-test-suite/src/test/resources/integrate/env-jdbc-local.properties`, for example: 
 
 ```properties
 # the switch for PK, concurrent, column index testing and so on
diff --git a/shardingsphere-integration-test/shardingsphere-test-suite/pom.xml b/shardingsphere-integration-test/shardingsphere-test-suite/pom.xml
index c3a0942..fa1b583 100644
--- a/shardingsphere-integration-test/shardingsphere-test-suite/pom.xml
+++ b/shardingsphere-integration-test/shardingsphere-test-suite/pom.xml
@@ -72,12 +72,18 @@
     
     <profiles>
         <profile>
-            <id>it-jdbc</id>
+            <id>it-jdbc-local</id>
             <activation>
                 <activeByDefault>true</activeByDefault>
             </activation>
             <properties>
-                <it.mode>jdbc</it.mode>
+                <it.mode>jdbc-local</it.mode>
+            </properties>
+        </profile>
+        <profile>
+            <id>it-jdbc-ci</id>
+            <properties>
+                <it.mode>jdbc-ci</it.mode>
             </properties>
         </profile>
         <profile>
diff --git a/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/dbtest/env/IntegrateTestEnvironment.java b/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/dbtest/env/IntegrateTestEnvironment.java
index d6ed244..5566b89 100644
--- a/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/dbtest/env/IntegrateTestEnvironment.java
+++ b/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/dbtest/env/IntegrateTestEnvironment.java
@@ -52,7 +52,7 @@ public final class IntegrateTestEnvironment {
         activeProfile = loadActiveProfile();
         Properties prop = new Properties();
         try {
-            prop.load(IntegrateTestEnvironment.class.getClassLoader().getResourceAsStream(isProxyEnvironment() ? "integrate/env-proxy.properties" : "integrate/env.properties"));
+            prop.load(IntegrateTestEnvironment.class.getClassLoader().getResourceAsStream(getEnvironmentProperties()));
         } catch (final IOException ex) {
             throw new RuntimeException(ex);
         }
@@ -100,6 +100,16 @@ public final class IntegrateTestEnvironment {
         return prop.getProperty("mode");
     }
     
+    private String getEnvironmentProperties() {
+        if ("jdbc-ci".equals(activeProfile)) {
+            return "integrate/env-jdbc-ci.properties";
+        }
+        if ("proxy".equals(activeProfile)) {
+            return "integrate/env-proxy.properties";
+        }
+        return "integrate/env-jdbc-local.properties";
+    }
+    
     /**
      * Is proxy environment.
      *
diff --git a/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/integrate/env.properties b/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/integrate/env-jdbc-ci.properties
similarity index 94%
copy from shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/integrate/env.properties
copy to shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/integrate/env-jdbc-ci.properties
index 41d5800..84f7ee6 100644
--- a/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/integrate/env.properties
+++ b/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/integrate/env-jdbc-ci.properties
@@ -20,14 +20,14 @@ run.additional.cases=false
 rule.types=db,tbl,dbtbl_with_primary_replica_replication,primary_replica_replication
 
 #databases=H2,MySQL,Oracle,SQLServer,PostgreSQL
-databases=H2
+databases=MySQL,PostgreSQL
 
-mysql.host=db.mysql
+mysql.host=127.0.0.1
 mysql.port=3306
 mysql.username=root
 mysql.password=
 
-postgresql.host=db.psql
+postgresql.host=127.0.0.1
 postgresql.port=5432
 postgresql.username=postgres
 postgresql.password=postgres
diff --git a/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/integrate/env.properties b/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/integrate/env-jdbc-local.properties
similarity index 100%
rename from shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/integrate/env.properties
rename to shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/integrate/env-jdbc-local.properties