You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2021/03/24 10:01:13 UTC
[shardingsphere] branch master updated: refactor: it engine (#9725)
This is an automated email from the ASF dual-hosted git repository.
zhangliang 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 70176a6 refactor: it engine (#9725)
70176a6 is described below
commit 70176a68c9d7d55a47f4dde8391fdbb0d52cb231
Author: Daming <zt...@foxmail.com>
AuthorDate: Wed Mar 24 18:00:29 2021 +0800
refactor: it engine (#9725)
* move packages
* refactor dockerfile
* Refactor IT engine
* fix checkstyle and update it.yaml
* optimize
* fix
* fix ci/it script
* fix null pointer
* fix checkstyle
* fix nullpointer
* code polish
* revert
* make adapter=jdbc available
* fix
* fix
* following reviews
* fix ci
* Compatible with ci
* support parallel
* fix
* fix
* fix
* fix
* disable fail-fast
* polish
* fix health-chek
* fix health-chek
* fix health-chek
* code polish
* code polish
* code polish
* rollback
* fix missing case
* fix
* fix skip dockerfile build
* revert removed profile
* remove dead code
Co-authored-by: root <ro...@daming.sgp>
---
.github/workflows/it.yml | 246 +----------------
shardingsphere-test/pom.xml | 15 +
.../Dockerfile | 15 +-
.../pom.xml | 84 +++++-
.../src/test/assembly/bin/start.sh | 0
.../src/test/assembly/bin/stop.sh | 0
.../assembly/shardingsphere-proxy-assembly.xml | 8 +
.../test/integration/common/ExecutionMode.java} | 9 +-
.../test/integration/common}/SQLExecuteType.java | 2 +-
.../env/dataset/DataSetEnvironmentManager.java | 4 +-
.../junit/annotation/BeforeAllCases.java} | 21 +-
.../junit/annotation/ContainerInitializer.java} | 21 +-
.../junit/annotation/ContainerType.java} | 13 +-
.../integration/junit/annotation/OnContainer.java} | 36 ++-
.../junit/annotation/ParameterFilter.java} | 33 ++-
.../junit/annotation/ShardingSphereITInject.java} | 20 +-
.../annotation/ShardingSphereITStorageType.java} | 32 +--
.../junit/annotation/TestCaseSpec.java} | 37 ++-
.../integration/junit/annotation/XmlResource.java} | 31 ++-
.../junit/compose/ContainerCompose.java | 233 ++++++++++++++++
.../junit/compose/NotSupportedException.java} | 9 +-
.../integration/junit/container/H2Container.java | 75 +++++
.../junit/container/MySQLContainer.java | 71 +++++
.../junit/container/NativeStorageContainer.java} | 31 ++-
.../junit/container/PostgreSQLContainer.java | 56 ++++
.../container/ShardingSphereAdapterContainer.java | 55 ++++
.../junit/container/ShardingSphereContainer.java | 166 ++++++++++++
.../container/ShardingSphereJDBCContainer.java | 84 ++++++
.../container/ShardingSphereProxyContainer.java | 121 +++++++++
.../container/ShardingSphereStorageContainer.java | 124 +++++++++
.../integration/junit/logging/ContainerLogs.java | 61 +++++
.../junit}/param/ParameterizedArrayFactory.java | 20 +-
.../integration/junit}/param/RunnerParameters.java | 13 +-
.../junit/param/TestCaseParameters.java} | 35 ++-
.../param/model/AssertionParameterizedArray.java | 4 +-
.../junit}/param/model/CaseParameterizedArray.java | 2 +-
.../junit}/param/model/ParameterizedArray.java | 2 +-
.../junit/processor/AuthenticationProcessor.java | 49 ++++
.../junit/processor/DatabaseProcessor.java} | 36 +--
.../integration/junit/processor/Processor.java} | 18 +-
.../junit/runner/ShardingSphereCISubRunner.java | 118 ++++++++
.../junit/runner/ShardingSphereITSubRunner.java | 115 ++++++++
.../junit/runner/ShardingSphereRunner.java | 301 +++++++++++++++++++++
.../junit/runner/TestCaseBeanContext.java | 113 ++++++++
.../junit/runner/TestCaseDescription.java | 84 ++++++
.../runner}/parallel/ParallelRunnerExecutor.java | 4 +-
.../parallel/ParallelRunnerExecutorFactory.java | 8 +-
.../runner}/parallel/ParallelRunnerScheduler.java | 8 +-
.../runner}/parallel/annotaion/ParallelLevel.java | 2 +-
.../annotaion/ParallelRuntimeStrategy.java | 2 +-
.../parallel/impl/CaseParallelRunnerExecutor.java | 6 +-
.../impl/ScenarioParallelRunnerExecutor.java | 6 +-
.../shardingsphere-integration-test-suite/pom.xml | 212 +--------------
.../test/integration/engine/it/BaseIT.java | 113 --------
.../test/integration/engine/it/BaseITCase.java | 131 +++++++++
.../engine/it/{BatchIT.java => BatchITCase.java} | 36 +--
.../test/integration/engine/it/SingleIT.java | 70 -----
.../test/integration/engine/it/SingleITCase.java | 43 +++
.../test/integration/engine/it/dal/BaseDALIT.java | 14 +-
.../integration/engine/it/dal/GeneralDALIT.java | 47 ++--
.../test/integration/engine/it/dcl/BaseDCLIT.java | 72 +----
.../integration/engine/it/dcl/GeneralDCLIT.java | 35 +--
.../test/integration/engine/it/ddl/BaseDDLIT.java | 55 ++--
.../integration/engine/it/ddl/GeneralDDLIT.java | 37 +--
.../integration/engine/it/dml/AdditionalDMLIT.java | 86 +++---
.../test/integration/engine/it/dml/BaseDMLIT.java | 31 +--
.../test/integration/engine/it/dml/BatchDMLIT.java | 71 ++---
.../integration/engine/it/dml/GeneralDMLIT.java | 57 ++--
.../integration/engine/it/dql/AdditionalDQLIT.java | 57 ++--
.../test/integration/engine/it/dql/BaseDQLIT.java | 47 ++--
.../integration/engine/it/dql/GeneralDQLIT.java | 43 +--
.../integration/engine/junit/ITParameterized.java | 38 ---
.../config-dbtbl-with-read-write-splitting.yaml | 40 +--
...btbl-with-read-write-splitting-and-encrypt.yaml | 40 +--
.../docker/encrypt/proxy/conf/config-encrypt.yaml | 2 +-
.../proxy/conf/config-read-write-splitting.yaml | 6 +-
.../docker/tbl/proxy/conf/config-tbl.yaml | 2 +-
.../src/test/resources/logback-test.xml | 7 +-
78 files changed, 2673 insertions(+), 1378 deletions(-)
diff --git a/.github/workflows/it.yml b/.github/workflows/it.yml
index af439ae..f8a8ca8 100644
--- a/.github/workflows/it.yml
+++ b/.github/workflows/it.yml
@@ -24,9 +24,16 @@ on:
branches: [ master ]
jobs:
- mysql-proxy-db:
- name: MySQL-Proxy with DB
+ MySQL:
+ name: DB
runs-on: ubuntu-latest
+ timeout-minutes: 60
+ strategy:
+ fail-fast: false
+ matrix:
+ env: [ docker ]
+ adapter: [ proxy, jdbc ]
+ scenario: [ db,tbl,dbtbl_with_read_write_splitting,encrypt,dbtbl_with_read_write_splitting_and_encrypt, read_write_splitting]
steps:
- name: Cache Maven Repos
uses: actions/cache@v2
@@ -41,240 +48,9 @@ jobs:
with:
java-version: 8
- name: Build Project
- run: ./mvnw -B clean install -Dmaven.javadoc.skip=true -Drat.skip=true -Djacoco.skip=true -DskipITs -DskipTests
- - name: Run Integration Test
- run: ./mvnw -B clean install -f shardingsphere-test/shardingsphere-integration-test/pom.xml -Pit.env.docker -Dit.adapters=proxy -Dit.scenarios=db -Dit.databases=MySQL
-
- mysql-proxy-tbl:
- name: MySQL-Proxy with TBL
- runs-on: ubuntu-latest
- steps:
- - name: Cache Maven Repos
- uses: actions/cache@v2
- with:
- path: ~/.m2/repository
- key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
- restore-keys: |
- ${{ runner.os }}-maven-
- - uses: actions/checkout@v2
- - name: Set up JDK 8
- uses: actions/setup-java@v1
- with:
- java-version: 8
- - name: Build Project
- run: ./mvnw -B clean install -Dmaven.javadoc.skip=true -Drat.skip=true -Djacoco.skip=true -DskipITs -DskipTests
- - name: Run Integration Test
- run: ./mvnw -B clean install -f shardingsphere-test/shardingsphere-integration-test/pom.xml -Pit.env.docker -Dit.adapters=proxy -Dit.scenarios=tbl -Dit.databases=MySQL
-
- mysql-proxy-read-write-splitting:
- name: MySQL-Proxy with READ-WRITE-SPLITTING
- runs-on: ubuntu-latest
- steps:
- - name: Cache Maven Repos
- uses: actions/cache@v2
- with:
- path: ~/.m2/repository
- key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
- restore-keys: |
- ${{ runner.os }}-maven-
- - uses: actions/checkout@v2
- - name: Set up JDK 8
- uses: actions/setup-java@v1
- with:
- java-version: 8
- - name: Build Project
- run: ./mvnw -B clean install -Dmaven.javadoc.skip=true -Drat.skip=true -Djacoco.skip=true -DskipITs -DskipTests
- - name: Run Integration Test
- run: ./mvnw -B clean install -f shardingsphere-test/shardingsphere-integration-test/pom.xml -Pit.env.docker -Dit.adapters=proxy -Dit.scenarios=read_write_splitting -Dit.databases=MySQL
-
- mysql-proxy-dbtbl-with-proxy-read-write-splitting:
- name: MySQL-Proxy with DBTBL-WITH-READ-WRITE-SPLITTING
- runs-on: ubuntu-latest
- steps:
- - name: Cache Maven Repos
- uses: actions/cache@v2
- with:
- path: ~/.m2/repository
- key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
- restore-keys: |
- ${{ runner.os }}-maven-
- - uses: actions/checkout@v2
- - name: Set up JDK 8
- uses: actions/setup-java@v1
- with:
- java-version: 8
- - name: Build Project
- run: ./mvnw -B clean install -Dmaven.javadoc.skip=true -Drat.skip=true -Djacoco.skip=true -DskipITs -DskipTests
- - name: Run Integration Test
- run: ./mvnw -B clean install -f shardingsphere-test/shardingsphere-integration-test/pom.xml -Pit.env.docker -Dit.adapters=proxy -Dit.scenarios=dbtbl_with_read_write_splitting -Dit.databases=MySQL
-
- mysql-proxy-encrypt:
- name: MySQL-Proxy with ENCRYPT
- runs-on: ubuntu-latest
- steps:
- - name: Cache Maven Repos
- uses: actions/cache@v2
- with:
- path: ~/.m2/repository
- key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
- restore-keys: |
- ${{ runner.os }}-maven-
- - uses: actions/checkout@v2
- - name: Set up JDK 8
- uses: actions/setup-java@v1
- with:
- java-version: 8
- - name: Build Project
- run: ./mvnw -B clean install -Dmaven.javadoc.skip=true -Drat.skip=true -Djacoco.skip=true -DskipITs -DskipTests
- - name: Run Integration Test
- run: ./mvnw -B clean install -f shardingsphere-test/shardingsphere-integration-test/pom.xml -Pit.env.docker -Dit.adapters=proxy -Dit.scenarios=encrypt -Dit.databases=MySQL
-
- mysql-proxy-dbtbl-with-read-write-splitting-and-encrypt:
- name: MySQL-Proxy with DBTBL-WITH-READ-WRITE-SPLITTING-AND-ENCRYPT
- runs-on: ubuntu-latest
- steps:
- - name: Cache Maven Repos
- uses: actions/cache@v2
- with:
- path: ~/.m2/repository
- key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
- restore-keys: |
- ${{ runner.os }}-maven-
- - uses: actions/checkout@v2
- - name: Set up JDK 8
- uses: actions/setup-java@v1
- with:
- java-version: 8
- - name: Build Project
- run: ./mvnw -B clean install -Dmaven.javadoc.skip=true -Drat.skip=true -Djacoco.skip=true -DskipITs -DskipTests
- - name: Run Integration Test
- run: ./mvnw -B clean install -f shardingsphere-test/shardingsphere-integration-test/pom.xml -Pit.env.docker -Dit.adapters=proxy -Dit.scenarios=dbtbl_with_read_write_splitting_and_encrypt -Dit.databases=MySQL
-
- mysql-jdbc-db:
- name: MySQL-JDBC with DB
- runs-on: ubuntu-latest
- steps:
- - name: Cache Maven Repos
- uses: actions/cache@v2
- with:
- path: ~/.m2/repository
- key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
- restore-keys: |
- ${{ runner.os }}-maven-
- - uses: actions/checkout@v2
- - name: Set up JDK 8
- uses: actions/setup-java@v1
- with:
- java-version: 8
- - name: Build Project
- run: ./mvnw -B clean install -Dmaven.javadoc.skip=true -Drat.skip=true -Djacoco.skip=true -DskipITs -DskipTests
- - name: Run Integration Test
- run: ./mvnw -B clean install -f shardingsphere-test/shardingsphere-integration-test/pom.xml -Pit.env.docker -Dit.adapters=jdbc -Dit.scenarios=db -Dit.databases=MySQL
-
- mysql-jdbc-tbl:
- name: MySQL-JDBC with TBL
- runs-on: ubuntu-latest
- steps:
- - name: Cache Maven Repos
- uses: actions/cache@v2
- with:
- path: ~/.m2/repository
- key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
- restore-keys: |
- ${{ runner.os }}-maven-
- - uses: actions/checkout@v2
- - name: Set up JDK 8
- uses: actions/setup-java@v1
- with:
- java-version: 8
- - name: Build Project
- run: ./mvnw -B clean install -Dmaven.javadoc.skip=true -Drat.skip=true -Djacoco.skip=true -DskipITs -DskipTests
- - name: Run Integration Test
- run: ./mvnw -B clean install -f shardingsphere-test/shardingsphere-integration-test/pom.xml -Pit.env.docker -Dit.adapters=jdbc -Dit.scenarios=tbl -Dit.databases=MySQL
-
- mysql-jdbc-read-write-splitting:
- name: MySQL-JDBC with READ-WRITE-SPLITTING
- runs-on: ubuntu-latest
- steps:
- - name: Cache Maven Repos
- uses: actions/cache@v2
- with:
- path: ~/.m2/repository
- key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
- restore-keys: |
- ${{ runner.os }}-maven-
- - uses: actions/checkout@v2
- - name: Set up JDK 8
- uses: actions/setup-java@v1
- with:
- java-version: 8
- - name: Build Project
- run: ./mvnw -B clean install -Dmaven.javadoc.skip=true -Drat.skip=true -Djacoco.skip=true -DskipITs -DskipTests
- - name: Run Integration Test
- run: ./mvnw -B clean install -f shardingsphere-test/shardingsphere-integration-test/pom.xml -Pit.env.docker -Dit.adapters=jdbc -Dit.scenarios=read_write_splitting -Dit.databases=MySQL
-
- mysql-jdbc-dbtbl-with-proxy-read-write-splitting:
- name: MySQL-JDBC with DBTBL-WITH-READ-WRITE-SPLITTING
- runs-on: ubuntu-latest
- steps:
- - name: Cache Maven Repos
- uses: actions/cache@v2
- with:
- path: ~/.m2/repository
- key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
- restore-keys: |
- ${{ runner.os }}-maven-
- - uses: actions/checkout@v2
- - name: Set up JDK 8
- uses: actions/setup-java@v1
- with:
- java-version: 8
- - name: Build Project
- run: ./mvnw -B clean install -Dmaven.javadoc.skip=true -Drat.skip=true -Djacoco.skip=true -DskipITs -DskipTests
- - name: Run Integration Test
- run: ./mvnw -B clean install -f shardingsphere-test/shardingsphere-integration-test/pom.xml -Pit.env.docker -Dit.adapters=jdbc -Dit.scenarios=dbtbl_with_read_write_splitting -Dit.databases=MySQL
-
- mysql-jdbc-encrypt:
- name: MySQL-JDBC with ENCRYPT
- runs-on: ubuntu-latest
- steps:
- - name: Cache Maven Repos
- uses: actions/cache@v2
- with:
- path: ~/.m2/repository
- key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
- restore-keys: |
- ${{ runner.os }}-maven-
- - uses: actions/checkout@v2
- - name: Set up JDK 8
- uses: actions/setup-java@v1
- with:
- java-version: 8
- - name: Build Project
- run: ./mvnw -B clean install -Dmaven.javadoc.skip=true -Drat.skip=true -Djacoco.skip=true -DskipITs -DskipTests
- - name: Run Integration Test
- run: ./mvnw -B clean install -f shardingsphere-test/shardingsphere-integration-test/pom.xml -Pit.env.docker -Dit.adapters=jdbc -Dit.scenarios=encrypt -Dit.databases=MySQL
-
- mysql-jdbc-dbtbl-with-read-write-splitting-and-encrypt:
- name: MySQL-JDBC with DBTBL-WITH--READ-WRITE-SPLITTING-AND-ENCRYPT
- runs-on: ubuntu-latest
- steps:
- - name: Cache Maven Repos
- uses: actions/cache@v2
- with:
- path: ~/.m2/repository
- key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
- restore-keys: |
- ${{ runner.os }}-maven-
- - uses: actions/checkout@v2
- - name: Set up JDK 8
- uses: actions/setup-java@v1
- with:
- java-version: 8
- - name: Build Project
- run: ./mvnw -B clean install -Dmaven.javadoc.skip=true -Drat.skip=true -Djacoco.skip=true -DskipITs -DskipTests
+ run: ./mvnw -B clean install -Pit.env.docker -DskipTests -Dmaven.javadoc.skip=true -Drat.skip=true -Djacoco.skip=true -am -pl shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite
- name: Run Integration Test
- run: ./mvnw -B clean install -f shardingsphere-test/shardingsphere-integration-test/pom.xml -Pit.env.docker -Dit.adapters=jdbc -Dit.scenarios=dbtbl_with_read_write_splitting_and_encrypt -Dit.databases=MySQL
+ run: ./mvnw -B -Pit.env.docker -Dmaven.javadoc.skip=true -Drat.skip=true -Djacoco.skip=true -f shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/pom.xml -Dit.adapter=${{ matrix.adapter }} -Dit.database=MySQL -Dit.scenario=${{ matrix.scenario }} verify
mysql-proxy-agent-metrics:
name: MySQL-Proxy with Agent Metrics
diff --git a/shardingsphere-test/pom.xml b/shardingsphere-test/pom.xml
index 645418b..4679ab1 100644
--- a/shardingsphere-test/pom.xml
+++ b/shardingsphere-test/pom.xml
@@ -34,4 +34,19 @@
<module>shardingsphere-integration-test</module>
<module>shardingsphere-integration-agent-test</module>
</modules>
+
+ <properties>
+ <testcontainers.version>1.15.2</testcontainers.version>
+ </properties>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.testcontainers</groupId>
+ <artifactId>testcontainers</artifactId>
+ <version>${testcontainers.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
</project>
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/Dockerfile b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/Dockerfile
similarity index 73%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/Dockerfile
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/Dockerfile
index d7a763a..6b06943 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/Dockerfile
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/Dockerfile
@@ -18,10 +18,17 @@
FROM openjdk:8-jdk-alpine
ARG APP_NAME
-ENV WAIT_VERSION 2.7.2
ADD target/${APP_NAME}.tar.gz /opt
-ADD https://github.com/ufoscout/docker-compose-wait/releases/download/$WAIT_VERSION/wait /wait
-RUN chmod +x /wait
RUN mv /opt/${APP_NAME} /opt/shardingsphere-proxy
-ENTRYPOINT /wait && /opt/shardingsphere-proxy/bin/start.sh && tail -f /opt/shardingsphere-proxy/logs/stdout.log
+
+EXPOSE 3307
+EXPOSE 3308
+
+WORKDIR /opt/shardingsphere-proxy
+
+RUN cat bin/start.sh | tr -d '\r' > _start.sh && mv _start.sh bin/start.sh
+RUN cat bin/stop.sh | tr -d '\r' > _stop.sh && mv _stop.sh bin/stop.sh
+RUN chmod +x -R ./bin
+
+CMD /opt/shardingsphere-proxy/bin/start.sh && tail -f /opt/shardingsphere-proxy/logs/stdout.log
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/pom.xml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/pom.xml
index 788d3a7..637765a 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/pom.xml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/pom.xml
@@ -28,21 +28,43 @@
<artifactId>shardingsphere-integration-test-fixture</artifactId>
<name>${project.artifactId}</name>
+ <properties>
+ <dockerfile.skip.build>true</dockerfile.skip.build>
+ </properties>
+
<dependencies>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-agent-bootstrap</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-proxy-bootstrap</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-test-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-jdbc-core</artifactId>
<version>${project.version}</version>
- <scope>test</scope>
</dependency>
<dependency>
- <groupId>org.postgresql</groupId>
- <artifactId>postgresql</artifactId>
+ <groupId>org.testcontainers</groupId>
+ <artifactId>testcontainers</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
- <groupId>com.microsoft.sqlserver</groupId>
- <artifactId>mssql-jdbc</artifactId>
+ <groupId>org.postgresql</groupId>
+ <artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
@@ -50,7 +72,6 @@
<artifactId>logback-classic</artifactId>
<scope>runtime</scope>
</dependency>
-
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
@@ -71,6 +92,57 @@
</dependency>
</dependencies>
+ <profiles>
+ <profile>
+ <id>it.env.docker</id>
+ <properties>
+ <it.env>DOCKER</it.env>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <appendAssemblyId>false</appendAssemblyId>
+ <descriptors>
+ <descriptor>src/test/assembly/shardingsphere-proxy-assembly.xml</descriptor>
+ </descriptors>
+ </configuration>
+ <executions>
+ <execution>
+ <id>assembly</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>com.spotify</groupId>
+ <artifactId>dockerfile-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>shardingsphere-proxy-bin</id>
+ <goals>
+ <goal>build</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <repository>apache/shardingsphere-proxy-test</repository>
+ <tag>${project.version}</tag>
+ <tag>latest</tag>
+ <buildArgs>
+ <APP_NAME>${project.build.finalName}</APP_NAME>
+ </buildArgs>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
<build>
<plugins>
<plugin>
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/assembly/bin/start.sh b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/assembly/bin/start.sh
similarity index 100%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/assembly/bin/start.sh
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/assembly/bin/start.sh
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/assembly/bin/stop.sh b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/assembly/bin/stop.sh
similarity index 100%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/assembly/bin/stop.sh
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/assembly/bin/stop.sh
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/assembly/shardingsphere-proxy-assembly.xml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/assembly/shardingsphere-proxy-assembly.xml
similarity index 86%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/assembly/shardingsphere-proxy-assembly.xml
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/assembly/shardingsphere-proxy-assembly.xml
index 1d6acf0..7cd27a7 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/assembly/shardingsphere-proxy-assembly.xml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/assembly/shardingsphere-proxy-assembly.xml
@@ -31,6 +31,14 @@
</fileSet>
</fileSets>
+ <files>
+ <file>
+ <source>${project.build.directory}/${project.build.finalName}-tests.jar</source>
+ <outputDirectory>lib</outputDirectory>
+ <fileMode>0644</fileMode>
+ </file>
+ </files>
+
<dependencySets>
<dependencySet>
<outputDirectory>lib</outputDirectory>
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/param/SQLExecuteType.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/common/ExecutionMode.java
similarity index 84%
copy from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/param/SQLExecuteType.java
copy to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/common/ExecutionMode.java
index 5aa2f58..5c79ecf 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/param/SQLExecuteType.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/common/ExecutionMode.java
@@ -15,12 +15,9 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.test.integration.engine.param;
+package org.apache.shardingsphere.test.integration.common;
-/**
- * SQL execute type.
- */
-public enum SQLExecuteType {
+public enum ExecutionMode {
- Literal, Placeholder
+ SINGLE, BATCH, ADDITIONAL
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/param/SQLExecuteType.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/common/SQLExecuteType.java
similarity index 93%
copy from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/param/SQLExecuteType.java
copy to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/common/SQLExecuteType.java
index 5aa2f58..6d65593 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/param/SQLExecuteType.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/common/SQLExecuteType.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.test.integration.engine.param;
+package org.apache.shardingsphere.test.integration.common;
/**
* SQL execute type.
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/env/dataset/DataSetEnvironmentManager.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/env/dataset/DataSetEnvironmentManager.java
index a11c1ad..5703685 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/env/dataset/DataSetEnvironmentManager.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/env/dataset/DataSetEnvironmentManager.java
@@ -68,7 +68,7 @@ public final class DataSetEnvironmentManager {
/**
* Fill data.
- *
+ *
* @throws SQLException SQL exception
* @throws ParseException parse exception
*/
@@ -122,7 +122,7 @@ public final class DataSetEnvironmentManager {
/**
* Clear data.
- *
+ *
*/
public void clearData() {
List<Callable<Void>> deleteTasks = new LinkedList<>();
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/annotaion/ParallelRuntimeStrategy.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/annotation/BeforeAllCases.java
similarity index 71%
copy from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/annotaion/ParallelRuntimeStrategy.java
copy to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/annotation/BeforeAllCases.java
index b7e118d..d090c0a 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/annotaion/ParallelRuntimeStrategy.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/annotation/BeforeAllCases.java
@@ -15,28 +15,19 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.test.integration.engine.junit.parallel.annotaion;
+package org.apache.shardingsphere.test.integration.junit.annotation;
-import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
- * Parallel runtime strategy.
+ * It is very like @BeforeClass, but it could be marked at the non-static method.
+ * A method that has been marked by it, would be executed once.
*/
-@Documented
-@Target(ElementType.TYPE)
+@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
-@Inherited
-public @interface ParallelRuntimeStrategy {
-
- /**
- * Get parallel level.
- *
- * @return value parallel level
- */
- ParallelLevel value();
+public @interface BeforeAllCases {
+
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/annotaion/ParallelRuntimeStrategy.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/annotation/ContainerInitializer.java
similarity index 70%
copy from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/annotaion/ParallelRuntimeStrategy.java
copy to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/annotation/ContainerInitializer.java
index b7e118d..c232e21 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/annotaion/ParallelRuntimeStrategy.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/annotation/ContainerInitializer.java
@@ -15,28 +15,15 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.test.integration.engine.junit.parallel.annotaion;
+package org.apache.shardingsphere.test.integration.junit.annotation;
-import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-/**
- * Parallel runtime strategy.
- */
-@Documented
-@Target(ElementType.TYPE)
+@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
-@Inherited
-public @interface ParallelRuntimeStrategy {
-
- /**
- * Get parallel level.
- *
- * @return value parallel level
- */
- ParallelLevel value();
+public @interface ContainerInitializer {
+
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/param/SQLExecuteType.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/annotation/ContainerType.java
similarity index 84%
copy from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/param/SQLExecuteType.java
copy to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/annotation/ContainerType.java
index 5aa2f58..8c2eb12 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/param/SQLExecuteType.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/annotation/ContainerType.java
@@ -15,12 +15,13 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.test.integration.engine.param;
+package org.apache.shardingsphere.test.integration.junit.annotation;
-/**
- * SQL execute type.
- */
-public enum SQLExecuteType {
+public enum ContainerType {
+
+ ADAPTER,
+
+ STORAGE,
- Literal, Placeholder
+ COORDINATOR
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/annotaion/ParallelRuntimeStrategy.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/annotation/OnContainer.java
similarity index 67%
copy from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/annotaion/ParallelRuntimeStrategy.java
copy to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/annotation/OnContainer.java
index b7e118d..916e293 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/annotaion/ParallelRuntimeStrategy.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/annotation/OnContainer.java
@@ -15,28 +15,36 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.test.integration.engine.junit.parallel.annotaion;
+package org.apache.shardingsphere.test.integration.junit.annotation;
-import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-/**
- * Parallel runtime strategy.
- */
-@Documented
-@Target(ElementType.TYPE)
+@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
-@Inherited
-public @interface ParallelRuntimeStrategy {
+public @interface OnContainer {
+
+ /**
+ * Specify the container name.
+ *
+ * @return name
+ */
+ String name();
/**
- * Get parallel level.
- *
- * @return value parallel level
+ * Container hostname. Default by container name.
+ *
+ * @return hostname
*/
- ParallelLevel value();
+ String hostName() default "";
+
+ /**
+ * The type of container.
+ *
+ * @return container type.
+ */
+ ContainerType type() default ContainerType.ADAPTER;
+
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/annotaion/ParallelRuntimeStrategy.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/annotation/ParameterFilter.java
similarity index 67%
copy from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/annotaion/ParallelRuntimeStrategy.java
copy to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/annotation/ParameterFilter.java
index b7e118d..c77f677 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/annotaion/ParallelRuntimeStrategy.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/annotation/ParameterFilter.java
@@ -15,28 +15,35 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.test.integration.engine.junit.parallel.annotaion;
+package org.apache.shardingsphere.test.integration.junit.annotation;
+
+import org.apache.shardingsphere.test.integration.junit.runner.TestCaseBeanContext;
-import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-/**
- * Parallel runtime strategy.
- */
-@Documented
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
-@Inherited
-public @interface ParallelRuntimeStrategy {
+public @interface ParameterFilter {
/**
- * Get parallel level.
- *
- * @return value parallel level
+ * Filter.
+ *
+ * @return filter
*/
- ParallelLevel value();
+ Class<? extends Filter> filter();
+
+ interface Filter {
+
+ /**
+ * Filter.
+ *
+ * @param context test case context
+ * @return false if ignore
+ */
+ boolean filter(TestCaseBeanContext context);
+
+ }
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/annotaion/ParallelRuntimeStrategy.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/annotation/ShardingSphereITInject.java
similarity index 75%
copy from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/annotaion/ParallelRuntimeStrategy.java
copy to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/annotation/ShardingSphereITInject.java
index b7e118d..74dedbd 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/annotaion/ParallelRuntimeStrategy.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/annotation/ShardingSphereITInject.java
@@ -15,28 +15,22 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.test.integration.engine.junit.parallel.annotaion;
+package org.apache.shardingsphere.test.integration.junit.annotation;
+
+import org.apache.shardingsphere.test.integration.junit.compose.ContainerCompose;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
- * Parallel runtime strategy.
+ * The field will be auto injected by {@link ContainerCompose} when it is marked by the annotation.
*/
@Documented
-@Target(ElementType.TYPE)
+@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
-@Inherited
-public @interface ParallelRuntimeStrategy {
-
- /**
- * Get parallel level.
- *
- * @return value parallel level
- */
- ParallelLevel value();
+public @interface ShardingSphereITInject {
+
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/ParallelRunnerExecutor.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/annotation/ShardingSphereITStorageType.java
similarity index 54%
copy from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/ParallelRunnerExecutor.java
copy to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/annotation/ShardingSphereITStorageType.java
index c5d8577..28b9ce8 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/ParallelRunnerExecutor.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/annotation/ShardingSphereITStorageType.java
@@ -15,25 +15,23 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.test.integration.engine.junit.parallel;
+package org.apache.shardingsphere.test.integration.junit.annotation;
-import org.apache.shardingsphere.test.integration.engine.param.model.ParameterizedArray;
+import lombok.Getter;
+import org.apache.shardingsphere.test.integration.junit.container.H2Container;
+import org.apache.shardingsphere.test.integration.junit.container.MySQLContainer;
+import org.apache.shardingsphere.test.integration.junit.container.ShardingSphereStorageContainer;
-/**
- * Parallel runner executor.
- */
-public interface ParallelRunnerExecutor {
+public enum ShardingSphereITStorageType {
+
+ MySQL(MySQLContainer.class),
+
+ H2(H2Container.class);
- /**
- * Execute child statement.
- *
- * @param parameterizedArray parameterized array
- * @param childStatement child statement
- */
- void execute(ParameterizedArray parameterizedArray, Runnable childStatement);
+ @Getter
+ private final Class<? extends ShardingSphereStorageContainer> klass;
- /**
- * Override to implement any behavior that must occur after all children have been scheduled (for example, waiting for them all to finish).
- */
- void finished();
+ ShardingSphereITStorageType(final Class<? extends ShardingSphereStorageContainer> klass) {
+ this.klass = klass;
+ }
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/annotaion/ParallelRuntimeStrategy.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/annotation/TestCaseSpec.java
similarity index 63%
copy from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/annotaion/ParallelRuntimeStrategy.java
copy to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/annotation/TestCaseSpec.java
index b7e118d..03b4095 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/annotaion/ParallelRuntimeStrategy.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/annotation/TestCaseSpec.java
@@ -15,28 +15,39 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.test.integration.engine.junit.parallel.annotaion;
+package org.apache.shardingsphere.test.integration.junit.annotation;
+
+import org.apache.shardingsphere.test.integration.cases.SQLCommandType;
+import org.apache.shardingsphere.test.integration.common.ExecutionMode;
-import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-/**
- * Parallel runtime strategy.
- */
-@Documented
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
-@Inherited
-public @interface ParallelRuntimeStrategy {
+public @interface TestCaseSpec {
+
+ /**
+ * Test case name.
+ *
+ * @return pattern
+ */
+ String name() default "";
/**
- * Get parallel level.
- *
- * @return value parallel level
+ * Sql command type.
+ *
+ * @return type
*/
- ParallelLevel value();
+ SQLCommandType sqlCommandType();
+
+ /**
+ * Case execution mode.
+ *
+ * @return execution mode
+ */
+ ExecutionMode executionMode() default ExecutionMode.SINGLE;
+
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/annotaion/ParallelRuntimeStrategy.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/annotation/XmlResource.java
similarity index 69%
copy from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/annotaion/ParallelRuntimeStrategy.java
copy to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/annotation/XmlResource.java
index b7e118d..d90a98e 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/annotaion/ParallelRuntimeStrategy.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/annotation/XmlResource.java
@@ -14,29 +14,32 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
+package org.apache.shardingsphere.test.integration.junit.annotation;
-package org.apache.shardingsphere.test.integration.engine.junit.parallel.annotaion;
+import org.apache.shardingsphere.test.integration.junit.processor.Processor;
-import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-/**
- * Parallel runtime strategy.
- */
-@Documented
-@Target(ElementType.TYPE)
+@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
-@Inherited
-public @interface ParallelRuntimeStrategy {
+public @interface XmlResource {
/**
- * Get parallel level.
- *
- * @return value parallel level
+ * setting path of resource file.
+ *
+ * @return resource file
*/
- ParallelLevel value();
+ String file();
+
+ /**
+ * Specify the processor of resource.
+ *
+ * @return prceossor
+ */
+ Class<? extends Processor> processor();
+
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/compose/ContainerCompose.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/compose/ContainerCompose.java
new file mode 100644
index 0000000..5b5baea
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/compose/ContainerCompose.java
@@ -0,0 +1,233 @@
+/*
+ * 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.shardingsphere.test.integration.junit.compose;
+
+import com.google.common.base.Strings;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
+import lombok.RequiredArgsConstructor;
+import lombok.Setter;
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shardingsphere.test.integration.junit.annotation.ContainerInitializer;
+import org.apache.shardingsphere.test.integration.junit.annotation.OnContainer;
+import org.apache.shardingsphere.test.integration.junit.annotation.ShardingSphereITInject;
+import org.apache.shardingsphere.test.integration.junit.container.H2Container;
+import org.apache.shardingsphere.test.integration.junit.container.MySQLContainer;
+import org.apache.shardingsphere.test.integration.junit.container.ShardingSphereAdapterContainer;
+import org.apache.shardingsphere.test.integration.junit.container.ShardingSphereContainer;
+import org.apache.shardingsphere.test.integration.junit.container.ShardingSphereJDBCContainer;
+import org.apache.shardingsphere.test.integration.junit.container.ShardingSphereProxyContainer;
+import org.apache.shardingsphere.test.integration.junit.container.ShardingSphereStorageContainer;
+import org.apache.shardingsphere.test.integration.junit.logging.ContainerLogs;
+import org.apache.shardingsphere.test.integration.junit.runner.TestCaseBeanContext;
+import org.apache.shardingsphere.test.integration.junit.runner.TestCaseDescription;
+import org.junit.runners.model.FrameworkField;
+import org.junit.runners.model.TestClass;
+import org.testcontainers.containers.GenericContainer;
+import org.testcontainers.containers.Network;
+import org.testcontainers.lifecycle.Startable;
+
+import java.io.Closeable;
+import java.lang.reflect.Field;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Objects;
+import java.util.concurrent.TimeUnit;
+
+@Slf4j
+@RequiredArgsConstructor
+public class ContainerCompose implements Closeable {
+
+ private final Network network = Network.newNetwork();
+
+ private final String clusterName;
+
+ private final TestClass testClass;
+
+ private final TestCaseDescription description;
+
+ private final TestCaseBeanContext beanContext;
+
+ private ImmutableList<ShardingSphereContainer> containers;
+
+ @Setter
+ private Object instance;
+
+ /**
+ * Create container and then autowired to test-case.
+ */
+ public void createContainers() {
+ ImmutableList.Builder<ShardingSphereContainer> builder = new ImmutableList.Builder<>();
+ testClass.getAnnotatedFields(OnContainer.class).stream()
+ .map(this::createContainer)
+ .filter(Objects::nonNull)
+ .peek(this::inject)
+ .forEach(builder::add);
+ containers = builder.build();
+ }
+
+ @SneakyThrows
+ private ShardingSphereContainer createContainer(final FrameworkField field) {
+ final OnContainer metadata = field.getAnnotation(OnContainer.class);
+ try {
+ final ShardingSphereContainer container = createContainer(metadata);
+ if (Objects.isNull(container)) {
+ log.warn("container {} is not activated.", metadata.name());
+ return null;
+ }
+ container.setDockerName(metadata.name());
+ String hostName = metadata.hostName();
+ if (Strings.isNullOrEmpty(hostName)) {
+ hostName = metadata.name();
+ }
+ container.withNetworkAliases(hostName);
+ container.setNetwork(network);
+ container.withLogConsumer(ContainerLogs.newConsumer(clusterName + "_" + metadata.name()));
+ field.getField().setAccessible(true);
+ field.getField().set(instance, container);
+ beanContext.registerBeanByName(metadata.name(), container);
+ log.info("container {} is activated.", metadata.name());
+ return container;
+ // CHECKSTYLE:OFF
+ } catch (Exception e) {
+ // CHECKSTYLE:ON
+ log.error("Failed to instantiate container {}.", metadata.name(), e);
+ }
+ return null;
+ }
+
+ @SneakyThrows
+ private ShardingSphereContainer createContainer(final OnContainer metadata) {
+ switch (metadata.type()) {
+ case ADAPTER:
+ return createAdapterContainer();
+ case STORAGE:
+ return createStorageContainer();
+ case COORDINATOR:
+ throw new NotSupportedException();
+ default:
+ return null;
+ }
+ }
+
+ private ShardingSphereAdapterContainer createAdapterContainer() {
+ switch (description.getAdapter()) {
+ case "proxy":
+ return new ShardingSphereProxyContainer();
+ case "jdbc":
+ return new ShardingSphereJDBCContainer();
+ default:
+ throw new RuntimeException("Adapter[" + description.getAdapter() + "] is unknown.");
+ }
+ }
+
+ private ShardingSphereStorageContainer createStorageContainer() {
+ switch (description.getStorageType()) {
+ case MySQL:
+ return new MySQLContainer();
+ case H2:
+ return new H2Container();
+ default:
+ throw new RuntimeException("Unknown storage type " + description.getStorageType());
+ }
+ }
+
+ private void inject(final ShardingSphereContainer container) {
+ final List<Field> fields = Lists.newArrayList();
+ for (Class<?> klass = container.getClass(); Objects.nonNull(klass); klass = klass.getSuperclass()) {
+ fields.addAll(Arrays.asList(klass.getDeclaredFields()));
+ }
+ fields.stream()
+ .filter(e -> e.isAnnotationPresent(ShardingSphereITInject.class))
+ .forEach(e -> {
+ Class<?> type = e.getType();
+ e.setAccessible(true);
+ try {
+ if (type.isPrimitive() || String.class == type) {
+ e.set(container, beanContext.getBeanByName(e.getName()));
+ } else {
+ e.set(container, beanContext.getBean(type));
+ }
+ } catch (IllegalAccessException illegalAccessException) {
+ log.error("Failed to auto inject {}.{}.", container.getContainerName(), e.getName());
+ }
+ });
+ }
+
+ /**
+ * Create the initializer and execute.
+ */
+ @SneakyThrows
+ public void createInitializerAndExecute() {
+ testClass.getAnnotatedMethods(ContainerInitializer.class).forEach(method -> {
+ try {
+ if (method.isStatic()) {
+ method.getMethod().setAccessible(true);
+ method.invokeExplosively(null);
+ } else {
+ method.getMethod().setAccessible(true);
+ method.invokeExplosively(instance);
+ }
+ // CHECKSTYLE:OFF
+ } catch (Throwable throwable) {
+ // CHECKSTYLE:ON
+ throwable.printStackTrace();
+ }
+ });
+ }
+
+ /**
+ * Startup.
+ */
+ public void start() {
+ containers.stream().filter(c -> !c.isCreated()).forEach(GenericContainer::start);
+ }
+
+ /**
+ * Wait until all containers ready.
+ */
+ public void waitUntilReady() {
+ containers.stream()
+ .filter(c -> {
+ try {
+ return !c.isHealthy();
+ // CHECKSTYLE:OFF
+ } catch (Exception e) {
+ // CHECKSTYLE:ON
+ return false;
+ }
+ })
+ .forEach(c -> {
+ while (!(c.isRunning() && c.isHealthy())) {
+ try {
+ TimeUnit.MILLISECONDS.sleep(200L);
+ } catch (InterruptedException ignore) {
+
+ }
+ }
+ });
+ log.info("Any container is startup.");
+ }
+
+ @Override
+ public void close() {
+ containers.forEach(Startable::close);
+ }
+
+}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/param/SQLExecuteType.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/compose/NotSupportedException.java
similarity index 84%
copy from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/param/SQLExecuteType.java
copy to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/compose/NotSupportedException.java
index 5aa2f58..9acab94 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/param/SQLExecuteType.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/compose/NotSupportedException.java
@@ -15,12 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.test.integration.engine.param;
+package org.apache.shardingsphere.test.integration.junit.compose;
-/**
- * SQL execute type.
- */
-public enum SQLExecuteType {
-
- Literal, Placeholder
+public class NotSupportedException extends Exception {
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/H2Container.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/H2Container.java
new file mode 100644
index 0000000..9bda4fe
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/H2Container.java
@@ -0,0 +1,75 @@
+/*
+ * 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.shardingsphere.test.integration.junit.container;
+
+import lombok.SneakyThrows;
+import org.apache.shardingsphere.infra.database.type.dialect.H2DatabaseType;
+import org.apache.shardingsphere.test.integration.env.datasource.builder.ActualDataSourceBuilder;
+
+import javax.sql.DataSource;
+import java.util.Map;
+
+public class H2Container extends ShardingSphereStorageContainer {
+
+ private volatile Map<String, DataSource> actualDataSources;
+
+ private volatile boolean isHealthy;
+
+ public H2Container() {
+ super("h2:fake", new H2DatabaseType(), true);
+ }
+
+ @Override
+ @SneakyThrows
+ protected void configure() {
+ super.configure();
+ actualDataSources = ActualDataSourceBuilder.createActualDataSources(getDescription().getScenario(), getDescription().getDatabaseType());
+ isHealthy = true;
+ }
+
+ @Override
+ public boolean isHealthy() {
+ return isHealthy;
+ }
+
+ @Override
+ protected String getUrl(final String dataSourceName) {
+ return null;
+ }
+
+ @Override
+ protected int getPort() {
+ return 0;
+ }
+
+ @Override
+ protected String getUsername() {
+ return null;
+ }
+
+ @Override
+ protected String getPassword() {
+ return null;
+ }
+
+ @Override
+ @SneakyThrows
+ public synchronized Map<String, DataSource> getDataSourceMap() {
+ return actualDataSources;
+ }
+}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/MySQLContainer.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/MySQLContainer.java
new file mode 100644
index 0000000..cff9f62
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/MySQLContainer.java
@@ -0,0 +1,71 @@
+/*
+ * 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.shardingsphere.test.integration.junit.container;
+
+import com.google.common.collect.Lists;
+import lombok.SneakyThrows;
+import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
+
+import java.util.Optional;
+
+/**
+ * MySQL Server Container.
+ */
+public class MySQLContainer extends ShardingSphereStorageContainer {
+
+ public MySQLContainer() {
+ super("mysql/mysql-server:5.7", new MySQLDatabaseType());
+ }
+
+ @Override
+ protected void configure() {
+ withInitSQLMapping("/env/" + getDescription().getScenario() + "/init-sql/mysql");
+ setEnv(Lists.newArrayList("LANG=C.UTF-8"));
+ }
+
+ @Override
+ @SneakyThrows
+ protected void execute() {
+ execInContainer("--sql_mode=", "--default-authentication-plugin=mysql_native_password");
+ }
+
+ @Override
+ protected String getUrl(final String dataSourceName) {
+ return "jdbc:mysql://localhost:" + getPort() + "/" + dataSourceName + "?useServerPrepStmts=true&serverTimezone=UTC&useSSL=false&useLocalSessionState=true&characterEncoding=utf-8";
+ }
+
+ @Override
+ protected Optional<String> getConnectionInitSQL() {
+ return Optional.of("SET sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''))");
+ }
+
+ @Override
+ protected int getPort() {
+ return getMappedPort(3306);
+ }
+
+ @Override
+ protected String getUsername() {
+ return "root";
+ }
+
+ @Override
+ protected String getPassword() {
+ return "";
+ }
+}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/param/SQLExecuteType.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/NativeStorageContainer.java
similarity index 58%
copy from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/param/SQLExecuteType.java
copy to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/NativeStorageContainer.java
index 5aa2f58..c932f79 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/param/SQLExecuteType.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/NativeStorageContainer.java
@@ -15,12 +15,31 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.test.integration.engine.param;
+package org.apache.shardingsphere.test.integration.junit.container;
-/**
- * SQL execute type.
- */
-public enum SQLExecuteType {
+public class NativeStorageContainer extends ShardingSphereStorageContainer {
+
+ public NativeStorageContainer() {
+ super("native-storage", null);
+ }
+
+ @Override
+ protected String getUrl(final String dataSourceName) {
+ return null;
+ }
+
+ @Override
+ protected int getPort() {
+ return 0;
+ }
+
+ @Override
+ protected String getUsername() {
+ return null;
+ }
- Literal, Placeholder
+ @Override
+ protected String getPassword() {
+ return null;
+ }
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/PostgreSQLContainer.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/PostgreSQLContainer.java
new file mode 100644
index 0000000..f7513a6
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/PostgreSQLContainer.java
@@ -0,0 +1,56 @@
+/*
+ * 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.shardingsphere.test.integration.junit.container;
+
+import org.apache.shardingsphere.infra.database.type.dialect.PostgreSQLDatabaseType;
+
+public class PostgreSQLContainer extends ShardingSphereStorageContainer {
+
+ public PostgreSQLContainer() {
+ super("postgres:12.6", new PostgreSQLDatabaseType());
+ }
+
+ @Override
+ protected void configure() {
+ addEnv("POSTGRES_USER", "postgres");
+ addEnv("POSTGRES_PASSWORD", "postgres");
+ withInitSQLMapping("/env/" + getDescription().getScenario() + "/init-sql/postgresql");
+ super.configure();
+ }
+
+ @Override
+ protected String getUrl(final String dataSourceName) {
+ return String.format("jdbc:postgresql://%s:%s/", getHost(), getPort());
+ }
+
+ @Override
+ protected int getPort() {
+ return getMappedPort(5432);
+ }
+
+ @Override
+ protected String getUsername() {
+ return "postgres";
+ }
+
+ @Override
+ protected String getPassword() {
+ return "postgres";
+ }
+
+}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/ShardingSphereAdapterContainer.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/ShardingSphereAdapterContainer.java
new file mode 100644
index 0000000..9c7563d
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/ShardingSphereAdapterContainer.java
@@ -0,0 +1,55 @@
+/*
+ * 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.shardingsphere.test.integration.junit.container;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shardingsphere.test.integration.junit.annotation.XmlResource;
+import org.apache.shardingsphere.test.integration.junit.processor.AuthenticationProcessor;
+import org.apache.shardingsphere.test.integration.junit.processor.AuthenticationProcessor.Authentication;
+
+import javax.sql.DataSource;
+
+@Slf4j
+public abstract class ShardingSphereAdapterContainer extends ShardingSphereContainer {
+
+ @Getter
+ @XmlResource(file = "/docker/{scenario}/proxy/conf/server.yaml", processor = AuthenticationProcessor.class)
+ private Authentication authentication;
+
+ @Getter
+ @Setter
+ private String dockerName;
+
+ public ShardingSphereAdapterContainer(final String dockerImageName) {
+ this(dockerImageName, false);
+ }
+
+ public ShardingSphereAdapterContainer(final String dockerImageName, final boolean isFakeContainer) {
+ super(dockerImageName, isFakeContainer);
+ }
+
+ /**
+ * Get DataSource.
+ *
+ * @return DataSource
+ */
+ public abstract DataSource getDataSource();
+
+}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/ShardingSphereContainer.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/ShardingSphereContainer.java
new file mode 100644
index 0000000..163d8fd
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/ShardingSphereContainer.java
@@ -0,0 +1,166 @@
+/*
+ * 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.shardingsphere.test.integration.junit.container;
+
+import com.google.common.collect.Lists;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.shardingsphere.test.integration.junit.annotation.ShardingSphereITInject;
+import org.apache.shardingsphere.test.integration.junit.annotation.XmlResource;
+import org.apache.shardingsphere.test.integration.junit.processor.Processor;
+import org.apache.shardingsphere.test.integration.junit.runner.TestCaseDescription;
+import org.testcontainers.containers.GenericContainer;
+import org.testcontainers.containers.wait.strategy.DockerHealthcheckWaitStrategy;
+import org.testcontainers.images.RemoteDockerImage;
+import org.testcontainers.utility.DockerImageName;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.nio.file.Files;
+import java.nio.file.StandardOpenOption;
+import java.time.Duration;
+import java.time.temporal.ChronoUnit;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+@Slf4j
+public abstract class ShardingSphereContainer extends GenericContainer<ShardingSphereContainer> {
+
+ private static final Pattern REGEX = Pattern.compile("\\{([\\w._-]*)}");
+
+ @Getter
+ private final boolean isFakeContainer;
+
+ @Getter
+ @ShardingSphereITInject
+ private TestCaseDescription description;
+
+ @Getter
+ @Setter
+ private String dockerName;
+
+ public ShardingSphereContainer(final String dockerImageName, final boolean isFakeContainer) {
+ super(convertToDockerImage(dockerImageName, isFakeContainer));
+ this.isFakeContainer = isFakeContainer;
+ }
+
+ private static RemoteDockerImage convertToDockerImage(final String dockerImageName, final boolean isFakeContainer) {
+ if (isFakeContainer) {
+ return new RemoteDockerImage(DockerImageName.parse(dockerImageName)).withImagePullPolicy(dockerName -> false);
+ }
+ return new RemoteDockerImage(DockerImageName.parse(dockerImageName));
+ }
+
+ @Override
+ public void start() {
+ resolveXmlResource(this.getClass());
+ configure();
+ startDependencies();
+ if (!isFakeContainer) {
+ super.start();
+ }
+ execute();
+ }
+
+ private void startDependencies() {
+ final List<ShardingSphereContainer> dependencies = getDependencies().stream()
+ .map(e -> (ShardingSphereContainer) e)
+ .collect(Collectors.toList());
+ dependencies.stream()
+ .filter(c -> !c.isCreated())
+ .forEach(GenericContainer::start);
+ dependencies.stream()
+ .filter(c -> {
+ try {
+ return !c.isHealthy();
+ // CHECKSTYLE:OFF
+ } catch (Exception e) {
+ // CHECKSTYLE:ON
+ log.warn("Failed to check container {} healthy.", c.getDockerName(), e);
+ return false;
+ }
+ })
+ .forEach(c -> {
+ DockerHealthcheckWaitStrategy waitStrategy = new DockerHealthcheckWaitStrategy();
+ log.info("Waiting for container {} healthy.", c.getDockerImageName());
+ waitStrategy.withStartupTimeout(Duration.of(90, ChronoUnit.SECONDS));
+ waitStrategy.waitUntilReady(c);
+ log.info("Container {} is startup.", c.getDockerImageName());
+ });
+ }
+
+ private void resolveXmlResource(final Class<?> klass) {
+ ArrayList<Field> fields = Lists.newArrayList(klass.getDeclaredFields());
+ fields.stream()
+ .filter(it -> it.isAnnotationPresent(XmlResource.class))
+ .forEach(this::injectXmlResource);
+ Class<?> parent = klass.getSuperclass();
+ if (Objects.nonNull(parent)) {
+ resolveXmlResource(parent);
+ }
+ }
+
+ @SuppressWarnings("rawtypes")
+ private void injectXmlResource(final Field field) {
+ XmlResource annotation = field.getAnnotation(XmlResource.class);
+ String file = parse(annotation.file());
+ Class<? extends Processor> processor = annotation.processor();
+ String base = getClass().getResource("/").getFile();
+ try (InputStream stream = Files.newInputStream(new File(base, file).toPath(), StandardOpenOption.READ)) {
+ Object result = processor.newInstance().process(stream);
+ field.setAccessible(true);
+ field.set(this, result);
+ } catch (InstantiationException | IllegalAccessException | IOException ex) {
+ throw new RuntimeException(ex.getMessage(), ex);
+ }
+ }
+
+ @SneakyThrows
+ private String parse(final String pattern) {
+ String result = pattern;
+ Matcher matcher = REGEX.matcher(pattern);
+ Map<String, Method> methodMap = Arrays.stream(TestCaseDescription.class.getDeclaredMethods())
+ .filter(e -> e.getName().startsWith("get"))
+ .collect(Collectors.toMap(e -> StringUtils.uncapitalize(e.getName().substring(3)), e -> e));
+ while (matcher.find()) {
+ result = result.replace(matcher.group(), invoke(methodMap.get(matcher.group(1))));
+ }
+ return result;
+ }
+
+ @SneakyThrows
+ private String invoke(final Method method) {
+ return String.valueOf(method.invoke(description));
+ }
+
+ protected void execute() {
+
+ }
+}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/ShardingSphereJDBCContainer.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/ShardingSphereJDBCContainer.java
new file mode 100644
index 0000000..9dc3f0c
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/ShardingSphereJDBCContainer.java
@@ -0,0 +1,84 @@
+/*
+ * 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.shardingsphere.test.integration.junit.container;
+
+import lombok.NonNull;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shardingsphere.driver.api.yaml.YamlShardingSphereDataSourceFactory;
+import org.apache.shardingsphere.test.integration.env.EnvironmentPath;
+import org.testcontainers.containers.wait.strategy.WaitStrategy;
+import org.testcontainers.lifecycle.Startable;
+
+import javax.sql.DataSource;
+import java.io.File;
+import java.io.IOException;
+import java.sql.SQLException;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.stream.Collectors;
+
+@Slf4j
+public class ShardingSphereJDBCContainer extends ShardingSphereAdapterContainer {
+
+ private final AtomicBoolean isHealthy = new AtomicBoolean();
+
+ private Map<String, DataSource> dataSourceMap;
+
+ public ShardingSphereJDBCContainer() {
+ super("ShardingSphere-JDBC", true);
+ }
+
+ @Override
+ public void start() {
+ super.start();
+ // do not start because it is a fake container.
+ List<Startable> startables = getDependencies().stream()
+ .filter(e -> e instanceof ShardingSphereStorageContainer)
+ .collect(Collectors.toList());
+ dataSourceMap = ((ShardingSphereStorageContainer) startables.get(0)).getDataSourceMap();
+ isHealthy.set(true);
+ }
+
+ /**
+ * Get DataSource.
+ *
+ * @return DataSource
+ */
+ public DataSource getDataSource() {
+ try {
+ return YamlShardingSphereDataSourceFactory.createDataSource(
+ dataSourceMap,
+ new File(EnvironmentPath.getRulesConfigurationFile(getDescription().getScenario()))
+ );
+ } catch (SQLException | IOException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ @Override
+ public boolean isHealthy() {
+ return isHealthy.get();
+ }
+
+ @Override
+ public ShardingSphereContainer waitingFor(final @NonNull WaitStrategy waitStrategy) {
+ return super.waitingFor(waitStrategy);
+ }
+
+}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/ShardingSphereProxyContainer.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/ShardingSphereProxyContainer.java
new file mode 100644
index 0000000..41a5e29
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/ShardingSphereProxyContainer.java
@@ -0,0 +1,121 @@
+/*
+ * 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.shardingsphere.test.integration.junit.container;
+
+import com.zaxxer.hikari.HikariConfig;
+import com.zaxxer.hikari.HikariDataSource;
+import lombok.extern.slf4j.Slf4j;
+import org.testcontainers.containers.BindMode;
+import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy;
+import org.testcontainers.utility.MountableFile;
+
+import javax.sql.DataSource;
+import java.util.Objects;
+import java.util.concurrent.atomic.AtomicReference;
+
+@Slf4j
+public class ShardingSphereProxyContainer extends ShardingSphereAdapterContainer {
+
+ private static final String AGENT_HOME_IN_CONTAINER = "/usr/local/shardingsphere-agent";
+
+ private static final String PROPERTY_AGENT_HOME = "AGENT_HOME";
+
+ private final AtomicReference<DataSource> dataSourceProvider = new AtomicReference<>();
+
+ public ShardingSphereProxyContainer() {
+ super("apache/shardingsphere-proxy-test");
+ }
+
+ /**
+ * Mount path into container from classpath.
+ *
+ * @param classPathResource resource path in classpath
+ * @param containerPath path in container
+ * @return self
+ */
+ public ShardingSphereProxyContainer withClassPathResourceMapping(final String classPathResource, final String containerPath) {
+ withCopyFileToContainer(MountableFile.forClasspathResource(classPathResource), containerPath);
+ return this;
+ }
+
+ /**
+ * Mount configure path into container from classpath.
+ *
+ * @param resourcePath resource path
+ * @return self
+ */
+ public ShardingSphereProxyContainer withConfMapping(final String resourcePath) {
+ return withClassPathResourceMapping(resourcePath, "/opt/shardingsphere-proxy/conf");
+ }
+
+ /**
+ * Mount the agent into container.
+ *
+ * @param agentHome agent home
+ * @return self
+ */
+ public ShardingSphereProxyContainer withAgent(final String agentHome) {
+ withEnv(PROPERTY_AGENT_HOME, AGENT_HOME_IN_CONTAINER);
+ withFileSystemBind(agentHome, AGENT_HOME_IN_CONTAINER, BindMode.READ_ONLY);
+ return this;
+ }
+
+ @Override
+ protected void configure() {
+ withConfMapping("/docker/" + getDescription().getScenario() + "/proxy/conf");
+ super.setWaitStrategy(new LogMessageWaitStrategy().withRegEx(".*ShardingSphere-Proxy start success.*"));
+ super.configure();
+ }
+
+ @Override
+ protected void execute() {
+ log.info("Mapped port 3307: {}", getMappedPort(3307));
+ log.info("Mapped port 3308: {}", getMappedPort(3308));
+ }
+
+ /**
+ * Get DataSource.
+ *
+ * @return DataSource
+ */
+ public DataSource getDataSource() {
+ DataSource dataSource = dataSourceProvider.get();
+ if (Objects.isNull(dataSource)) {
+ dataSourceProvider.lazySet(createDataSource());
+ }
+ return dataSourceProvider.get();
+ }
+
+ private DataSource createDataSource() {
+ HikariConfig result = new HikariConfig();
+ result.setDriverClassName("com.mysql.jdbc.Driver");
+ result.setJdbcUrl(getURL());
+ result.setUsername(getAuthentication().getUser());
+ result.setPassword(getAuthentication().getPassword());
+ result.setMaximumPoolSize(2);
+ result.setTransactionIsolation("TRANSACTION_READ_COMMITTED");
+ result.setConnectionInitSql("SET sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''))");
+ return new HikariDataSource(result);
+ }
+
+ protected String getURL() {
+ return String.format("jdbc:mysql://%s:%s/%s?useServerPrepStmts=true&serverTimezone=UTC&useSSL=false&useLocalSessionState=true&characterEncoding=utf-8",
+ getHost(), getMappedPort(3307), getDescription().getScenario());
+ }
+
+}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/ShardingSphereStorageContainer.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/ShardingSphereStorageContainer.java
new file mode 100644
index 0000000..9702cec
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/ShardingSphereStorageContainer.java
@@ -0,0 +1,124 @@
+/*
+ * 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.shardingsphere.test.integration.junit.container;
+
+import com.zaxxer.hikari.HikariConfig;
+import com.zaxxer.hikari.HikariDataSource;
+import lombok.Getter;
+import org.apache.shardingsphere.infra.database.type.DatabaseType;
+import org.apache.shardingsphere.test.integration.junit.annotation.XmlResource;
+import org.apache.shardingsphere.test.integration.junit.processor.DatabaseProcessor;
+import org.testcontainers.containers.BindMode;
+import org.testcontainers.shaded.com.google.common.collect.ImmutableMap;
+import org.testcontainers.shaded.com.google.common.collect.ImmutableMap.Builder;
+
+import javax.sql.DataSource;
+import java.util.Collection;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+
+/**
+ * The storage container was binding to the single scenario and database type.
+ */
+public abstract class ShardingSphereStorageContainer extends ShardingSphereContainer {
+
+ @Getter
+ @XmlResource(file = "/env/{scenario}/databases.xml", processor = DatabaseProcessor.class)
+ private Collection<String> databases;
+
+ private ImmutableMap<String, DataSource> dataSourceMap;
+
+ @Getter
+ private final DatabaseType databaseType;
+
+ public ShardingSphereStorageContainer(final String dockerImageName, final DatabaseType databaseType) {
+ this(dockerImageName, databaseType, false);
+ }
+
+ public ShardingSphereStorageContainer(final String dockerImageName, final DatabaseType databaseType, final boolean isFakeContainer) {
+ super(dockerImageName, isFakeContainer);
+ this.databaseType = databaseType;
+ }
+
+ /**
+ * Mount a source path into container.
+ *
+ * @param resourcePath resource path
+ * @return self
+ */
+ public ShardingSphereStorageContainer withInitSQLMapping(final String resourcePath) {
+ withClasspathResourceMapping(resourcePath, "/docker-entrypoint-initdb.d/", BindMode.READ_ONLY);
+ return this;
+ }
+
+ protected DataSource createDataSource(final String dataSourceName) {
+ HikariConfig config = new HikariConfig();
+ config.setUsername(getUsername());
+ config.setPassword(getPassword());
+ config.setDriverClassName(getDriverClassName());
+ config.setJdbcUrl(getUrl(dataSourceName));
+ config.setMaximumPoolSize(2);
+ config.setTransactionIsolation("TRANSACTION_READ_COMMITTED");
+ getConnectionInitSQL().ifPresent(config::setConnectionInitSql);
+ return new HikariDataSource(config);
+ }
+
+ /**
+ * Get DataSource Map.
+ *
+ * @return DatabaseName and DataSource Map
+ */
+ public synchronized Map<String, DataSource> getDataSourceMap() {
+ if (Objects.isNull(dataSourceMap)) {
+ Builder<String, DataSource> builder = ImmutableMap.builder();
+ databases.forEach(e -> builder.put(e, createDataSource(e)));
+ dataSourceMap = builder.build();
+ }
+ return dataSourceMap;
+ }
+
+ protected Optional<String> getConnectionInitSQL() {
+ return Optional.empty();
+ }
+
+ protected String getDriverClassName() {
+ switch (databaseType.getName()) {
+ case "H2":
+ return "org.h2.Driver";
+ case "MySQL":
+ return "com.mysql.jdbc.Driver";
+ case "PostgreSQL":
+ return "org.postgresql.Driver";
+ case "SQLServer":
+ return "com.microsoft.sqlserver.jdbc.SQLServerDriver";
+ case "Oracle":
+ return "oracle.jdbc.driver.OracleDriver";
+ default:
+ throw new UnsupportedOperationException(databaseType.getName());
+ }
+ }
+
+ protected abstract String getUrl(String dataSourceName);
+
+ protected abstract int getPort();
+
+ protected abstract String getUsername();
+
+ protected abstract String getPassword();
+}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/logging/ContainerLogs.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/logging/ContainerLogs.java
new file mode 100644
index 0000000..d173d20
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/logging/ContainerLogs.java
@@ -0,0 +1,61 @@
+/*
+ * 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.shardingsphere.test.integration.junit.logging;
+
+import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.LoggerContext;
+import ch.qos.logback.classic.encoder.PatternLayoutEncoder;
+import ch.qos.logback.classic.spi.ILoggingEvent;
+import ch.qos.logback.core.ConsoleAppender;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import org.slf4j.LoggerFactory;
+import org.testcontainers.containers.output.BaseConsumer;
+import org.testcontainers.containers.output.Slf4jLogConsumer;
+
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public class ContainerLogs {
+
+ /**
+ * Create new log consumer.
+ *
+ * @param serviceName service name
+ * @return log consumer
+ */
+ public static BaseConsumer<?> newConsumer(final String serviceName) {
+ final LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
+
+ PatternLayoutEncoder encoder = new PatternLayoutEncoder();
+ encoder.setContext(context);
+ encoder.setPattern("%d{yyyy-MM-dd HH:mm:ss.SSS} %msg%n");
+ encoder.start();
+
+ final ConsoleAppender<ILoggingEvent> fileAppender = new ConsoleAppender<>();
+ fileAppender.setEncoder(encoder);
+ fileAppender.start();
+
+ final ch.qos.logback.classic.Logger logger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(serviceName);
+ logger.addAppender(fileAppender);
+ logger.setLevel(Level.DEBUG);
+ logger.setAdditive(false);
+
+ Slf4jLogConsumer consumer = new Slf4jLogConsumer(logger, true);
+ consumer.withPrefix(serviceName);
+ return consumer;
+ }
+}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/param/ParameterizedArrayFactory.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/param/ParameterizedArrayFactory.java
similarity index 92%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/param/ParameterizedArrayFactory.java
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/param/ParameterizedArrayFactory.java
index dbbf787..3cca6f3 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/param/ParameterizedArrayFactory.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/param/ParameterizedArrayFactory.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.test.integration.engine.param;
+package org.apache.shardingsphere.test.integration.junit.param;
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
@@ -28,9 +28,10 @@ import org.apache.shardingsphere.test.integration.cases.IntegrationTestCaseConte
import org.apache.shardingsphere.test.integration.cases.IntegrationTestCasesLoader;
import org.apache.shardingsphere.test.integration.cases.SQLCommandType;
import org.apache.shardingsphere.test.integration.cases.assertion.IntegrationTestCaseAssertion;
-import org.apache.shardingsphere.test.integration.engine.param.model.AssertionParameterizedArray;
-import org.apache.shardingsphere.test.integration.engine.param.model.CaseParameterizedArray;
-import org.apache.shardingsphere.test.integration.engine.param.model.ParameterizedArray;
+import org.apache.shardingsphere.test.integration.common.SQLExecuteType;
+import org.apache.shardingsphere.test.integration.junit.param.model.AssertionParameterizedArray;
+import org.apache.shardingsphere.test.integration.junit.param.model.CaseParameterizedArray;
+import org.apache.shardingsphere.test.integration.junit.param.model.ParameterizedArray;
import org.apache.shardingsphere.test.integration.env.IntegrationTestEnvironment;
import java.util.Arrays;
@@ -51,18 +52,19 @@ public final class ParameterizedArrayFactory {
private static final IntegrationTestEnvironment ENV = IntegrationTestEnvironment.getInstance();
+
/**
* Get assertion parameterized array.
- *
+ *
* @param sqlCommandType SQL command type
* @return assertion parameterized array
*/
- public static Collection<Object[]> getAssertionParameterizedArray(final SQLCommandType sqlCommandType) {
+ public static Collection<ParameterizedArray> getAssertionParameterized(final SQLCommandType sqlCommandType) {
Collection<ParameterizedArray> result = new LinkedList<>();
for (IntegrationTestCaseContext each : TEST_CASES_LOADER.getTestCaseContexts(sqlCommandType)) {
result.addAll(getAssertionParameterizedArray(each, sqlCommandType));
}
- return toArrays(result);
+ return result;
}
private static Collection<ParameterizedArray> getAssertionParameterizedArray(final IntegrationTestCaseContext testCaseContext, final SQLCommandType sqlCommandType) {
@@ -117,12 +119,12 @@ public final class ParameterizedArrayFactory {
* @param sqlCommandType SQL command type
* @return case parameterized array
*/
- public static Collection<Object[]> getCaseParameterizedArray(final SQLCommandType sqlCommandType) {
+ public static Collection<ParameterizedArray> getCaseParameterized(final SQLCommandType sqlCommandType) {
Collection<ParameterizedArray> result = new LinkedList<>();
for (IntegrationTestCaseContext each : TEST_CASES_LOADER.getTestCaseContexts(sqlCommandType)) {
result.addAll(getCaseParameterizedArray(each, sqlCommandType));
}
- return toArrays(result);
+ return result;
}
private static Collection<ParameterizedArray> getCaseParameterizedArray(final IntegrationTestCaseContext testCaseContext, final SQLCommandType sqlCommandType) {
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/param/RunnerParameters.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/param/RunnerParameters.java
similarity index 74%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/param/RunnerParameters.java
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/param/RunnerParameters.java
index d234df1..5810923 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/param/RunnerParameters.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/param/RunnerParameters.java
@@ -15,12 +15,12 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.test.integration.engine.param;
+package org.apache.shardingsphere.test.integration.junit.param;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
-import org.apache.shardingsphere.test.integration.engine.param.model.ParameterizedArray;
-import org.junit.runners.parameterized.BlockJUnit4ClassRunnerWithParameters;
+import org.apache.shardingsphere.test.integration.junit.param.model.ParameterizedArray;
+import org.apache.shardingsphere.test.integration.junit.runner.ShardingSphereCISubRunner;
import java.lang.reflect.Field;
@@ -39,10 +39,9 @@ public final class RunnerParameters {
*/
@SneakyThrows(ReflectiveOperationException.class)
public ParameterizedArray getParameterizedArray() {
- Field parametersField = BlockJUnit4ClassRunnerWithParameters.class.getDeclaredField("parameters");
- parametersField.setAccessible(true);
- Object[] parameters = (Object[]) parametersField.get(getRunner());
- return (ParameterizedArray) parameters[0];
+ Field field = ShardingSphereCISubRunner.class.getDeclaredField("parameterized");
+ field.setAccessible(true);
+ return (ParameterizedArray) field.get(getRunner());
}
@SneakyThrows(ReflectiveOperationException.class)
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/param/model/CaseParameterizedArray.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/param/TestCaseParameters.java
similarity index 52%
copy from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/param/model/CaseParameterizedArray.java
copy to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/param/TestCaseParameters.java
index e862e14..2c5be6c 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/param/model/CaseParameterizedArray.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/param/TestCaseParameters.java
@@ -15,33 +15,32 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.test.integration.engine.param.model;
+package org.apache.shardingsphere.test.integration.junit.param;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.test.integration.cases.IntegrationTestCaseContext;
-import org.apache.shardingsphere.test.integration.cases.SQLCommandType;
+import lombok.ToString;
+import org.apache.shardingsphere.test.integration.cases.assertion.IntegrationTestCase;
+import org.apache.shardingsphere.test.integration.cases.assertion.IntegrationTestCaseAssertion;
+import org.apache.shardingsphere.test.integration.common.SQLExecuteType;
-/**
- * Parameterized array of case based integration test.
- */
-@RequiredArgsConstructor
@Getter
-public final class CaseParameterizedArray implements ParameterizedArray {
+@ToString
+@RequiredArgsConstructor
+public class TestCaseParameters {
+
+ private final String name;
+
+ private final String parentPath;
- private final IntegrationTestCaseContext testCaseContext;
+ private final String statement;
- private final String adapter;
+ private final SQLExecuteType executeType;
- private final String scenario;
+ private final Class<?> testClass;
- private final DatabaseType databaseType;
+ private final IntegrationTestCase testCase;
- private final SQLCommandType sqlCommandType;
+ private final IntegrationTestCaseAssertion assertion;
- @Override
- public String toString() {
- return String.format("%s: %s -> %s -> %s", adapter, scenario, databaseType.getName(), testCaseContext.getTestCase().getSql());
- }
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/param/model/AssertionParameterizedArray.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/param/model/AssertionParameterizedArray.java
similarity index 92%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/param/model/AssertionParameterizedArray.java
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/param/model/AssertionParameterizedArray.java
index 90294ce..edb3db6 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/param/model/AssertionParameterizedArray.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/param/model/AssertionParameterizedArray.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.test.integration.engine.param.model;
+package org.apache.shardingsphere.test.integration.junit.param.model;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
@@ -23,7 +23,7 @@ import org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.test.integration.cases.IntegrationTestCaseContext;
import org.apache.shardingsphere.test.integration.cases.SQLCommandType;
import org.apache.shardingsphere.test.integration.cases.assertion.IntegrationTestCaseAssertion;
-import org.apache.shardingsphere.test.integration.engine.param.SQLExecuteType;
+import org.apache.shardingsphere.test.integration.common.SQLExecuteType;
/**
* Parameterized array of assertion based integration test.
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/param/model/CaseParameterizedArray.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/param/model/CaseParameterizedArray.java
similarity index 95%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/param/model/CaseParameterizedArray.java
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/param/model/CaseParameterizedArray.java
index e862e14..134cb4f 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/param/model/CaseParameterizedArray.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/param/model/CaseParameterizedArray.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.test.integration.engine.param.model;
+package org.apache.shardingsphere.test.integration.junit.param.model;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/param/model/ParameterizedArray.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/param/model/ParameterizedArray.java
similarity index 95%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/param/model/ParameterizedArray.java
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/param/model/ParameterizedArray.java
index 49028a9..9d39559 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/param/model/ParameterizedArray.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/param/model/ParameterizedArray.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.test.integration.engine.param.model;
+package org.apache.shardingsphere.test.integration.junit.param.model;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.test.integration.cases.IntegrationTestCaseContext;
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/processor/AuthenticationProcessor.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/processor/AuthenticationProcessor.java
new file mode 100644
index 0000000..530408c
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/processor/AuthenticationProcessor.java
@@ -0,0 +1,49 @@
+/*
+ * 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.shardingsphere.test.integration.junit.processor;
+
+import com.google.common.io.ByteStreams;
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import lombok.SneakyThrows;
+import org.apache.shardingsphere.infra.metadata.auth.builtin.yaml.config.YamlUserConfiguration;
+import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
+import org.apache.shardingsphere.proxy.config.yaml.YamlProxyServerConfiguration;
+
+import java.io.InputStream;
+
+public class AuthenticationProcessor implements Processor<AuthenticationProcessor.Authentication> {
+
+ @Override
+ @SneakyThrows
+ public Authentication process(final InputStream stream) {
+ YamlProxyServerConfiguration configuration = YamlEngine.unmarshal(ByteStreams.toByteArray(stream), YamlProxyServerConfiguration.class);
+ YamlUserConfiguration user = configuration.getAuthentication().getUsers().get("root");
+ return new Authentication("root", user.getPassword());
+ }
+
+ @Getter
+ @RequiredArgsConstructor
+ public static class Authentication {
+
+ private final String user;
+
+ private final String password;
+
+ }
+}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/ParallelRunnerExecutor.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/processor/DatabaseProcessor.java
similarity index 51%
copy from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/ParallelRunnerExecutor.java
copy to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/processor/DatabaseProcessor.java
index c5d8577..c79bc8b 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/ParallelRunnerExecutor.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/processor/DatabaseProcessor.java
@@ -15,25 +15,27 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.test.integration.engine.junit.parallel;
+package org.apache.shardingsphere.test.integration.junit.processor;
-import org.apache.shardingsphere.test.integration.engine.param.model.ParameterizedArray;
+import lombok.SneakyThrows;
-/**
- * Parallel runner executor.
- */
-public interface ParallelRunnerExecutor {
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.io.InputStream;
+import java.util.Collection;
+import java.util.LinkedList;
+
+@XmlRootElement(name = "databases")
+public class DatabaseProcessor implements Processor<Collection<String>> {
+
+ @XmlElement(name = "database")
+ private final Collection<String> databases = new LinkedList<>();
- /**
- * Execute child statement.
- *
- * @param parameterizedArray parameterized array
- * @param childStatement child statement
- */
- void execute(ParameterizedArray parameterizedArray, Runnable childStatement);
+ @SneakyThrows
+ @Override
+ public Collection<String> process(final InputStream stream) {
+ return ((DatabaseProcessor) JAXBContext.newInstance(DatabaseProcessor.class).createUnmarshaller().unmarshal(stream)).databases;
+ }
- /**
- * Override to implement any behavior that must occur after all children have been scheduled (for example, waiting for them all to finish).
- */
- void finished();
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/param/SQLExecuteType.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/processor/Processor.java
similarity index 74%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/param/SQLExecuteType.java
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/processor/Processor.java
index 5aa2f58..6d86301 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/param/SQLExecuteType.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/processor/Processor.java
@@ -15,12 +15,18 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.test.integration.engine.param;
+package org.apache.shardingsphere.test.integration.junit.processor;
-/**
- * SQL execute type.
- */
-public enum SQLExecuteType {
+import java.io.InputStream;
+
+public interface Processor<T> {
+
+ /**
+ * Process InputStream.
+ *
+ * @param stream file
+ * @return configuration bean
+ */
+ T process(InputStream stream);
- Literal, Placeholder
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/runner/ShardingSphereCISubRunner.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/runner/ShardingSphereCISubRunner.java
new file mode 100644
index 0000000..f0a9233
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/runner/ShardingSphereCISubRunner.java
@@ -0,0 +1,118 @@
+/*
+ * 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.shardingsphere.test.integration.junit.runner;
+
+import lombok.Getter;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shardingsphere.test.integration.common.SQLExecuteType;
+import org.apache.shardingsphere.test.integration.junit.annotation.ShardingSphereITInject;
+import org.apache.shardingsphere.test.integration.junit.compose.ContainerCompose;
+import org.apache.shardingsphere.test.integration.junit.param.model.ParameterizedArray;
+import org.junit.runners.BlockJUnit4ClassRunner;
+import org.junit.runners.model.FrameworkMethod;
+import org.junit.runners.model.InitializationError;
+import org.junit.runners.model.Statement;
+
+import java.lang.reflect.Field;
+
+@Slf4j
+public class ShardingSphereCISubRunner extends BlockJUnit4ClassRunner {
+
+ private final TestCaseBeanContext context;
+
+ private final ContainerCompose compose;
+
+ private volatile Object testInstance;
+
+ @Getter
+ private final ParameterizedArray parameterized;
+
+ public ShardingSphereCISubRunner(final Class<?> testClass, final TestCaseBeanContext context) throws InitializationError {
+ super(testClass);
+ this.context = context;
+ this.parameterized = context.getBean(ParameterizedArray.class);
+ this.compose = new ContainerCompose(getTestClass().getName(), getTestClass(), context.getBean(TestCaseDescription.class), context);
+ }
+
+ @Override
+ protected Object createTest() throws Exception {
+ testInstance = super.createTest();
+ compose.setInstance(testInstance);
+ compose.createContainers();
+ getTestClass().getAnnotatedFields(ShardingSphereITInject.class)
+ .forEach(e -> {
+ try {
+ Field field = e.getField();
+ field.setAccessible(true);
+ if (field.getType() == String.class) {
+ field.set(testInstance, context.getBeanByName(field.getName()));
+ } else {
+ field.set(testInstance, context.getBean(e.getType()));
+ }
+ } catch (IllegalAccessException ex) {
+ throw new RuntimeException(ex.getMessage(), ex);
+ }
+ });
+ compose.createInitializerAndExecute();
+ compose.start();
+ compose.waitUntilReady();
+ return testInstance;
+ }
+
+ @Override
+ protected String testName(final FrameworkMethod method) {
+ return method.getName() + getName();
+ }
+
+ @Override
+ protected Statement withBeforeClasses(final Statement statement) {
+ // skip @BeforeClass
+ return new Statement() {
+ @Override
+ public void evaluate() throws Throwable {
+ statement.evaluate();
+ }
+ };
+ }
+
+ @Override
+ protected Statement withAfterClasses(final Statement statement) {
+ // skip @AfterClass
+ return new Statement() {
+ @Override
+ public void evaluate() throws Throwable {
+ statement.evaluate();
+ compose.close();
+ }
+ };
+ }
+
+ @Override
+ protected String getName() {
+ // {2}: {3} -> {4} -> {5} -> {6}
+ TestCaseDescription description = context.getBean(TestCaseDescription.class);
+ return String.format("[%s: %s -> %s -> %s -> %s]",
+ description.getAdapter(),
+ description.getScenario(),
+ description.getDatabase(),
+ context.getBean(SQLExecuteType.class),
+ context.getBeanByName("statement")
+ );
+ }
+
+}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/runner/ShardingSphereITSubRunner.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/runner/ShardingSphereITSubRunner.java
new file mode 100644
index 0000000..3faeae6
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/runner/ShardingSphereITSubRunner.java
@@ -0,0 +1,115 @@
+/*
+ * 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.shardingsphere.test.integration.junit.runner;
+
+import lombok.Getter;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shardingsphere.test.integration.common.SQLExecuteType;
+import org.apache.shardingsphere.test.integration.junit.annotation.OnContainer;
+import org.apache.shardingsphere.test.integration.junit.annotation.ShardingSphereITInject;
+import org.junit.runners.BlockJUnit4ClassRunner;
+import org.junit.runners.model.InitializationError;
+import org.junit.runners.model.Statement;
+
+import java.lang.reflect.Field;
+
+@Slf4j
+public class ShardingSphereITSubRunner extends BlockJUnit4ClassRunner {
+
+ @Getter
+ private final TestCaseBeanContext context;
+
+ public ShardingSphereITSubRunner(final Class<?> testClass, final TestCaseBeanContext context) throws InitializationError {
+ super(testClass);
+ this.context = context;
+ }
+
+ @Override
+ protected Object createTest() throws Exception {
+ final Object testInstance = super.createTest();
+ autowired(testInstance);
+ return testInstance;
+ }
+
+ /**
+ * Clone and return.
+ *
+ * @return self
+ * @throws InitializationError ex
+ */
+ public ShardingSphereITSubRunner copySelf() throws InitializationError {
+ return new ShardingSphereITSubRunner(getTestClass().getJavaClass(), context);
+ }
+
+ protected Object createTestInstance() throws Exception {
+ return super.createTest();
+ }
+
+ protected void autowired(final Object testInstance) {
+ getTestClass().getAnnotatedFields(ShardingSphereITInject.class)
+ .forEach(e -> {
+ try {
+ Field field = e.getField();
+ field.setAccessible(true);
+ if (field.getType() == String.class) {
+ field.set(testInstance, context.getBeanByName(field.getName()));
+ } else {
+ field.set(testInstance, context.getBean(e.getType()));
+ }
+ } catch (IllegalAccessException ex) {
+ throw new RuntimeException(ex.getMessage(), ex);
+ }
+ });
+ getTestClass().getAnnotatedFields(OnContainer.class).forEach(e -> {
+ OnContainer container = e.getAnnotation(OnContainer.class);
+ Object c = context.getBeanByName(container.name());
+ try {
+ e.getField().setAccessible(true);
+ e.getField().set(testInstance, c);
+ } catch (IllegalAccessException ex) {
+ throw new RuntimeException(ex);
+ }
+ });
+ }
+
+ @Override
+ protected Statement withBeforeClasses(final Statement statement) {
+ // skip @BeforeClass
+ return statement;
+ }
+
+ @Override
+ protected Statement withAfterClasses(final Statement statement) {
+ // skip @AfterClass
+ return statement;
+ }
+
+ @Override
+ protected String getName() {
+ // {2}: {3} -> {4} -> {5} -> {6}
+ TestCaseDescription description = context.getBean(TestCaseDescription.class);
+ return String.format("[%s: %s -> %s -> %s -> %s]",
+ description.getAdapter(),
+ description.getScenario(),
+ description.getDatabase(),
+ context.getBean(SQLExecuteType.class),
+ context.getBeanByName("statement")
+ );
+ }
+
+}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/runner/ShardingSphereRunner.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/runner/ShardingSphereRunner.java
new file mode 100644
index 0000000..5504617
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/runner/ShardingSphereRunner.java
@@ -0,0 +1,301 @@
+/*
+ * 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.shardingsphere.test.integration.junit.runner;
+
+import com.google.common.base.Strings;
+import lombok.Getter;
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shardingsphere.test.integration.cases.IntegrationTestCasesLoader;
+import org.apache.shardingsphere.test.integration.cases.assertion.IntegrationTestCase;
+import org.apache.shardingsphere.test.integration.cases.assertion.IntegrationTestCaseAssertion;
+import org.apache.shardingsphere.test.integration.common.SQLExecuteType;
+import org.apache.shardingsphere.test.integration.env.EnvironmentType;
+import org.apache.shardingsphere.test.integration.env.IntegrationTestEnvironment;
+import org.apache.shardingsphere.test.integration.junit.annotation.BeforeAllCases;
+import org.apache.shardingsphere.test.integration.junit.annotation.ParameterFilter;
+import org.apache.shardingsphere.test.integration.junit.annotation.TestCaseSpec;
+import org.apache.shardingsphere.test.integration.junit.compose.ContainerCompose;
+import org.apache.shardingsphere.test.integration.junit.compose.NotSupportedException;
+import org.apache.shardingsphere.test.integration.junit.param.ParameterizedArrayFactory;
+import org.apache.shardingsphere.test.integration.junit.param.TestCaseParameters;
+import org.apache.shardingsphere.test.integration.junit.param.model.AssertionParameterizedArray;
+import org.apache.shardingsphere.test.integration.junit.param.model.CaseParameterizedArray;
+import org.apache.shardingsphere.test.integration.junit.param.model.ParameterizedArray;
+import org.apache.shardingsphere.test.integration.junit.runner.parallel.ParallelRunnerScheduler;
+import org.apache.shardingsphere.test.integration.junit.runner.parallel.annotaion.ParallelRuntimeStrategy;
+import org.junit.runner.Runner;
+import org.junit.runners.Suite;
+import org.junit.runners.model.FrameworkMethod;
+import org.junit.runners.model.InitializationError;
+import org.junit.runners.model.Statement;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+
+@Slf4j
+public class ShardingSphereRunner extends Suite {
+
+ private final List<Runner> runners;
+
+ @Getter
+ private final String caseName;
+
+ private ContainerCompose compose;
+
+ private final TestCaseBeanContext beanContext = new TestCaseBeanContext();
+
+ public ShardingSphereRunner(final Class<?> klass) throws InitializationError {
+ super(klass, Collections.emptyList());
+ TestCaseSpec testCaseSpec = getTestClass().getAnnotation(TestCaseSpec.class);
+ caseName = Strings.isNullOrEmpty(testCaseSpec.name()) ? klass.getSimpleName() : testCaseSpec.name();
+ if (EnvironmentType.NATIVE == IntegrationTestEnvironment.getInstance().getEnvType()) {
+ ParallelRuntimeStrategy parallelRuntimeStrategy = getTestClass().getAnnotation(ParallelRuntimeStrategy.class);
+ if (null != parallelRuntimeStrategy) {
+ setScheduler(new ParallelRunnerScheduler(parallelRuntimeStrategy.value()));
+ }
+ runners = createCIRunners(testCaseSpec);
+ } else {
+ runners = createITRunners(testCaseSpec);
+ }
+ }
+
+ private List<Runner> createITRunners(final TestCaseSpec testCaseSpec) {
+ final Predicate<TestCaseBeanContext> predicate = createTestCaseParametersPredicate();
+ TestCaseDescription description = TestCaseDescription.fromSystemProps(testCaseSpec).build();
+ beanContext.registerBean(TestCaseDescription.class, description);
+ compose = new ContainerCompose(caseName, getTestClass(), description, beanContext);
+ return allParameters(description).stream()
+ .map(e -> {
+ TestCaseBeanContext context = beanContext.subContext();
+ register(e, context);
+ return context;
+ })
+ .filter(predicate)
+ .map(e -> {
+ try {
+ return new ShardingSphereITSubRunner(getTestClass().getJavaClass(), e);
+ } catch (InitializationError ex) {
+ throw new RuntimeException("Initialization Error", ex);
+ }
+ })
+ .collect(Collectors.toList());
+ }
+
+ private List<Runner> createCIRunners(final TestCaseSpec testCaseSpec) {
+ final Predicate<TestCaseBeanContext> predicate = createTestCaseParametersPredicate();
+ return allCIParameters(testCaseSpec).stream()
+ .map(e -> {
+ final TestCaseDescription description = TestCaseDescription.builder()
+ .sqlCommandType(testCaseSpec.sqlCommandType())
+ .executionMode(testCaseSpec.executionMode())
+ .adapter(e.getAdapter())
+ .database(e.getDatabaseType().getName())
+ .scenario(e.getScenario())
+ .build();
+ IntegrationTestCase testCase = e.getTestCaseContext().getTestCase();
+ final TestCaseBeanContext context = beanContext.subContext();
+ context.registerBean(ParameterizedArray.class, e);
+ context.registerBean(TestCaseDescription.class, description);
+ TestCaseParameters testCaseParameters;
+ if (e instanceof CaseParameterizedArray) {
+ testCaseParameters = new TestCaseParameters(e.toString(), e.getTestCaseContext().getParentPath(),
+ testCase.getSql(), null, getTestClass().getJavaClass(), testCase, null);
+ context.registerBean(CaseParameterizedArray.class, (CaseParameterizedArray) e);
+ } else {
+ AssertionParameterizedArray assertion = (AssertionParameterizedArray) e;
+ SQLExecuteType executeType = assertion.getSqlExecuteType();
+ testCaseParameters = new TestCaseParameters(e.toString(), e.getTestCaseContext().getParentPath(),
+ testCase.getSql(), executeType, getTestClass().getJavaClass(), testCase, assertion.getAssertion());
+ context.registerBean(AssertionParameterizedArray.class, assertion);
+ }
+ register(testCaseParameters, context);
+ return context;
+ })
+ .filter(predicate)
+ .map(e -> {
+ try {
+ return new ShardingSphereCISubRunner(getTestClass().getJavaClass(), e);
+ } catch (InitializationError initializationError) {
+ throw new RuntimeException(initializationError);
+ }
+ })
+ .collect(Collectors.toList());
+ }
+
+ private void register(final TestCaseParameters parameters, final TestCaseBeanContext context) {
+ context.registerBean(TestCaseParameters.class, parameters);
+ context.registerBeanByName("statement", parameters.getStatement());
+ context.registerBeanByName("parentPath", parameters.getParentPath());
+ context.registerBean(SQLExecuteType.class, parameters.getExecuteType());
+ context.registerBean(IntegrationTestCase.class, parameters.getTestCase());
+ context.registerBean(IntegrationTestCaseAssertion.class, parameters.getAssertion());
+ }
+
+ private Predicate<TestCaseBeanContext> createTestCaseParametersPredicate() {
+ ParameterFilter filter = getTestClass().getAnnotation(ParameterFilter.class);
+ final Predicate<TestCaseBeanContext> predicate;
+ if (Objects.nonNull(filter)) {
+ Class<? extends ParameterFilter.Filter> filtered = filter.filter();
+ try {
+ final ParameterFilter.Filter instance = filtered.newInstance();
+ predicate = instance::filter;
+ } catch (InstantiationException | IllegalAccessException ex) {
+ throw new RuntimeException(ex);
+ }
+ } else {
+ predicate = parameters -> true;
+ }
+ return predicate;
+ }
+
+ private Collection<ParameterizedArray> allCIParameters(final TestCaseSpec testCaseSpec) {
+ switch (testCaseSpec.executionMode()) {
+ case ADDITIONAL:
+ return IntegrationTestEnvironment.getInstance().isRunAdditionalTestCases()
+ ? ParameterizedArrayFactory.getAssertionParameterized(testCaseSpec.sqlCommandType())
+ : Collections.emptyList();
+ case BATCH:
+ return ParameterizedArrayFactory.getCaseParameterized(testCaseSpec.sqlCommandType());
+ default:
+ return ParameterizedArrayFactory.getAssertionParameterized(testCaseSpec.sqlCommandType());
+ }
+ }
+
+ @SneakyThrows
+ private Collection<TestCaseParameters> allParameters(final TestCaseDescription description) {
+ switch (description.getExecutionMode()) {
+ case ADDITIONAL:
+ return IntegrationTestEnvironment.getInstance().isRunAdditionalTestCases()
+ ? getAssertionParameters(getTestClass().getJavaClass(), description)
+ : Collections.emptyList();
+ case BATCH:
+ return getCaseParameters(getTestClass().getJavaClass(), description);
+ case SINGLE:
+ return getAssertionParameters(getTestClass().getJavaClass(), description);
+ default:
+ throw new NotSupportedException();
+ }
+ }
+
+ private Collection<TestCaseParameters> getAssertionParameters(final Class<?> klass, final TestCaseDescription description) {
+ final IntegrationTestCasesLoader testCasesLoader = IntegrationTestCasesLoader.getInstance();
+ return testCasesLoader.getTestCaseContexts(description.getSqlCommandType()).stream()
+ .filter(e -> assertThan(e.getTestCase().getDbTypes(), description.getDatabase()))
+ .filter(e -> assertThan(e.getTestCase().getScenarioTypes(), description.getScenario()))
+ .flatMap(e -> Arrays.stream(SQLExecuteType.values()).flatMap(type -> e.getTestCase().getAssertions().stream()
+ .map(a -> new TestCaseParameters(getCaseName(), e.getParentPath(), e.getTestCase().getSql(), type, klass, e.getTestCase(), a)))
+ ).collect(Collectors.toList());
+ }
+
+ private static boolean assertThan(final String target, final String expected) {
+ if (Strings.isNullOrEmpty(target)) {
+ return true;
+ }
+ if (target.indexOf(',') < 0) {
+ return target.equals(expected);
+ }
+ String[] scenarioTypes = target.split("\\s*,\\s*");
+ for (String each : scenarioTypes) {
+ if (each.equals(expected)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private Collection<TestCaseParameters> getCaseParameters(final Class<?> klass, final TestCaseDescription description) {
+ IntegrationTestCasesLoader testCasesLoader = IntegrationTestCasesLoader.getInstance();
+ return testCasesLoader.getTestCaseContexts(description.getSqlCommandType()).stream()
+ .filter(e -> assertThan(e.getTestCase().getDbTypes(), description.getDatabase()))
+ .filter(e -> assertThan(e.getTestCase().getScenarioTypes(), description.getScenario()))
+ .flatMap(e -> Arrays.stream(SQLExecuteType.values())
+ .map(type -> new TestCaseParameters(getCaseName(), e.getParentPath(), e.getTestCase().getSql(), type, klass, e.getTestCase(), null)))
+ .collect(Collectors.toList());
+ }
+
+ @Override
+ protected List<Runner> getChildren() {
+ return runners;
+ }
+
+ protected Statement withBeforeClasses(final Statement statement) {
+ if (getChildren().isEmpty()) {
+ return super.withBeforeClasses(statement);
+ }
+ return super.withBeforeClasses(new Statement() {
+ @Override
+ public void evaluate() throws Throwable {
+ beforeAllClasses();
+ statement.evaluate();
+ }
+ });
+ }
+
+ private void beforeAllClasses() throws Exception {
+ List<FrameworkMethod> methods = getTestClass().getAnnotatedMethods(BeforeAllCases.class);
+ List<Runner> children = getChildren();
+ if (!children.isEmpty()) {
+ final Runner runner = children.get(0);
+ final Object testInstance;
+ if (runner instanceof ShardingSphereITSubRunner) {
+ ShardingSphereITSubRunner itRunner = ((ShardingSphereITSubRunner) runner).copySelf();
+ testInstance = itRunner.createTestInstance();
+ compose.setInstance(testInstance);
+ compose.createContainers();
+ ((ShardingSphereITSubRunner) runner).autowired(testInstance);
+ compose.createInitializerAndExecute();
+ compose.start();
+ compose.waitUntilReady();
+ } else {
+ testInstance = ((ShardingSphereCISubRunner) runner).createTest();
+ }
+ methods.forEach(e -> {
+ e.getMethod().setAccessible(true);
+ try {
+ e.invokeExplosively(testInstance);
+ // CHECKSTYLE:OFF
+ } catch (Throwable throwable) {
+ // CHECKSTYLE:ON
+ throw new RuntimeException(throwable);
+ }
+ });
+ }
+ }
+
+ @Override
+ protected Statement withAfterClasses(final Statement statement) {
+ return super.withAfterClasses(new Statement() {
+ @Override
+ public void evaluate() throws Throwable {
+ statement.evaluate();
+ // shutdown docker containers.
+ if (Objects.nonNull(compose)) {
+ compose.close();
+ }
+ // missing @AfterAllCases
+ }
+ });
+ }
+
+}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/runner/TestCaseBeanContext.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/runner/TestCaseBeanContext.java
new file mode 100644
index 0000000..450e33e
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/runner/TestCaseBeanContext.java
@@ -0,0 +1,113 @@
+/*
+ * 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.shardingsphere.test.integration.junit.runner;
+
+import org.apache.curator.shaded.com.google.common.collect.Maps;
+
+import java.util.Map;
+import java.util.Objects;
+
+public class TestCaseBeanContext {
+
+ private final Map<Object, Object> classObjectMap = Maps.newConcurrentMap();
+
+ private final Map<Object, Object> parent;
+
+ public TestCaseBeanContext() {
+ parent = null;
+ }
+
+ private TestCaseBeanContext(final Map<Object, Object> parent) {
+ this.parent = parent;
+ }
+
+ /**
+ * Register the bean into context.
+ *
+ * @param <T> type
+ * @param identity key
+ * @param instance value
+ */
+ public <T> void registerBean(final Class<T> identity, final T instance) {
+ if (Objects.nonNull(instance)) {
+ classObjectMap.putIfAbsent(identity, instance);
+ }
+ }
+
+ /**
+ * Put the value with key into context.
+ *
+ * @param quality key
+ * @param value value
+ */
+ public void registerBeanByName(final String quality, final Object value) {
+ classObjectMap.putIfAbsent(quality, value);
+ }
+
+ /**
+ * Get the bean from context.
+ *
+ * @param <T> type
+ * @param klass class
+ * @return value
+ */
+ public <T> T getBean(final Class<T> klass) {
+ Object result = classObjectMap.get(klass);
+ if (Objects.isNull(result)) {
+ if (parent != null) {
+ return (T) parent.get(klass);
+ }
+ return null;
+ }
+ return (T) result;
+ }
+
+ /**
+ * Get the bean from context by name.
+ *
+ * @param <T> type
+ * @param name name
+ * @return value
+ */
+ public <T> T getBeanByName(final String name) {
+ Object result = classObjectMap.get(name);
+ if (Objects.isNull(result)) {
+ if (parent != null) {
+ return (T) parent.get(name);
+ }
+ return null;
+ }
+ return (T) result;
+ }
+
+ /**
+ * Create sub-context.
+ *
+ * @return Test case bean context
+ */
+ public TestCaseBeanContext subContext() {
+ return new TestCaseBeanContext(classObjectMap);
+ }
+
+ /**
+ * Clean up.
+ */
+ public void cleanup() {
+ classObjectMap.clear();
+ }
+}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/runner/TestCaseDescription.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/runner/TestCaseDescription.java
new file mode 100644
index 0000000..f19ba2e
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/runner/TestCaseDescription.java
@@ -0,0 +1,84 @@
+/*
+ * 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.shardingsphere.test.integration.junit.runner;
+
+import lombok.Builder;
+import lombok.Getter;
+import lombok.NonNull;
+import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.infra.database.type.DatabaseType;
+import org.apache.shardingsphere.infra.database.type.DatabaseTypeRegistry;
+import org.apache.shardingsphere.test.integration.cases.SQLCommandType;
+import org.apache.shardingsphere.test.integration.common.ExecutionMode;
+import org.apache.shardingsphere.test.integration.junit.annotation.ShardingSphereITStorageType;
+import org.apache.shardingsphere.test.integration.junit.annotation.TestCaseSpec;
+
+@Getter
+@Builder
+@RequiredArgsConstructor
+public class TestCaseDescription {
+
+ @NonNull
+ private final String database;
+
+ @NonNull
+ private final String scenario;
+
+ @NonNull
+ private final String adapter;
+
+ @NonNull
+ private final SQLCommandType sqlCommandType;
+
+ @NonNull
+ private final ExecutionMode executionMode;
+
+ /**
+ * Get storage type.
+ *
+ * @return storage type
+ */
+ public ShardingSphereITStorageType getStorageType() {
+ return ShardingSphereITStorageType.valueOf(database);
+ }
+
+ /**
+ * Get database type.
+ *
+ * @return database type
+ */
+ public DatabaseType getDatabaseType() {
+ return DatabaseTypeRegistry.getActualDatabaseType(database);
+ }
+
+ /**
+ * Create a instance builder from System properties.
+ *
+ * @param testCaseSpec test csae specification
+ * @return test instance
+ */
+ public static TestCaseDescriptionBuilder fromSystemProps(final TestCaseSpec testCaseSpec) {
+ return TestCaseDescription.builder()
+ .adapter(System.getProperty("it.adapter"))
+ .database(System.getProperty("it.database"))
+ .scenario(System.getProperty("it.scenario"))
+ .executionMode(testCaseSpec.executionMode())
+ .sqlCommandType(testCaseSpec.sqlCommandType());
+ }
+
+}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/ParallelRunnerExecutor.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/runner/parallel/ParallelRunnerExecutor.java
similarity index 89%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/ParallelRunnerExecutor.java
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/runner/parallel/ParallelRunnerExecutor.java
index c5d8577..9062b73 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/ParallelRunnerExecutor.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/runner/parallel/ParallelRunnerExecutor.java
@@ -15,9 +15,9 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.test.integration.engine.junit.parallel;
+package org.apache.shardingsphere.test.integration.junit.runner.parallel;
-import org.apache.shardingsphere.test.integration.engine.param.model.ParameterizedArray;
+import org.apache.shardingsphere.test.integration.junit.param.model.ParameterizedArray;
/**
* Parallel runner executor.
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/ParallelRunnerExecutorFactory.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/runner/parallel/ParallelRunnerExecutorFactory.java
similarity index 90%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/ParallelRunnerExecutorFactory.java
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/runner/parallel/ParallelRunnerExecutorFactory.java
index 6d6a234..3b531cc 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/ParallelRunnerExecutorFactory.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/runner/parallel/ParallelRunnerExecutorFactory.java
@@ -15,12 +15,12 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.test.integration.engine.junit.parallel;
+package org.apache.shardingsphere.test.integration.junit.runner.parallel;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.test.integration.engine.junit.parallel.annotaion.ParallelLevel;
-import org.apache.shardingsphere.test.integration.engine.junit.parallel.impl.CaseParallelRunnerExecutor;
-import org.apache.shardingsphere.test.integration.engine.junit.parallel.impl.ScenarioParallelRunnerExecutor;
+import org.apache.shardingsphere.test.integration.junit.runner.parallel.annotaion.ParallelLevel;
+import org.apache.shardingsphere.test.integration.junit.runner.parallel.impl.CaseParallelRunnerExecutor;
+import org.apache.shardingsphere.test.integration.junit.runner.parallel.impl.ScenarioParallelRunnerExecutor;
import java.util.Collection;
import java.util.Map;
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/ParallelRunnerScheduler.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/runner/parallel/ParallelRunnerScheduler.java
similarity index 85%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/ParallelRunnerScheduler.java
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/runner/parallel/ParallelRunnerScheduler.java
index 7135665..9f410c7 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/ParallelRunnerScheduler.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/runner/parallel/ParallelRunnerScheduler.java
@@ -15,12 +15,12 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.test.integration.engine.junit.parallel;
+package org.apache.shardingsphere.test.integration.junit.runner.parallel;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.test.integration.engine.junit.parallel.annotaion.ParallelLevel;
-import org.apache.shardingsphere.test.integration.engine.param.RunnerParameters;
-import org.apache.shardingsphere.test.integration.engine.param.model.ParameterizedArray;
+import org.apache.shardingsphere.test.integration.junit.runner.parallel.annotaion.ParallelLevel;
+import org.apache.shardingsphere.test.integration.junit.param.RunnerParameters;
+import org.apache.shardingsphere.test.integration.junit.param.model.ParameterizedArray;
import org.junit.runners.model.RunnerScheduler;
/**
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/annotaion/ParallelLevel.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/runner/parallel/annotaion/ParallelLevel.java
similarity index 93%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/annotaion/ParallelLevel.java
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/runner/parallel/annotaion/ParallelLevel.java
index 55e4d84..2c33d82 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/annotaion/ParallelLevel.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/runner/parallel/annotaion/ParallelLevel.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.test.integration.engine.junit.parallel.annotaion;
+package org.apache.shardingsphere.test.integration.junit.runner.parallel.annotaion;
/**
* Parallel level.
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/annotaion/ParallelRuntimeStrategy.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/runner/parallel/annotaion/ParallelRuntimeStrategy.java
similarity index 95%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/annotaion/ParallelRuntimeStrategy.java
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/runner/parallel/annotaion/ParallelRuntimeStrategy.java
index b7e118d..e63bec2 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/annotaion/ParallelRuntimeStrategy.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/runner/parallel/annotaion/ParallelRuntimeStrategy.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.test.integration.engine.junit.parallel.annotaion;
+package org.apache.shardingsphere.test.integration.junit.runner.parallel.annotaion;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/impl/CaseParallelRunnerExecutor.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/runner/parallel/impl/CaseParallelRunnerExecutor.java
similarity index 90%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/impl/CaseParallelRunnerExecutor.java
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/runner/parallel/impl/CaseParallelRunnerExecutor.java
index 25ec829..e52afed 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/impl/CaseParallelRunnerExecutor.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/runner/parallel/impl/CaseParallelRunnerExecutor.java
@@ -15,11 +15,11 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.test.integration.engine.junit.parallel.impl;
+package org.apache.shardingsphere.test.integration.junit.runner.parallel.impl;
import org.apache.shardingsphere.infra.executor.kernel.thread.ExecutorServiceManager;
-import org.apache.shardingsphere.test.integration.engine.junit.parallel.ParallelRunnerExecutor;
-import org.apache.shardingsphere.test.integration.engine.param.model.ParameterizedArray;
+import org.apache.shardingsphere.test.integration.junit.runner.parallel.ParallelRunnerExecutor;
+import org.apache.shardingsphere.test.integration.junit.param.model.ParameterizedArray;
import java.util.Collection;
import java.util.LinkedList;
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/impl/ScenarioParallelRunnerExecutor.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/runner/parallel/impl/ScenarioParallelRunnerExecutor.java
similarity index 94%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/impl/ScenarioParallelRunnerExecutor.java
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/runner/parallel/impl/ScenarioParallelRunnerExecutor.java
index 41e0936..7a4ab84 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/parallel/impl/ScenarioParallelRunnerExecutor.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/runner/parallel/impl/ScenarioParallelRunnerExecutor.java
@@ -15,12 +15,12 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.test.integration.engine.junit.parallel.impl;
+package org.apache.shardingsphere.test.integration.junit.runner.parallel.impl;
import lombok.EqualsAndHashCode;
import org.apache.shardingsphere.infra.executor.kernel.thread.ExecutorServiceManager;
-import org.apache.shardingsphere.test.integration.engine.junit.parallel.ParallelRunnerExecutor;
-import org.apache.shardingsphere.test.integration.engine.param.model.ParameterizedArray;
+import org.apache.shardingsphere.test.integration.junit.runner.parallel.ParallelRunnerExecutor;
+import org.apache.shardingsphere.test.integration.junit.param.model.ParameterizedArray;
import java.util.Collection;
import java.util.LinkedList;
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/pom.xml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/pom.xml
index 2c7862a..917c180 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/pom.xml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/pom.xml
@@ -25,25 +25,15 @@
</parent>
<artifactId>shardingsphere-integration-test-suite</artifactId>
<name>${project.artifactId}</name>
-
+
<dependencies>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-jdbc-core</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-proxy-bootstrap</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-integration-test-fixture</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
</dependency>
-
+
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
@@ -75,202 +65,12 @@
<artifactId>commons-dbcp2</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.testcontainers</groupId>
+ <artifactId>testcontainers</artifactId>
+ </dependency>
</dependencies>
- <profiles>
- <profile>
- <id>it.env.docker</id>
- <properties>
- <it.env>DOCKER</it.env>
- </properties>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <configuration>
- <appendAssemblyId>false</appendAssemblyId>
- <descriptors>
- <descriptor>src/test/assembly/shardingsphere-proxy-assembly.xml</descriptor>
- </descriptors>
- </configuration>
- <executions>
- <execution>
- <id>assembly</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>com.spotify</groupId>
- <artifactId>dockerfile-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>shardingsphere-proxy-bin</id>
- <goals>
- <goal>build</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <repository>apache/shardingsphere-proxy-test</repository>
- <tag>${project.version}</tag>
- <tag>latest</tag>
- <buildArgs>
- <APP_NAME>${project.build.finalName}</APP_NAME>
- </buildArgs>
- </configuration>
- </plugin>
- <plugin>
- <groupId>com.dkanejs.maven.plugins</groupId>
- <artifactId>docker-compose-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>db-up</id>
- <phase>pre-integration-test</phase>
- <goals>
- <goal>up</goal>
- </goals>
- <configuration>
- <composeFile>${project.basedir}/src/test/resources/docker/db/docker-compose.yml</composeFile>
- <detachedMode>true</detachedMode>
- </configuration>
- </execution>
- <execution>
- <id>db-down</id>
- <phase>post-integration-test</phase>
- <goals>
- <goal>down</goal>
- </goals>
- <configuration>
- <composeFile>${project.basedir}/src/test/resources/docker/db/docker-compose.yml</composeFile>
- <removeVolumes>true</removeVolumes>
- </configuration>
- </execution>
-
- <execution>
- <id>tbl-up</id>
- <phase>pre-integration-test</phase>
- <goals>
- <goal>up</goal>
- </goals>
- <configuration>
- <composeFile>${project.basedir}/src/test/resources/docker/tbl/docker-compose.yml</composeFile>
- <detachedMode>true</detachedMode>
- </configuration>
- </execution>
- <execution>
- <id>tbl-down</id>
- <phase>post-integration-test</phase>
- <goals>
- <goal>down</goal>
- </goals>
- <configuration>
- <composeFile>${project.basedir}/src/test/resources/docker/tbl/docker-compose.yml</composeFile>
- <removeVolumes>true</removeVolumes>
- </configuration>
- </execution>
-
- <execution>
- <id>read-write-splitting-up</id>
- <phase>pre-integration-test</phase>
- <goals>
- <goal>up</goal>
- </goals>
- <configuration>
- <composeFile>${project.basedir}/src/test/resources/docker/read_write_splitting/docker-compose.yml</composeFile>
- <detachedMode>true</detachedMode>
- </configuration>
- </execution>
- <execution>
- <id>read-write-splitting-down</id>
- <phase>post-integration-test</phase>
- <goals>
- <goal>down</goal>
- </goals>
- <configuration>
- <composeFile>${project.basedir}/src/test/resources/docker/read_write_splitting/docker-compose.yml</composeFile>
- <removeVolumes>true</removeVolumes>
- </configuration>
- </execution>
-
- <execution>
- <id>dbtbl-with-read-write-splitting-up</id>
- <phase>pre-integration-test</phase>
- <goals>
- <goal>up</goal>
- </goals>
- <configuration>
- <composeFile>${project.basedir}/src/test/resources/docker/dbtbl_with_read_write_splitting/docker-compose.yml</composeFile>
- <detachedMode>true</detachedMode>
- </configuration>
- </execution>
- <execution>
- <id>dbtbl-with-read-write-splitting-down</id>
- <phase>post-integration-test</phase>
- <goals>
- <goal>down</goal>
- </goals>
- <configuration>
- <composeFile>${project.basedir}/src/test/resources/docker/dbtbl_with_read_write_splitting/docker-compose.yml</composeFile>
- <removeVolumes>true</removeVolumes>
- </configuration>
- </execution>
-
- <execution>
- <id>encrypt-up</id>
- <phase>pre-integration-test</phase>
- <goals>
- <goal>up</goal>
- </goals>
- <configuration>
- <composeFile>${project.basedir}/src/test/resources/docker/encrypt/docker-compose.yml</composeFile>
- <detachedMode>true</detachedMode>
- </configuration>
- </execution>
- <execution>
- <id>encrypt-down</id>
- <phase>post-integration-test</phase>
- <goals>
- <goal>down</goal>
- </goals>
- <configuration>
- <composeFile>${project.basedir}/src/test/resources/docker/encrypt/docker-compose.yml</composeFile>
- <removeVolumes>true</removeVolumes>
- </configuration>
- </execution>
-
- <execution>
- <id>dbtbl-with-read-write-splitting-and-encrypt-up</id>
- <phase>pre-integration-test</phase>
- <goals>
- <goal>up</goal>
- </goals>
- <configuration>
- <composeFile>${project.basedir}/src/test/resources/docker/dbtbl_with_read_write_splitting_and_encrypt/docker-compose.yml</composeFile>
- <detachedMode>true</detachedMode>
- </configuration>
- </execution>
- <execution>
- <id>dbtbl-with-read-write-splitting-and-encrypt-down</id>
- <phase>post-integration-test</phase>
- <goals>
- <goal>down</goal>
- </goals>
- <configuration>
- <composeFile>${project.basedir}/src/test/resources/docker/dbtbl_with_read_write_splitting_and_encrypt/docker-compose.yml</composeFile>
- <removeVolumes>true</removeVolumes>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-
<build>
<plugins>
<plugin>
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/BaseIT.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/BaseIT.java
deleted file mode 100644
index 6e07d6c..0000000
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/BaseIT.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * 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.shardingsphere.test.integration.engine.it;
-
-import lombok.AccessLevel;
-import lombok.Getter;
-import org.apache.shardingsphere.driver.api.yaml.YamlShardingSphereDataSourceFactory;
-import org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource;
-import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.test.integration.engine.junit.ITParameterized;
-import org.apache.shardingsphere.test.integration.env.EnvironmentPath;
-import org.apache.shardingsphere.test.integration.env.EnvironmentType;
-import org.apache.shardingsphere.test.integration.env.IntegrationTestEnvironment;
-import org.apache.shardingsphere.test.integration.env.database.DatabaseEnvironmentManager;
-import org.apache.shardingsphere.test.integration.env.datasource.builder.ActualDataSourceBuilder;
-import org.apache.shardingsphere.test.integration.env.datasource.builder.ProxyDataSourceBuilder;
-import org.junit.After;
-import org.junit.BeforeClass;
-import org.junit.runner.RunWith;
-
-import javax.sql.DataSource;
-import javax.xml.bind.JAXBException;
-import java.io.File;
-import java.io.IOException;
-import java.sql.SQLException;
-import java.util.Map;
-import java.util.TimeZone;
-
-@RunWith(ITParameterized.class)
-@Getter(AccessLevel.PROTECTED)
-public abstract class BaseIT {
-
- public static final String NOT_VERIFY_FLAG = "NOT_VERIFY";
-
- private final String adapter;
-
- private final String scenario;
-
- private final DatabaseType databaseType;
-
- private final Map<String, DataSource> actualDataSources;
-
- private DataSource targetDataSource;
-
- static {
- TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
- }
-
- BaseIT(final String adapter, final String scenario, final DatabaseType databaseType) throws IOException, JAXBException, SQLException {
- this.adapter = adapter;
- this.scenario = scenario;
- this.databaseType = databaseType;
- actualDataSources = ActualDataSourceBuilder.createActualDataSources(scenario, databaseType);
- targetDataSource = createTargetDataSource();
- // TODO maybe use @AfterClass, but targetDataSource should be static
- Runtime.getRuntime().addShutdownHook(new Thread(() -> {
- if (targetDataSource instanceof ShardingSphereDataSource) {
- closeTargetDataSource();
- }
- }));
- }
-
- private DataSource createTargetDataSource() throws SQLException, IOException {
- if ("proxy".equalsIgnoreCase(adapter)) {
- return ProxyDataSourceBuilder.build(scenario, databaseType, IntegrationTestEnvironment.getInstance().getProxyEnvironments().get(scenario));
- }
- return YamlShardingSphereDataSourceFactory.createDataSource(actualDataSources, new File(EnvironmentPath.getRulesConfigurationFile(scenario)));
- }
-
- protected final void resetTargetDataSource() throws IOException, SQLException {
- targetDataSource = createTargetDataSource();
- }
-
- private void closeTargetDataSource() {
- ((ShardingSphereDataSource) targetDataSource).getDataSourceMap().values().forEach(dataSource -> {
- try {
- ((AutoCloseable) dataSource).close();
- //CHECKSTYLE:OFF
- } catch (final Exception ignored) {
- //CHECKSTYLE:ON
- }
- });
- }
-
- @BeforeClass
- public static void executeInitSQLs() throws IOException, JAXBException, SQLException {
- if (EnvironmentType.DOCKER != IntegrationTestEnvironment.getInstance().getEnvType()) {
- DatabaseEnvironmentManager.executeInitSQLs();
- }
- }
-
- @After
- public final void tearDown() {
- if (targetDataSource instanceof ShardingSphereDataSource) {
- ((ShardingSphereDataSource) targetDataSource).getMetaDataContexts().getExecutorEngine().close();
- }
- }
-}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/BaseITCase.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/BaseITCase.java
new file mode 100644
index 0000000..afc45b1
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/BaseITCase.java
@@ -0,0 +1,131 @@
+/*
+ * 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.shardingsphere.test.integration.engine.it;
+
+import lombok.AccessLevel;
+import lombok.Getter;
+import org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource;
+import org.apache.shardingsphere.test.integration.cases.assertion.IntegrationTestCaseAssertion;
+import org.apache.shardingsphere.test.integration.cases.value.SQLValue;
+import org.apache.shardingsphere.test.integration.common.SQLExecuteType;
+import org.apache.shardingsphere.test.integration.env.EnvironmentType;
+import org.apache.shardingsphere.test.integration.env.IntegrationTestEnvironment;
+import org.apache.shardingsphere.test.integration.env.database.DatabaseEnvironmentManager;
+import org.apache.shardingsphere.test.integration.env.dataset.DataSetEnvironmentManager;
+import org.apache.shardingsphere.test.integration.junit.annotation.ContainerInitializer;
+import org.apache.shardingsphere.test.integration.junit.annotation.ContainerType;
+import org.apache.shardingsphere.test.integration.junit.annotation.ShardingSphereITInject;
+import org.apache.shardingsphere.test.integration.junit.annotation.OnContainer;
+import org.apache.shardingsphere.test.integration.junit.container.ShardingSphereAdapterContainer;
+import org.apache.shardingsphere.test.integration.junit.container.ShardingSphereStorageContainer;
+import org.apache.shardingsphere.test.integration.junit.runner.ShardingSphereRunner;
+import org.apache.shardingsphere.test.integration.junit.runner.TestCaseDescription;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+
+import javax.sql.DataSource;
+import javax.xml.bind.JAXBException;
+import java.io.IOException;
+import java.sql.SQLException;
+import java.text.ParseException;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import java.util.TimeZone;
+import java.util.stream.Collectors;
+
+@Getter(AccessLevel.PROTECTED)
+@RunWith(ShardingSphereRunner.class)
+public abstract class BaseITCase {
+
+ public static final String NOT_VERIFY_FLAG = "NOT_VERIFY";
+
+ @Getter
+ @OnContainer(name = "adapter")
+ private ShardingSphereAdapterContainer proxy;
+
+ @Getter
+ @OnContainer(name = "storage", type = ContainerType.STORAGE, hostName = "mysql.db.host")
+ private ShardingSphereStorageContainer storage;
+
+ @ShardingSphereITInject
+ private IntegrationTestCaseAssertion assertion;
+
+ @ShardingSphereITInject
+ private DataSetEnvironmentManager dataSetEnvironmentManager;
+
+ @ShardingSphereITInject
+ private String statement;
+
+ @Getter
+ @ShardingSphereITInject
+ private TestCaseDescription description;
+
+ @ShardingSphereITInject
+ private SQLExecuteType sqlExecuteType;
+
+ @ShardingSphereITInject
+ private String parentPath;
+
+ private DataSource dataSource;
+
+ static {
+ TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
+ }
+
+ @ContainerInitializer
+ protected void initialize() {
+ if (Objects.nonNull(proxy) && Objects.nonNull(storage)) {
+ proxy.dependsOn(storage);
+ }
+ }
+
+ @Before
+ public void createDataSource() {
+ dataSource = proxy.getDataSource();
+ }
+
+ protected DataSource getTargetDataSource() {
+ return dataSource;
+ }
+
+ protected String getStatement() throws ParseException {
+ return sqlExecuteType == SQLExecuteType.Literal ? getLiteralSQL(statement) : statement;
+ }
+
+ protected String getLiteralSQL(final String sql) throws ParseException {
+ List<Object> parameters = null == getAssertion() ? Collections.emptyList() : getAssertion().getSQLValues().stream().map(SQLValue::toString).collect(Collectors.toList());
+ return parameters.isEmpty() ? sql : String.format(sql.replace("%", "$").replace("?", "%s"), parameters.toArray()).replace("$", "%").replace("%%", "%").replace("'%'", "'%%'");
+ }
+
+ @BeforeClass
+ public static void executeInitSQLs() throws IOException, JAXBException, SQLException {
+ if (EnvironmentType.DOCKER != IntegrationTestEnvironment.getInstance().getEnvType()) {
+ DatabaseEnvironmentManager.executeInitSQLs();
+ }
+ }
+
+ @After
+ public final void tearDown() {
+ if (getTargetDataSource() instanceof ShardingSphereDataSource) {
+ ((ShardingSphereDataSource) getTargetDataSource()).getMetaDataContexts().getExecutorEngine().close();
+ }
+ }
+}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/BatchIT.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/BatchITCase.java
similarity index 82%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/BatchIT.java
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/BatchITCase.java
index c118d54..e3715e9 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/BatchIT.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/BatchITCase.java
@@ -17,20 +17,21 @@
package org.apache.shardingsphere.test.integration.engine.it;
+import com.google.common.collect.Lists;
import lombok.AccessLevel;
import lombok.Getter;
import org.apache.shardingsphere.infra.datanode.DataNode;
import org.apache.shardingsphere.sharding.algorithm.sharding.inline.InlineExpressionParser;
-import org.apache.shardingsphere.test.integration.cases.IntegrationTestCaseContext;
+import org.apache.shardingsphere.test.integration.cases.assertion.IntegrationTestCase;
import org.apache.shardingsphere.test.integration.cases.assertion.IntegrationTestCaseAssertion;
import org.apache.shardingsphere.test.integration.cases.dataset.DataSet;
import org.apache.shardingsphere.test.integration.cases.dataset.DataSetLoader;
import org.apache.shardingsphere.test.integration.cases.dataset.metadata.DataSetColumn;
import org.apache.shardingsphere.test.integration.cases.dataset.metadata.DataSetMetadata;
import org.apache.shardingsphere.test.integration.cases.dataset.row.DataSetRow;
-import org.apache.shardingsphere.test.integration.engine.param.model.CaseParameterizedArray;
import org.apache.shardingsphere.test.integration.env.EnvironmentPath;
import org.apache.shardingsphere.test.integration.env.dataset.DataSetEnvironmentManager;
+import org.apache.shardingsphere.test.integration.junit.annotation.ShardingSphereITInject;
import org.junit.After;
import org.junit.Before;
@@ -55,30 +56,29 @@ import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
@Getter(AccessLevel.PROTECTED)
-public abstract class BatchIT extends BaseIT {
+public abstract class BatchITCase extends BaseITCase {
+
+ @Getter
+ @ShardingSphereITInject
+ private IntegrationTestCase testCase;
- private final IntegrationTestCaseContext testCaseContext;
+ private Collection<DataSet> dataSets;
- private final String sql;
+ private Collection<DataSet> dataSet = Lists.newArrayList();
- private final Collection<DataSet> dataSets;
-
- @Getter(AccessLevel.NONE)
- private final DataSetEnvironmentManager dataSetEnvironmentManager;
+ private DataSetEnvironmentManager dataSetEnvironmentManager;
- protected BatchIT(final CaseParameterizedArray parameterizedArray) throws IOException, JAXBException, SQLException {
- super(parameterizedArray.getAdapter(), parameterizedArray.getScenario(), parameterizedArray.getDatabaseType());
- this.testCaseContext = parameterizedArray.getTestCaseContext();
- this.sql = parameterizedArray.getTestCaseContext().getTestCase().getSql();
+ @Before
+ public void setup() throws IOException, JAXBException {
dataSets = new LinkedList<>();
- for (IntegrationTestCaseAssertion each : testCaseContext.getTestCase().getAssertions()) {
- dataSets.add(DataSetLoader.load(testCaseContext.getParentPath(), parameterizedArray.getScenario(), parameterizedArray.getDatabaseType(), each.getExpectedDataFile()));
+ for (IntegrationTestCaseAssertion each : testCase.getAssertions()) {
+ dataSets.add(DataSetLoader.load(getParentPath(), getDescription().getScenario(), getDescription().getDatabaseType(), each.getExpectedDataFile()));
}
- dataSetEnvironmentManager = new DataSetEnvironmentManager(EnvironmentPath.getDataSetFile(parameterizedArray.getScenario()), getActualDataSources());
+ dataSetEnvironmentManager = new DataSetEnvironmentManager(EnvironmentPath.getDataSetFile(getDescription().getScenario()), getStorage().getDataSourceMap());
}
@Before
- public void fillData() throws SQLException, ParseException {
+ public void fillData() throws SQLException, ParseException, InterruptedException {
dataSetEnvironmentManager.fillData();
}
@@ -93,7 +93,7 @@ public abstract class BatchIT extends BaseIT {
DataSetMetadata expectedDataSetMetadata = expected.getMetadataList().get(0);
for (String each : new InlineExpressionParser(expectedDataSetMetadata.getDataNodes()).splitAndEvaluate()) {
DataNode dataNode = new DataNode(each);
- try (Connection connection = getActualDataSources().get(dataNode.getDataSourceName()).getConnection();
+ try (Connection connection = getStorage().getDataSourceMap().get(dataNode.getDataSourceName()).getConnection();
PreparedStatement preparedStatement = connection.prepareStatement(String.format("SELECT * FROM %s ORDER BY 1", dataNode.getTableName()))) {
assertDataSet(preparedStatement, expected.findRows(dataNode), expectedDataSetMetadata);
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/SingleIT.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/SingleIT.java
deleted file mode 100644
index 62f4b44..0000000
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/SingleIT.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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.shardingsphere.test.integration.engine.it;
-
-import lombok.AccessLevel;
-import lombok.Getter;
-import org.apache.shardingsphere.test.integration.cases.assertion.IntegrationTestCaseAssertion;
-import org.apache.shardingsphere.test.integration.engine.param.SQLExecuteType;
-import org.apache.shardingsphere.test.integration.cases.value.SQLValue;
-import org.apache.shardingsphere.test.integration.cases.dataset.DataSet;
-import org.apache.shardingsphere.test.integration.cases.dataset.DataSetLoader;
-import org.apache.shardingsphere.test.integration.engine.junit.ITWatcher;
-import org.apache.shardingsphere.test.integration.engine.param.model.AssertionParameterizedArray;
-import org.junit.Rule;
-
-import javax.xml.bind.JAXBException;
-import java.io.IOException;
-import java.sql.SQLException;
-import java.text.ParseException;
-import java.util.Collections;
-import java.util.List;
-import java.util.stream.Collectors;
-
-@Getter(AccessLevel.PROTECTED)
-public abstract class SingleIT extends BaseIT {
-
- @Rule
- public ITWatcher watcher = new ITWatcher();
-
- private final String caseIdentifier;
-
- private final IntegrationTestCaseAssertion assertion;
-
- private final SQLExecuteType sqlExecuteType;
-
- private final DataSet dataSet;
-
- private final String sql;
-
- protected SingleIT(final AssertionParameterizedArray parameterizedArray) throws IOException, JAXBException, SQLException, ParseException {
- super(parameterizedArray.getAdapter(), parameterizedArray.getScenario(), parameterizedArray.getDatabaseType());
- String sql = parameterizedArray.getTestCaseContext().getTestCase().getSql();
- caseIdentifier = sql;
- this.assertion = parameterizedArray.getAssertion();
- this.sqlExecuteType = parameterizedArray.getSqlExecuteType();
- this.sql = sqlExecuteType == SQLExecuteType.Literal ? getLiteralSQL(sql) : sql;
- dataSet = null == assertion ? null : DataSetLoader.load(parameterizedArray.getTestCaseContext().getParentPath(), parameterizedArray.getScenario(),
- parameterizedArray.getDatabaseType(), assertion.getExpectedDataFile());
- }
-
- private String getLiteralSQL(final String sql) throws ParseException {
- List<Object> parameters = null == assertion ? Collections.emptyList() : assertion.getSQLValues().stream().map(SQLValue::toString).collect(Collectors.toList());
- return parameters.isEmpty() ? sql : String.format(sql.replace("%", "$").replace("?", "%s"), parameters.toArray()).replace("$", "%").replace("%%", "%").replace("'%'", "'%%'");
- }
-}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/SingleITCase.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/SingleITCase.java
new file mode 100644
index 0000000..3b99834
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/SingleITCase.java
@@ -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.
+ */
+
+package org.apache.shardingsphere.test.integration.engine.it;
+
+import lombok.AccessLevel;
+import lombok.Getter;
+import lombok.SneakyThrows;
+import org.apache.shardingsphere.test.integration.cases.dataset.DataSet;
+import org.apache.shardingsphere.test.integration.cases.dataset.DataSetLoader;
+import org.apache.shardingsphere.test.integration.engine.junit.ITWatcher;
+import org.junit.Before;
+import org.junit.Rule;
+
+@Getter(AccessLevel.PROTECTED)
+public abstract class SingleITCase extends BaseITCase {
+
+ @Rule
+ public ITWatcher watcher = new ITWatcher();
+
+ private DataSet dataSet;
+
+ @Before
+ @SneakyThrows
+ public void setup() {
+ dataSet = null == getAssertion() ? null : DataSetLoader.load(getParentPath(), getDescription().getScenario(), getDescription().getDatabaseType(), getAssertion().getExpectedDataFile());
+ }
+
+}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dal/BaseDALIT.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dal/BaseDALIT.java
index 4499396..661c396 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dal/BaseDALIT.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dal/BaseDALIT.java
@@ -20,16 +20,12 @@ package org.apache.shardingsphere.test.integration.engine.it.dal;
import org.apache.shardingsphere.test.integration.cases.dataset.metadata.DataSetColumn;
import org.apache.shardingsphere.test.integration.cases.dataset.metadata.DataSetMetadata;
import org.apache.shardingsphere.test.integration.cases.dataset.row.DataSetRow;
-import org.apache.shardingsphere.test.integration.engine.it.SingleIT;
-import org.apache.shardingsphere.test.integration.engine.param.model.AssertionParameterizedArray;
+import org.apache.shardingsphere.test.integration.engine.it.SingleITCase;
-import javax.xml.bind.JAXBException;
-import java.io.IOException;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Types;
-import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.LinkedList;
@@ -39,11 +35,7 @@ import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
-public abstract class BaseDALIT extends SingleIT {
-
- protected BaseDALIT(final AssertionParameterizedArray parameterizedArray) throws IOException, JAXBException, SQLException, ParseException {
- super(parameterizedArray);
- }
+public abstract class BaseDALIT extends SingleITCase {
protected final void assertResultSet(final ResultSet resultSet) throws SQLException {
assertMetaData(resultSet.getMetaData(), getExpectedColumns());
@@ -60,7 +52,7 @@ public abstract class BaseDALIT extends SingleIT {
private void assertMetaData(final ResultSetMetaData actual, final Collection<DataSetColumn> expected) throws SQLException {
// TODO Fix shadow
- if ("shadow".equals(getScenario())) {
+ if ("shadow".equals(getDescription().getScenario())) {
return;
}
assertThat(actual.getColumnCount(), is(expected.size()));
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dal/GeneralDALIT.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dal/GeneralDALIT.java
index 154daf1..ed9b35a 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dal/GeneralDALIT.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dal/GeneralDALIT.java
@@ -18,53 +18,40 @@
package org.apache.shardingsphere.test.integration.engine.it.dal;
import org.apache.shardingsphere.test.integration.cases.SQLCommandType;
-import org.apache.shardingsphere.test.integration.engine.junit.parallel.annotaion.ParallelLevel;
-import org.apache.shardingsphere.test.integration.engine.junit.parallel.annotaion.ParallelRuntimeStrategy;
-import org.apache.shardingsphere.test.integration.engine.param.ParameterizedArrayFactory;
-import org.apache.shardingsphere.test.integration.engine.param.SQLExecuteType;
-import org.apache.shardingsphere.test.integration.engine.param.model.AssertionParameterizedArray;
-import org.apache.shardingsphere.test.integration.engine.param.model.ParameterizedArray;
+import org.apache.shardingsphere.test.integration.common.SQLExecuteType;
+import org.apache.shardingsphere.test.integration.junit.annotation.ParameterFilter;
+import org.apache.shardingsphere.test.integration.junit.annotation.TestCaseSpec;
+import org.apache.shardingsphere.test.integration.junit.param.TestCaseParameters;
+import org.apache.shardingsphere.test.integration.junit.runner.TestCaseBeanContext;
+import org.apache.shardingsphere.test.integration.junit.runner.TestCaseDescription;
+import org.apache.shardingsphere.test.integration.junit.runner.parallel.annotaion.ParallelLevel;
+import org.apache.shardingsphere.test.integration.junit.runner.parallel.annotaion.ParallelRuntimeStrategy;
import org.junit.Test;
-import org.junit.runners.Parameterized.Parameters;
-import javax.xml.bind.JAXBException;
-import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.ParseException;
-import java.util.Collection;
-import java.util.stream.Collectors;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
+@ParameterFilter(filter = GeneralDALIT.Filter.class)
+@TestCaseSpec(sqlCommandType = SQLCommandType.DAL)
@ParallelRuntimeStrategy(ParallelLevel.SCENARIO)
public final class GeneralDALIT extends BaseDALIT {
- public GeneralDALIT(final AssertionParameterizedArray parameterizedArray) throws IOException, JAXBException, SQLException, ParseException {
- super(parameterizedArray);
- }
-
- @Parameters(name = "{0}")
- public static Collection<Object[]> getParameters() {
- return ParameterizedArrayFactory.getAssertionParameterizedArray(SQLCommandType.DAL).stream()
- .filter(each -> "proxy".equals(((ParameterizedArray) each[0]).getAdapter())
- && each[0] instanceof AssertionParameterizedArray && SQLExecuteType.Literal == ((AssertionParameterizedArray) each[0]).getSqlExecuteType()).collect(Collectors.toList());
- }
-
- @SuppressWarnings("JUnitTestMethodWithNoAssertions")
@Test
- public void assertExecute() throws SQLException {
+ public void assertExecute() throws SQLException, ParseException {
try (Connection connection = getTargetDataSource().getConnection()) {
assertExecuteForStatement(connection);
}
}
- private void assertExecuteForStatement(final Connection connection) throws SQLException {
+ private void assertExecuteForStatement(final Connection connection) throws SQLException, ParseException {
try (Statement statement = connection.createStatement()) {
- boolean isQuery = statement.execute(getSql());
+ boolean isQuery = statement.execute(getStatement());
if (isQuery) {
try (ResultSet resultSet = statement.getResultSet()) {
assertResultSet(resultSet);
@@ -74,4 +61,12 @@ public final class GeneralDALIT extends BaseDALIT {
}
}
}
+
+ public static class Filter implements ParameterFilter.Filter {
+ @Override
+ public boolean filter(final TestCaseBeanContext context) {
+ return context.getBean(TestCaseParameters.class).getExecuteType() == SQLExecuteType.Literal
+ && "proxy".equals(context.getBean(TestCaseDescription.class).getAdapter());
+ }
+ }
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dcl/BaseDCLIT.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dcl/BaseDCLIT.java
index 8ab251c..dcef5f8 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dcl/BaseDCLIT.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dcl/BaseDCLIT.java
@@ -17,81 +17,27 @@
package org.apache.shardingsphere.test.integration.engine.it.dcl;
-import org.apache.shardingsphere.infra.database.metadata.DataSourceMetaData;
-import org.apache.shardingsphere.infra.database.metadata.MemorizedDataSourceMetaData;
-import org.apache.shardingsphere.test.integration.engine.it.SingleIT;
-import org.apache.shardingsphere.test.integration.engine.param.model.AssertionParameterizedArray;
+import org.apache.shardingsphere.test.integration.engine.it.SingleITCase;
import org.apache.shardingsphere.test.integration.env.EnvironmentPath;
import org.apache.shardingsphere.test.integration.env.authority.AuthorityEnvironmentManager;
import org.junit.After;
import org.junit.Before;
-import javax.sql.DataSource;
import javax.xml.bind.JAXBException;
import java.io.IOException;
-import java.sql.Connection;
-import java.sql.DatabaseMetaData;
import java.sql.SQLException;
-import java.text.ParseException;
-import java.util.Collection;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Objects;
-public abstract class BaseDCLIT extends SingleIT {
+public abstract class BaseDCLIT extends SingleITCase {
- private final AuthorityEnvironmentManager authorityEnvironmentManager;
-
- protected BaseDCLIT(final AssertionParameterizedArray parameterizedArray) throws IOException, JAXBException, SQLException, ParseException {
- super(parameterizedArray);
- authorityEnvironmentManager = new AuthorityEnvironmentManager(
- EnvironmentPath.getAuthorityFile(parameterizedArray.getScenario()), null == getActualDataSources() ? null : createInstanceDataSourceMap(), parameterizedArray.getDatabaseType());
- }
-
- private Map<String, DataSource> createInstanceDataSourceMap() throws SQLException {
- return "shadow".equals(getScenario()) ? getActualDataSources() : getShardingInstanceDataSourceMap();
- }
-
- private Map<String, DataSource> getShardingInstanceDataSourceMap() throws SQLException {
- Map<String, DataSource> result = new LinkedHashMap<>(getActualDataSources().size(), 1);
- Map<String, DataSourceMetaData> dataSourceMetaDataMap = getDataSourceMetaDataMap();
- for (Entry<String, DataSource> entry : getActualDataSources().entrySet()) {
- if (!isExisted(entry.getKey(), result.keySet(), dataSourceMetaDataMap)) {
- result.put(entry.getKey(), entry.getValue());
- }
- }
- return result;
- }
-
- private Map<String, DataSourceMetaData> getDataSourceMetaDataMap() throws SQLException {
- Map<String, DataSourceMetaData> result = new LinkedHashMap<>(getActualDataSources().size(), 1);
- for (Entry<String, DataSource> entry : getActualDataSources().entrySet()) {
- try (Connection connection = entry.getValue().getConnection()) {
- DatabaseMetaData metaData = connection.getMetaData();
- result.put(entry.getKey(), getDatabaseType().getDataSourceMetaData(metaData.getURL(), metaData.getUserName()));
- }
- }
- return result;
- }
-
- private boolean isExisted(final String dataSourceName, final Collection<String> existedDataSourceNames, final Map<String, DataSourceMetaData> dataSourceMetaDataMap) {
- DataSourceMetaData sample = dataSourceMetaDataMap.get(dataSourceName);
- for (String each : existedDataSourceNames) {
- if (isInSameDatabaseInstance(sample, dataSourceMetaDataMap.get(each))) {
- return true;
- }
- }
- return false;
- }
-
- private boolean isInSameDatabaseInstance(final DataSourceMetaData sample, final DataSourceMetaData target) {
- return sample instanceof MemorizedDataSourceMetaData
- ? (Objects.equals(target.getSchema(), sample.getSchema())) : target.getHostName().equals(sample.getHostName()) && target.getPort() == sample.getPort();
- }
+ private AuthorityEnvironmentManager authorityEnvironmentManager;
@Before
- public final void insertData() throws SQLException {
+ public final void insertData() throws SQLException, IOException, JAXBException {
+ authorityEnvironmentManager = new AuthorityEnvironmentManager(
+ EnvironmentPath.getAuthorityFile(getDescription().getScenario()),
+ getStorage().getDataSourceMap(),
+ getDescription().getDatabaseType()
+ );
authorityEnvironmentManager.initialize();
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dcl/GeneralDCLIT.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dcl/GeneralDCLIT.java
index ed4fb25..7627ae9 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dcl/GeneralDCLIT.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dcl/GeneralDCLIT.java
@@ -18,51 +18,38 @@
package org.apache.shardingsphere.test.integration.engine.it.dcl;
import org.apache.shardingsphere.test.integration.cases.SQLCommandType;
-import org.apache.shardingsphere.test.integration.engine.junit.parallel.annotaion.ParallelLevel;
-import org.apache.shardingsphere.test.integration.engine.junit.parallel.annotaion.ParallelRuntimeStrategy;
-import org.apache.shardingsphere.test.integration.engine.param.ParameterizedArrayFactory;
-import org.apache.shardingsphere.test.integration.engine.param.SQLExecuteType;
-import org.apache.shardingsphere.test.integration.engine.param.model.AssertionParameterizedArray;
+import org.apache.shardingsphere.test.integration.common.SQLExecuteType;
+import org.apache.shardingsphere.test.integration.junit.annotation.TestCaseSpec;
+import org.apache.shardingsphere.test.integration.junit.runner.parallel.annotaion.ParallelLevel;
+import org.apache.shardingsphere.test.integration.junit.runner.parallel.annotaion.ParallelRuntimeStrategy;
import org.junit.Test;
-import org.junit.runners.Parameterized.Parameters;
-import javax.xml.bind.JAXBException;
-import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
import java.text.ParseException;
-import java.util.Collection;
+@TestCaseSpec(sqlCommandType = SQLCommandType.DCL)
@ParallelRuntimeStrategy(ParallelLevel.SCENARIO)
public final class GeneralDCLIT extends BaseDCLIT {
- public GeneralDCLIT(final AssertionParameterizedArray parameterizedArray) throws IOException, JAXBException, SQLException, ParseException {
- super(parameterizedArray);
- }
-
- @Parameters(name = "{0}")
- public static Collection<Object[]> getParameters() {
- return ParameterizedArrayFactory.getAssertionParameterizedArray(SQLCommandType.DCL);
- }
-
@Test
- public void assertExecuteUpdate() throws SQLException {
+ public void assertExecuteUpdate() throws SQLException, ParseException {
try (Connection connection = getTargetDataSource().getConnection()) {
if (SQLExecuteType.Literal == getSqlExecuteType()) {
- connection.createStatement().executeUpdate(getSql());
+ connection.createStatement().executeUpdate(getStatement());
} else {
- connection.prepareStatement(getSql()).executeUpdate();
+ connection.prepareStatement(getStatement()).executeUpdate();
}
}
}
@Test
- public void assertExecute() throws SQLException {
+ public void assertExecute() throws SQLException, ParseException {
try (Connection connection = getTargetDataSource().getConnection()) {
if (SQLExecuteType.Literal == getSqlExecuteType()) {
- connection.createStatement().execute(getSql());
+ connection.createStatement().execute(getStatement());
} else {
- connection.prepareStatement(getSql()).execute();
+ connection.prepareStatement(getStatement()).execute();
}
}
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/ddl/BaseDDLIT.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/ddl/BaseDDLIT.java
index 38fe542..538a9ee 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/ddl/BaseDDLIT.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/ddl/BaseDDLIT.java
@@ -18,28 +18,24 @@
package org.apache.shardingsphere.test.integration.engine.it.ddl;
import com.google.common.base.Splitter;
+import lombok.SneakyThrows;
import org.apache.shardingsphere.infra.datanode.DataNode;
import org.apache.shardingsphere.sharding.algorithm.sharding.inline.InlineExpressionParser;
import org.apache.shardingsphere.sharding.route.engine.exception.NoSuchTableException;
-import org.apache.shardingsphere.test.integration.cases.assertion.IntegrationTestCaseAssertion;
import org.apache.shardingsphere.test.integration.cases.dataset.metadata.DataSetColumn;
import org.apache.shardingsphere.test.integration.cases.dataset.metadata.DataSetIndex;
import org.apache.shardingsphere.test.integration.cases.dataset.metadata.DataSetMetadata;
-import org.apache.shardingsphere.test.integration.engine.it.SingleIT;
-import org.apache.shardingsphere.test.integration.engine.param.model.AssertionParameterizedArray;
+import org.apache.shardingsphere.test.integration.engine.it.SingleITCase;
import org.apache.shardingsphere.test.integration.env.EnvironmentPath;
import org.apache.shardingsphere.test.integration.env.dataset.DataSetEnvironmentManager;
import org.junit.After;
import org.junit.Before;
-import javax.xml.bind.JAXBException;
-import java.io.IOException;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
-import java.text.ParseException;
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.LinkedList;
@@ -52,25 +48,31 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
-public abstract class BaseDDLIT extends SingleIT {
+public abstract class BaseDDLIT extends SingleITCase {
- private final DataSetEnvironmentManager dataSetEnvironmentManager;
-
- protected BaseDDLIT(final AssertionParameterizedArray parameterizedArray) throws IOException, JAXBException, SQLException, ParseException {
- super(parameterizedArray);
- dataSetEnvironmentManager = new DataSetEnvironmentManager(EnvironmentPath.getDataSetFile(parameterizedArray.getScenario()), getActualDataSources());
- IntegrationTestCaseAssertion assertion = parameterizedArray.getAssertion();
- assertNotNull("Expected affected table is required", assertion.getInitialSQL());
- assertNotNull("Expected affected table is required", assertion.getInitialSQL().getAffectedTable());
- }
+ private DataSetEnvironmentManager dataSetEnvironmentManager;
@Before
- public final void initTables() throws SQLException, ParseException, IOException {
+ @SneakyThrows
+ public final void initTables() {
+ assertNotNull("Expected affected table is required", getAssertion().getInitialSQL());
+ assertNotNull("Expected affected table is required", getAssertion().getInitialSQL().getAffectedTable());
+ dataSetEnvironmentManager = new DataSetEnvironmentManager(
+ EnvironmentPath.getDataSetFile(getDescription().getScenario()),
+ getStorage().getDataSourceMap()
+ );
dataSetEnvironmentManager.fillData();
try (Connection connection = getTargetDataSource().getConnection()) {
executeInitSQLs(connection);
}
- resetTargetDataSource();
+// resetTargetDataSource();
+ }
+
+ @After
+ public final void destroyTables() throws SQLException {
+ try (Connection connection = getTargetDataSource().getConnection()) {
+ dropInitializedTable(connection);
+ }
}
private void executeInitSQLs(final Connection connection) throws SQLException {
@@ -82,13 +84,6 @@ public abstract class BaseDDLIT extends SingleIT {
}
}
- @After
- public final void destroyTables() throws SQLException {
- try (Connection connection = getTargetDataSource().getConnection()) {
- dropInitializedTable(connection);
- }
- }
-
private void dropInitializedTable(final Connection connection) {
try (PreparedStatement preparedStatement = connection.prepareStatement(String.format("DROP TABLE %s", getAssertion().getInitialSQL().getAffectedTable()))) {
preparedStatement.executeUpdate();
@@ -114,7 +109,7 @@ public abstract class BaseDDLIT extends SingleIT {
private void assertNotContainsTable(final Collection<DataNode> dataNodes) throws SQLException {
for (DataNode each : dataNodes) {
- try (Connection connection = getActualDataSources().get(each.getDataSourceName()).getConnection()) {
+ try (Connection connection = getStorage().getDataSourceMap().get(each.getDataSourceName()).getConnection()) {
assertNotContainsTable(connection, each.getTableName());
}
}
@@ -127,7 +122,7 @@ public abstract class BaseDDLIT extends SingleIT {
private List<DataSetColumn> getActualColumns(final Collection<DataNode> dataNodes) throws SQLException {
Set<DataSetColumn> result = new LinkedHashSet<>();
for (DataNode each : dataNodes) {
- try (Connection connection = getActualDataSources().get(each.getDataSourceName()).getConnection()) {
+ try (Connection connection = getStorage().getDataSourceMap().get(each.getDataSourceName()).getConnection()) {
result.addAll(getActualColumns(connection, each.getTableName()));
}
}
@@ -151,7 +146,7 @@ public abstract class BaseDDLIT extends SingleIT {
private List<DataSetIndex> getActualIndexes(final Collection<DataNode> dataNodes) throws SQLException {
Set<DataSetIndex> result = new LinkedHashSet<>();
for (DataNode each : dataNodes) {
- try (Connection connection = getActualDataSources().get(each.getDataSourceName()).getConnection()) {
+ try (Connection connection = getStorage().getDataSourceMap().get(each.getDataSourceName()).getConnection()) {
result.addAll(getActualIndexes(connection, each.getTableName()));
}
}
@@ -182,9 +177,9 @@ public abstract class BaseDDLIT extends SingleIT {
private void assertColumnMetaData(final DataSetColumn actual, final DataSetColumn expected) {
assertThat("Mismatched column name.", actual.getName(), is(expected.getName()));
- if ("MySQL".equals(getDatabaseType().getName()) && "integer".equals(expected.getType())) {
+ if ("MySQL".equals(getDescription().getDatabaseType().getName()) && "integer".equals(expected.getType())) {
assertThat("Mismatched column type.", actual.getType(), is("int"));
- } else if ("PostgreSQL".equals(getDatabaseType().getName()) && "integer".equals(expected.getType())) {
+ } else if ("PostgreSQL".equals(getDescription().getDatabaseType().getName()) && "integer".equals(expected.getType())) {
assertThat("Mismatched column type.", actual.getType(), is("int4"));
} else {
assertThat("Mismatched column type.", actual.getType(), is(expected.getType()));
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/ddl/GeneralDDLIT.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/ddl/GeneralDDLIT.java
index 91fd03c..1dc5a69 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/ddl/GeneralDDLIT.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/ddl/GeneralDDLIT.java
@@ -18,54 +18,39 @@
package org.apache.shardingsphere.test.integration.engine.it.ddl;
import org.apache.shardingsphere.test.integration.cases.SQLCommandType;
-import org.apache.shardingsphere.test.integration.engine.junit.parallel.annotaion.ParallelLevel;
-import org.apache.shardingsphere.test.integration.engine.junit.parallel.annotaion.ParallelRuntimeStrategy;
-import org.apache.shardingsphere.test.integration.engine.param.ParameterizedArrayFactory;
-import org.apache.shardingsphere.test.integration.engine.param.SQLExecuteType;
-import org.apache.shardingsphere.test.integration.engine.param.model.AssertionParameterizedArray;
+import org.apache.shardingsphere.test.integration.common.SQLExecuteType;
+import org.apache.shardingsphere.test.integration.junit.annotation.TestCaseSpec;
+import org.apache.shardingsphere.test.integration.junit.runner.parallel.annotaion.ParallelLevel;
+import org.apache.shardingsphere.test.integration.junit.runner.parallel.annotaion.ParallelRuntimeStrategy;
import org.junit.Test;
-import org.junit.runners.Parameterized.Parameters;
-import javax.xml.bind.JAXBException;
-import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
import java.text.ParseException;
-import java.util.Collection;
+@TestCaseSpec(sqlCommandType = SQLCommandType.DDL)
@ParallelRuntimeStrategy(ParallelLevel.SCENARIO)
public final class GeneralDDLIT extends BaseDDLIT {
- public GeneralDDLIT(final AssertionParameterizedArray parameterizedArray) throws IOException, JAXBException, SQLException, ParseException {
- super(parameterizedArray);
- }
-
- @Parameters(name = "{0}")
- public static Collection<Object[]> getParameters() {
- return ParameterizedArrayFactory.getAssertionParameterizedArray(SQLCommandType.DDL);
- }
-
- @SuppressWarnings("JUnitTestMethodWithNoAssertions")
@Test
- public void assertExecuteUpdate() throws SQLException {
+ public void assertExecuteUpdate() throws SQLException, ParseException {
try (Connection connection = getTargetDataSource().getConnection()) {
if (SQLExecuteType.Literal == getSqlExecuteType()) {
- connection.createStatement().executeUpdate(getSql());
+ connection.createStatement().executeUpdate(getStatement());
} else {
- connection.prepareStatement(getSql()).executeUpdate();
+ connection.prepareStatement(getStatement()).executeUpdate();
}
assertTableMetaData();
}
}
- @SuppressWarnings("JUnitTestMethodWithNoAssertions")
@Test
- public void assertExecute() throws SQLException {
+ public void assertExecute() throws SQLException, ParseException {
try (Connection connection = getTargetDataSource().getConnection()) {
if (SQLExecuteType.Literal == getSqlExecuteType()) {
- connection.createStatement().execute(getSql());
+ connection.createStatement().execute(getStatement());
} else {
- connection.prepareStatement(getSql()).execute();
+ connection.prepareStatement(getStatement()).execute();
}
assertTableMetaData();
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dml/AdditionalDMLIT.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dml/AdditionalDMLIT.java
index 76b6044..1dce947 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dml/AdditionalDMLIT.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dml/AdditionalDMLIT.java
@@ -18,48 +18,30 @@
package org.apache.shardingsphere.test.integration.engine.it.dml;
import org.apache.shardingsphere.test.integration.cases.SQLCommandType;
-import org.apache.shardingsphere.test.integration.cases.assertion.IntegrationTestCaseAssertion;
import org.apache.shardingsphere.test.integration.cases.value.SQLValue;
-import org.apache.shardingsphere.test.integration.engine.junit.parallel.annotaion.ParallelLevel;
-import org.apache.shardingsphere.test.integration.engine.junit.parallel.annotaion.ParallelRuntimeStrategy;
-import org.apache.shardingsphere.test.integration.engine.param.ParameterizedArrayFactory;
-import org.apache.shardingsphere.test.integration.engine.param.SQLExecuteType;
-import org.apache.shardingsphere.test.integration.engine.param.model.AssertionParameterizedArray;
-import org.apache.shardingsphere.test.integration.env.IntegrationTestEnvironment;
+import org.apache.shardingsphere.test.integration.common.ExecutionMode;
+import org.apache.shardingsphere.test.integration.common.SQLExecuteType;
+import org.apache.shardingsphere.test.integration.junit.annotation.TestCaseSpec;
+import org.apache.shardingsphere.test.integration.junit.runner.parallel.annotaion.ParallelLevel;
+import org.apache.shardingsphere.test.integration.junit.runner.parallel.annotaion.ParallelRuntimeStrategy;
import org.junit.Test;
-import org.junit.runners.Parameterized.Parameters;
-import javax.xml.bind.JAXBException;
-import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.ParseException;
-import java.util.Collection;
-import java.util.Collections;
import static org.junit.Assert.assertFalse;
+@TestCaseSpec(sqlCommandType = SQLCommandType.DML, executionMode = ExecutionMode.ADDITIONAL)
@ParallelRuntimeStrategy(ParallelLevel.SCENARIO)
public final class AdditionalDMLIT extends BaseDMLIT {
- private final IntegrationTestCaseAssertion assertion;
-
- public AdditionalDMLIT(final AssertionParameterizedArray parameterizedArray) throws IOException, JAXBException, SQLException, ParseException {
- super(parameterizedArray);
- assertion = parameterizedArray.getAssertion();
- }
-
- @Parameters(name = "{0}")
- public static Collection<Object[]> getParameters() {
- return IntegrationTestEnvironment.getInstance().isRunAdditionalTestCases() ? ParameterizedArrayFactory.getAssertionParameterizedArray(SQLCommandType.DML) : Collections.emptyList();
- }
-
@Test
public void executeUpdateWithAutoGeneratedKeys() throws SQLException, ParseException {
// TODO fix replica_query
- if ("replica_query".equals(getScenario())) {
+ if ("replica_query".equals(getDescription().getScenario())) {
return;
}
int actualUpdateCount;
@@ -72,13 +54,13 @@ public final class AdditionalDMLIT extends BaseDMLIT {
private int executeUpdateForStatementWithAutoGeneratedKeys(final Connection connection) throws SQLException, ParseException {
try (Statement statement = connection.createStatement()) {
- return statement.executeUpdate(String.format(getSql(), assertion.getSQLValues().toArray()), Statement.NO_GENERATED_KEYS);
+ return statement.executeUpdate(String.format(getStatement(), getAssertion().getSQLValues().toArray()), Statement.NO_GENERATED_KEYS);
}
}
private int executeUpdateForPreparedStatementWithAutoGeneratedKeys(final Connection connection) throws SQLException, ParseException {
- try (PreparedStatement preparedStatement = connection.prepareStatement(getSql(), Statement.NO_GENERATED_KEYS)) {
- for (SQLValue each : assertion.getSQLValues()) {
+ try (PreparedStatement preparedStatement = connection.prepareStatement(getStatement(), Statement.NO_GENERATED_KEYS)) {
+ for (SQLValue each : getAssertion().getSQLValues()) {
preparedStatement.setObject(each.getIndex(), each.getValue());
}
return preparedStatement.executeUpdate();
@@ -88,7 +70,7 @@ public final class AdditionalDMLIT extends BaseDMLIT {
@Test
public void assertExecuteUpdateWithColumnIndexes() throws SQLException, ParseException {
// TODO fix replica_query
- if ("PostgreSQL".equals(getDatabaseType().getName()) || "replica_query".equals(getScenario())) {
+ if ("PostgreSQL".equals(getDescription().getDatabaseType().getName()) || "replica_query".equals(getDescription().getScenario())) {
return;
}
int actualUpdateCount;
@@ -100,13 +82,13 @@ public final class AdditionalDMLIT extends BaseDMLIT {
private int executeUpdateForStatementWithColumnIndexes(final Connection connection) throws SQLException, ParseException {
try (Statement statement = connection.createStatement()) {
- return statement.executeUpdate(String.format(getSql(), assertion.getSQLValues().toArray()), new int[]{1});
+ return statement.executeUpdate(String.format(getStatement(), getAssertion().getSQLValues().toArray()), new int[]{1});
}
}
private int executeUpdateForPreparedStatementWithColumnIndexes(final Connection connection) throws SQLException, ParseException {
- try (PreparedStatement preparedStatement = connection.prepareStatement(getSql(), new int[]{1})) {
- for (SQLValue each : assertion.getSQLValues()) {
+ try (PreparedStatement preparedStatement = connection.prepareStatement(getStatement(), new int[]{1})) {
+ for (SQLValue each : getAssertion().getSQLValues()) {
preparedStatement.setObject(each.getIndex(), each.getValue());
}
return preparedStatement.executeUpdate();
@@ -116,7 +98,7 @@ public final class AdditionalDMLIT extends BaseDMLIT {
@Test
public void assertExecuteUpdateWithColumnNames() throws SQLException, ParseException {
// TODO fix replica_query
- if ("PostgreSQL".equals(getDatabaseType().getName()) || "replica_query".equals(getScenario())) {
+ if ("PostgreSQL".equals(getDescription().getDatabaseType().getName()) || "replica_query".equals(getDescription().getScenario())) {
return;
}
int actualUpdateCount;
@@ -128,13 +110,13 @@ public final class AdditionalDMLIT extends BaseDMLIT {
private int executeUpdateForStatementWithColumnNames(final Connection connection) throws SQLException, ParseException {
try (Statement statement = connection.createStatement()) {
- return statement.executeUpdate(String.format(getSql(), assertion.getSQLValues().toArray()));
+ return statement.executeUpdate(String.format(getStatement(), getAssertion().getSQLValues().toArray()));
}
}
private int executeUpdateForPreparedStatementWithColumnNames(final Connection connection) throws SQLException, ParseException {
- try (PreparedStatement preparedStatement = connection.prepareStatement(getSql(), new String[]{"TODO"})) {
- for (SQLValue each : assertion.getSQLValues()) {
+ try (PreparedStatement preparedStatement = connection.prepareStatement(getStatement(), new String[]{"TODO"})) {
+ for (SQLValue each : getAssertion().getSQLValues()) {
preparedStatement.setObject(each.getIndex(), each.getValue());
}
return preparedStatement.executeUpdate();
@@ -144,7 +126,7 @@ public final class AdditionalDMLIT extends BaseDMLIT {
@Test
public void assertExecuteWithoutAutoGeneratedKeys() throws SQLException, ParseException {
// TODO fix replica_query
- if ("replica_query".equals(getScenario())) {
+ if ("replica_query".equals(getDescription().getScenario())) {
return;
}
int actualUpdateCount;
@@ -157,14 +139,14 @@ public final class AdditionalDMLIT extends BaseDMLIT {
private int executeForStatementWithoutAutoGeneratedKeys(final Connection connection) throws SQLException, ParseException {
try (Statement statement = connection.createStatement()) {
- assertFalse("Not a DML statement.", statement.execute(String.format(getSql(), assertion.getSQLValues().toArray()), Statement.NO_GENERATED_KEYS));
+ assertFalse("Not a DML statement.", statement.execute(String.format(getStatement(), getAssertion().getSQLValues().toArray()), Statement.NO_GENERATED_KEYS));
return statement.getUpdateCount();
}
}
private int executeForPreparedStatementWithoutAutoGeneratedKeys(final Connection connection) throws SQLException, ParseException {
- try (PreparedStatement preparedStatement = connection.prepareStatement(getSql(), Statement.NO_GENERATED_KEYS)) {
- for (SQLValue each : assertion.getSQLValues()) {
+ try (PreparedStatement preparedStatement = connection.prepareStatement(getStatement(), Statement.NO_GENERATED_KEYS)) {
+ for (SQLValue each : getAssertion().getSQLValues()) {
preparedStatement.setObject(each.getIndex(), each.getValue());
}
assertFalse("Not a DML statement.", preparedStatement.execute());
@@ -175,7 +157,7 @@ public final class AdditionalDMLIT extends BaseDMLIT {
@Test
public void assertExecuteWithAutoGeneratedKeys() throws SQLException, ParseException {
// TODO fix replica_query
- if ("replica_query".equals(getScenario())) {
+ if ("replica_query".equals(getDescription().getScenario())) {
return;
}
int actualUpdateCount;
@@ -187,15 +169,15 @@ public final class AdditionalDMLIT extends BaseDMLIT {
private int executeForStatementWithAutoGeneratedKeys(final Connection connection) throws SQLException, ParseException {
try (Statement statement = connection.createStatement()) {
- assertFalse("Not a DML statement.", statement.execute(String.format(getSql(), assertion.getSQLValues().toArray()), Statement.RETURN_GENERATED_KEYS));
+ assertFalse("Not a DML statement.", statement.execute(String.format(getStatement(), getAssertion().getSQLValues().toArray()), Statement.RETURN_GENERATED_KEYS));
return statement.getUpdateCount();
// TODO assert statement.getGeneratedKeys();
}
}
private int executeForPreparedStatementWithAutoGeneratedKeys(final Connection connection) throws SQLException, ParseException {
- try (PreparedStatement preparedStatement = connection.prepareStatement(getSql(), Statement.RETURN_GENERATED_KEYS)) {
- for (SQLValue each : assertion.getSQLValues()) {
+ try (PreparedStatement preparedStatement = connection.prepareStatement(getStatement(), Statement.RETURN_GENERATED_KEYS)) {
+ for (SQLValue each : getAssertion().getSQLValues()) {
preparedStatement.setObject(each.getIndex(), each.getValue());
}
assertFalse("Not a DML statement.", preparedStatement.execute());
@@ -207,7 +189,7 @@ public final class AdditionalDMLIT extends BaseDMLIT {
@Test
public void assertExecuteWithColumnIndexes() throws SQLException, ParseException {
// TODO fix replica_query
- if ("PostgreSQL".equals(getDatabaseType().getName()) || "replica_query".equals(getScenario())) {
+ if ("PostgreSQL".equals(getDescription().getDatabaseType().getName()) || "replica_query".equals(getDescription().getScenario())) {
return;
}
int actualUpdateCount;
@@ -219,14 +201,14 @@ public final class AdditionalDMLIT extends BaseDMLIT {
private int executeForStatementWithColumnIndexes(final Connection connection) throws SQLException, ParseException {
try (Statement statement = connection.createStatement()) {
- assertFalse("Not a DML statement.", statement.execute(String.format(getSql(), assertion.getSQLValues().toArray()), new int[]{1}));
+ assertFalse("Not a DML statement.", statement.execute(String.format(getStatement(), getAssertion().getSQLValues().toArray()), new int[]{1}));
return statement.getUpdateCount();
}
}
private int executeForPreparedStatementWithColumnIndexes(final Connection connection) throws SQLException, ParseException {
- try (PreparedStatement preparedStatement = connection.prepareStatement(getSql(), new int[]{1})) {
- for (SQLValue each : assertion.getSQLValues()) {
+ try (PreparedStatement preparedStatement = connection.prepareStatement(getStatement(), new int[]{1})) {
+ for (SQLValue each : getAssertion().getSQLValues()) {
preparedStatement.setObject(each.getIndex(), each.getValue());
}
assertFalse("Not a DML statement.", preparedStatement.execute());
@@ -237,7 +219,7 @@ public final class AdditionalDMLIT extends BaseDMLIT {
@Test
public void assertExecuteWithColumnNames() throws SQLException, ParseException {
// TODO fix replica_query
- if ("PostgreSQL".equals(getDatabaseType().getName()) || "replica_query".equals(getScenario())) {
+ if ("PostgreSQL".equals(getDescription().getDatabaseType().getName()) || "replica_query".equals(getDescription().getScenario())) {
return;
}
int actualUpdateCount;
@@ -249,14 +231,14 @@ public final class AdditionalDMLIT extends BaseDMLIT {
private int executeForStatementWithColumnNames(final Connection connection) throws SQLException, ParseException {
try (Statement statement = connection.createStatement()) {
- assertFalse("Not a DML statement.", statement.execute(String.format(getSql(), assertion.getSQLValues().toArray()), new String[]{"TODO"}));
+ assertFalse("Not a DML statement.", statement.execute(String.format(getStatement(), getAssertion().getSQLValues().toArray()), new String[]{"TODO"}));
return statement.getUpdateCount();
}
}
private int executeForPreparedStatementWithColumnNames(final Connection connection) throws SQLException, ParseException {
- try (PreparedStatement preparedStatement = connection.prepareStatement(getSql(), new String[]{"TODO"})) {
- for (SQLValue each : assertion.getSQLValues()) {
+ try (PreparedStatement preparedStatement = connection.prepareStatement(getStatement(), new String[]{"TODO"})) {
+ for (SQLValue each : getAssertion().getSQLValues()) {
preparedStatement.setObject(each.getIndex(), each.getValue());
}
assertFalse("Not a DML statement.", preparedStatement.execute());
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dml/BaseDMLIT.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dml/BaseDMLIT.java
index 60d1795..c087e5c 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dml/BaseDMLIT.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dml/BaseDMLIT.java
@@ -17,21 +17,19 @@
package org.apache.shardingsphere.test.integration.engine.it.dml;
+import lombok.SneakyThrows;
import org.apache.shardingsphere.infra.database.type.dialect.PostgreSQLDatabaseType;
import org.apache.shardingsphere.infra.datanode.DataNode;
import org.apache.shardingsphere.sharding.algorithm.sharding.inline.InlineExpressionParser;
import org.apache.shardingsphere.test.integration.cases.dataset.metadata.DataSetColumn;
import org.apache.shardingsphere.test.integration.cases.dataset.metadata.DataSetMetadata;
import org.apache.shardingsphere.test.integration.cases.dataset.row.DataSetRow;
-import org.apache.shardingsphere.test.integration.engine.it.SingleIT;
-import org.apache.shardingsphere.test.integration.engine.param.model.AssertionParameterizedArray;
+import org.apache.shardingsphere.test.integration.engine.it.SingleITCase;
import org.apache.shardingsphere.test.integration.env.EnvironmentPath;
import org.apache.shardingsphere.test.integration.env.dataset.DataSetEnvironmentManager;
import org.junit.After;
import org.junit.Before;
-import javax.xml.bind.JAXBException;
-import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@@ -39,7 +37,6 @@ import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Types;
-import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.List;
@@ -47,22 +44,22 @@ import java.util.List;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
-public abstract class BaseDMLIT extends SingleIT {
+public abstract class BaseDMLIT extends SingleITCase {
- private final DataSetEnvironmentManager dataSetEnvironmentManager;
-
- protected BaseDMLIT(final AssertionParameterizedArray parameterizedArray) throws IOException, JAXBException, SQLException, ParseException {
- super(parameterizedArray);
- dataSetEnvironmentManager = new DataSetEnvironmentManager(EnvironmentPath.getDataSetFile(parameterizedArray.getScenario()), getActualDataSources());
- }
+ private DataSetEnvironmentManager dataSetEnvironmentManager;
@Before
- public final void fillData() throws SQLException, ParseException {
+ @SneakyThrows
+ public final void fillData() {
+ dataSetEnvironmentManager = new DataSetEnvironmentManager(
+ EnvironmentPath.getDataSetFile(getDescription().getScenario()),
+ getStorage().getDataSourceMap()
+ );
dataSetEnvironmentManager.fillData();
}
@After
- public final void clearData() {
+ public final void cleanup() {
dataSetEnvironmentManager.clearData();
}
@@ -73,7 +70,7 @@ public abstract class BaseDMLIT extends SingleIT {
for (String each : new InlineExpressionParser(expectedDataSetMetadata.getDataNodes()).splitAndEvaluate()) {
DataNode dataNode = new DataNode(each);
try (
- Connection connection = getActualDataSources().get(dataNode.getDataSourceName()).getConnection();
+ Connection connection = getStorage().getDataSourceMap().get(dataNode.getDataSourceName()).getConnection();
PreparedStatement preparedStatement = connection.prepareStatement(generateFetchActualDataSQL(dataNode))) {
assertDataSet(preparedStatement, expectedDataSetMetadata, getDataSet().findRows(dataNode));
}
@@ -88,7 +85,7 @@ public abstract class BaseDMLIT extends SingleIT {
}
private String generateFetchActualDataSQL(final DataNode dataNode) throws SQLException {
- if (getDatabaseType() instanceof PostgreSQLDatabaseType) {
+ if (getStorage().getDatabaseType() instanceof PostgreSQLDatabaseType) {
String primaryKeyColumnName = getPrimaryKeyColumnNameForPostgreSQL(dataNode);
return String.format("SELECT * FROM %s ORDER BY %s ASC", dataNode.getTableName(), primaryKeyColumnName);
}
@@ -99,7 +96,7 @@ public abstract class BaseDMLIT extends SingleIT {
String sql = String.format("SELECT a.attname, format_type(a.atttypid, a.atttypmod) AS data_type "
+ "FROM pg_index i JOIN pg_attribute a ON a.attrelid = i.indrelid AND a.attnum = ANY(i.indkey) WHERE i.indrelid = '%s'::regclass AND i.indisprimary", dataNode.getTableName());
try (
- Connection connection = getActualDataSources().get(dataNode.getDataSourceName()).getConnection();
+ Connection connection = getStorage().getDataSourceMap().get(dataNode.getDataSourceName()).getConnection();
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery(sql)) {
if (resultSet.next()) {
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dml/BatchDMLIT.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dml/BatchDMLIT.java
index f906716..709c959 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dml/BatchDMLIT.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dml/BatchDMLIT.java
@@ -17,57 +17,36 @@
package org.apache.shardingsphere.test.integration.engine.it.dml;
-import org.apache.shardingsphere.test.integration.cases.IntegrationTestCaseContext;
import org.apache.shardingsphere.test.integration.cases.SQLCommandType;
import org.apache.shardingsphere.test.integration.cases.assertion.IntegrationTestCaseAssertion;
import org.apache.shardingsphere.test.integration.cases.value.SQLValue;
-import org.apache.shardingsphere.test.integration.engine.it.BatchIT;
-import org.apache.shardingsphere.test.integration.engine.junit.parallel.annotaion.ParallelLevel;
-import org.apache.shardingsphere.test.integration.engine.junit.parallel.annotaion.ParallelRuntimeStrategy;
-import org.apache.shardingsphere.test.integration.engine.param.ParameterizedArrayFactory;
-import org.apache.shardingsphere.test.integration.engine.param.model.CaseParameterizedArray;
+import org.apache.shardingsphere.test.integration.common.ExecutionMode;
+import org.apache.shardingsphere.test.integration.engine.it.BatchITCase;
+import org.apache.shardingsphere.test.integration.junit.annotation.TestCaseSpec;
+import org.apache.shardingsphere.test.integration.junit.runner.parallel.annotaion.ParallelLevel;
+import org.apache.shardingsphere.test.integration.junit.runner.parallel.annotaion.ParallelRuntimeStrategy;
import org.junit.Test;
-import org.junit.runners.Parameterized.Parameters;
-import javax.xml.bind.JAXBException;
-import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.text.ParseException;
-import java.util.Collection;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
+@TestCaseSpec(sqlCommandType = SQLCommandType.DML, executionMode = ExecutionMode.BATCH)
@ParallelRuntimeStrategy(ParallelLevel.SCENARIO)
-public final class BatchDMLIT extends BatchIT {
-
- private final IntegrationTestCaseContext testCaseContext;
-
- public BatchDMLIT(final CaseParameterizedArray parameterizedArray) throws IOException, JAXBException, SQLException {
- super(parameterizedArray);
- testCaseContext = parameterizedArray.getTestCaseContext();
- }
-
- @Parameters(name = "{0}")
- public static Collection<Object[]> getParameters() {
- return ParameterizedArrayFactory.getCaseParameterizedArray(SQLCommandType.DML);
- }
+public final class BatchDMLIT extends BatchITCase {
@Test
public void assertExecuteBatch() throws SQLException, ParseException {
- // TODO fix replica_query
- if ("replica_query".equals(getScenario())) {
- return;
- }
- // TODO fix shadow
- if ("shadow".equals(getScenario())) {
- return;
- }
- // TODO fix encrypt
- if ("encrypt".equals(getScenario())) {
- return;
+ switch (getDescription().getScenario()) {
+ case "replica_query":
+ case "shadow":
+ case "encrypt":
+ return;
+ default:
}
int[] actualUpdateCounts;
try (Connection connection = getTargetDataSource().getConnection()) {
@@ -77,8 +56,8 @@ public final class BatchDMLIT extends BatchIT {
}
private int[] executeBatchForPreparedStatement(final Connection connection) throws SQLException, ParseException {
- try (PreparedStatement preparedStatement = connection.prepareStatement(getSql())) {
- for (IntegrationTestCaseAssertion each : testCaseContext.getTestCase().getAssertions()) {
+ try (PreparedStatement preparedStatement = connection.prepareStatement(getStatement())) {
+ for (IntegrationTestCaseAssertion each : getTestCase().getAssertions()) {
addBatch(preparedStatement, each);
}
return preparedStatement.executeBatch();
@@ -95,20 +74,16 @@ public final class BatchDMLIT extends BatchIT {
@Test
public void assertClearBatch() throws SQLException, ParseException {
// TODO fix replica_query
- if ("replica_query".equals(getScenario())) {
- return;
- }
- // TODO fix shadow
- if ("shadow".equals(getScenario())) {
- return;
- }
- // TODO fix encrypt
- if ("encrypt".equals(getScenario())) {
- return;
+ switch (getDescription().getScenario()) {
+ case "replica_query":
+ case "shadow":
+ case "encrypt":
+ return;
+ default:
}
try (Connection connection = getTargetDataSource().getConnection()) {
- try (PreparedStatement preparedStatement = connection.prepareStatement(getSql())) {
- for (IntegrationTestCaseAssertion each : testCaseContext.getTestCase().getAssertions()) {
+ try (PreparedStatement preparedStatement = connection.prepareStatement(getStatement())) {
+ for (IntegrationTestCaseAssertion each : getTestCase().getAssertions()) {
addBatch(preparedStatement, each);
}
preparedStatement.clearBatch();
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dml/GeneralDMLIT.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dml/GeneralDMLIT.java
index 185c95f..be83a45 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dml/GeneralDMLIT.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dml/GeneralDMLIT.java
@@ -18,44 +18,34 @@
package org.apache.shardingsphere.test.integration.engine.it.dml;
import org.apache.shardingsphere.test.integration.cases.SQLCommandType;
-import org.apache.shardingsphere.test.integration.cases.assertion.IntegrationTestCaseAssertion;
import org.apache.shardingsphere.test.integration.cases.value.SQLValue;
-import org.apache.shardingsphere.test.integration.engine.junit.parallel.annotaion.ParallelLevel;
-import org.apache.shardingsphere.test.integration.engine.junit.parallel.annotaion.ParallelRuntimeStrategy;
-import org.apache.shardingsphere.test.integration.engine.param.ParameterizedArrayFactory;
-import org.apache.shardingsphere.test.integration.engine.param.SQLExecuteType;
-import org.apache.shardingsphere.test.integration.engine.param.model.AssertionParameterizedArray;
+import org.apache.shardingsphere.test.integration.common.SQLExecuteType;
+import org.apache.shardingsphere.test.integration.junit.annotation.TestCaseSpec;
+import org.apache.shardingsphere.test.integration.junit.runner.parallel.annotaion.ParallelLevel;
+import org.apache.shardingsphere.test.integration.junit.runner.parallel.annotaion.ParallelRuntimeStrategy;
import org.junit.Test;
-import org.junit.runners.Parameterized.Parameters;
-import javax.xml.bind.JAXBException;
-import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.ParseException;
-import java.util.Collection;
import static org.junit.Assert.assertFalse;
+@TestCaseSpec(name = "General DML", sqlCommandType = SQLCommandType.DML)
@ParallelRuntimeStrategy(ParallelLevel.SCENARIO)
public final class GeneralDMLIT extends BaseDMLIT {
- private final IntegrationTestCaseAssertion assertion;
-
- public GeneralDMLIT(final AssertionParameterizedArray parameterizedArray) throws IOException, JAXBException, SQLException, ParseException {
- super(parameterizedArray);
- assertion = parameterizedArray.getAssertion();
- }
-
- @Parameters(name = "{0}")
- public static Collection<Object[]> getParameters() {
- return ParameterizedArrayFactory.getAssertionParameterizedArray(SQLCommandType.DML);
- }
-
@Test
public void assertExecuteUpdate() throws SQLException, ParseException {
+ switch (getDescription().getScenario()) {
+ case "replica_query":
+ case "shadow":
+ case "encrypt":
+ return;
+ default:
+ }
int actualUpdateCount;
try (Connection connection = getTargetDataSource().getConnection()) {
actualUpdateCount = SQLExecuteType.Literal == getSqlExecuteType() ? executeUpdateForStatement(connection) : executeUpdateForPreparedStatement(connection);
@@ -63,15 +53,15 @@ public final class GeneralDMLIT extends BaseDMLIT {
assertDataSet(actualUpdateCount);
}
- private int executeUpdateForStatement(final Connection connection) throws SQLException {
+ private int executeUpdateForStatement(final Connection connection) throws SQLException, ParseException {
try (Statement statement = connection.createStatement()) {
- return statement.executeUpdate(getSql());
+ return statement.executeUpdate(getStatement());
}
}
private int executeUpdateForPreparedStatement(final Connection connection) throws SQLException, ParseException {
- try (PreparedStatement preparedStatement = connection.prepareStatement(getSql())) {
- for (SQLValue each : assertion.getSQLValues()) {
+ try (PreparedStatement preparedStatement = connection.prepareStatement(getStatement())) {
+ for (SQLValue each : getAssertion().getSQLValues()) {
preparedStatement.setObject(each.getIndex(), each.getValue());
}
return preparedStatement.executeUpdate();
@@ -80,6 +70,13 @@ public final class GeneralDMLIT extends BaseDMLIT {
@Test
public void assertExecute() throws SQLException, ParseException {
+ switch (getDescription().getScenario()) {
+ case "replica_query":
+ case "shadow":
+ case "encrypt":
+ return;
+ default:
+ }
int actualUpdateCount;
try (Connection connection = getTargetDataSource().getConnection()) {
actualUpdateCount = SQLExecuteType.Literal == getSqlExecuteType() ? executeForStatement(connection) : executeForPreparedStatement(connection);
@@ -87,16 +84,16 @@ public final class GeneralDMLIT extends BaseDMLIT {
assertDataSet(actualUpdateCount);
}
- private int executeForStatement(final Connection connection) throws SQLException {
+ private int executeForStatement(final Connection connection) throws SQLException, ParseException {
try (Statement statement = connection.createStatement()) {
- assertFalse("Not a DML statement.", statement.execute(getSql()));
+ assertFalse("Not a DML statement.", statement.execute(getStatement()));
return statement.getUpdateCount();
}
}
private int executeForPreparedStatement(final Connection connection) throws SQLException, ParseException {
- try (PreparedStatement preparedStatement = connection.prepareStatement(getSql())) {
- for (SQLValue each : assertion.getSQLValues()) {
+ try (PreparedStatement preparedStatement = connection.prepareStatement(getStatement())) {
+ for (SQLValue each : getAssertion().getSQLValues()) {
preparedStatement.setObject(each.getIndex(), each.getValue());
}
assertFalse("Not a DML statement.", preparedStatement.execute());
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dql/AdditionalDQLIT.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dql/AdditionalDQLIT.java
index 4a2ebc4..f26ccf7 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dql/AdditionalDQLIT.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dql/AdditionalDQLIT.java
@@ -18,45 +18,27 @@
package org.apache.shardingsphere.test.integration.engine.it.dql;
import org.apache.shardingsphere.test.integration.cases.SQLCommandType;
-import org.apache.shardingsphere.test.integration.cases.assertion.IntegrationTestCaseAssertion;
import org.apache.shardingsphere.test.integration.cases.value.SQLValue;
-import org.apache.shardingsphere.test.integration.engine.junit.parallel.annotaion.ParallelLevel;
-import org.apache.shardingsphere.test.integration.engine.junit.parallel.annotaion.ParallelRuntimeStrategy;
-import org.apache.shardingsphere.test.integration.engine.param.ParameterizedArrayFactory;
-import org.apache.shardingsphere.test.integration.engine.param.SQLExecuteType;
-import org.apache.shardingsphere.test.integration.engine.param.model.AssertionParameterizedArray;
-import org.apache.shardingsphere.test.integration.env.IntegrationTestEnvironment;
+import org.apache.shardingsphere.test.integration.common.ExecutionMode;
+import org.apache.shardingsphere.test.integration.common.SQLExecuteType;
+import org.apache.shardingsphere.test.integration.junit.annotation.TestCaseSpec;
+import org.apache.shardingsphere.test.integration.junit.runner.parallel.annotaion.ParallelLevel;
+import org.apache.shardingsphere.test.integration.junit.runner.parallel.annotaion.ParallelRuntimeStrategy;
import org.junit.Test;
-import org.junit.runners.Parameterized.Parameters;
-import javax.xml.bind.JAXBException;
-import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.ParseException;
-import java.util.Collection;
-import java.util.Collections;
import static org.junit.Assert.assertTrue;
+@TestCaseSpec(name = "Additional DQL", sqlCommandType = SQLCommandType.DQL, executionMode = ExecutionMode.ADDITIONAL)
@ParallelRuntimeStrategy(ParallelLevel.CASE)
public final class AdditionalDQLIT extends BaseDQLIT {
- private final IntegrationTestCaseAssertion assertion;
-
- public AdditionalDQLIT(final AssertionParameterizedArray parameterizedArray) throws IOException, JAXBException, SQLException, ParseException {
- super(parameterizedArray);
- assertion = parameterizedArray.getAssertion();
- }
-
- @Parameters(name = "{0}")
- public static Collection<Object[]> getParameters() {
- return IntegrationTestEnvironment.getInstance().isRunAdditionalTestCases() ? ParameterizedArrayFactory.getAssertionParameterizedArray(SQLCommandType.DQL) : Collections.emptyList();
- }
-
@Test
public void assertExecuteQueryWithResultSetTypeAndResultSetConcurrency() throws SQLException, ParseException {
try (Connection connection = getTargetDataSource().getConnection()) {
@@ -69,15 +51,16 @@ public final class AdditionalDQLIT extends BaseDQLIT {
}
private void assertExecuteQueryForStatementWithResultSetTypeAndResultSetConcurrency(final Connection connection) throws SQLException, ParseException {
- try (Statement statement = connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
- ResultSet resultSet = statement.executeQuery(String.format(getSql(), assertion.getSQLValues().toArray()))) {
+ try (
+ Statement statement = connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
+ ResultSet resultSet = statement.executeQuery(String.format(getStatement(), getAssertion().getSQLValues().toArray()))) {
assertResultSet(resultSet);
}
}
private void assertExecuteQueryForPreparedStatementWithResultSetTypeAndResultSetConcurrency(final Connection connection) throws SQLException, ParseException {
- try (PreparedStatement preparedStatement = connection.prepareStatement(getSql(), ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY)) {
- for (SQLValue each : assertion.getSQLValues()) {
+ try (PreparedStatement preparedStatement = connection.prepareStatement(getStatement(), ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY)) {
+ for (SQLValue each : getAssertion().getSQLValues()) {
preparedStatement.setObject(each.getIndex(), each.getValue());
}
try (ResultSet resultSet = preparedStatement.executeQuery()) {
@@ -101,15 +84,15 @@ public final class AdditionalDQLIT extends BaseDQLIT {
throws SQLException, ParseException {
try (
Statement statement = connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
- ResultSet resultSet = statement.executeQuery(String.format(getSql(), assertion.getSQLValues().toArray()))) {
+ ResultSet resultSet = statement.executeQuery(String.format(getStatement(), getAssertion().getSQLValues().toArray()))) {
assertResultSet(resultSet);
}
}
private void assertExecuteQueryForPreparedStatementWithResultSetTypeAndResultSetConcurrencyAndResultSetHoldability(final Connection connection)
throws SQLException, ParseException {
- try (PreparedStatement preparedStatement = connection.prepareStatement(getSql(), ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT)) {
- for (SQLValue each : assertion.getSQLValues()) {
+ try (PreparedStatement preparedStatement = connection.prepareStatement(getStatement(), ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT)) {
+ for (SQLValue each : getAssertion().getSQLValues()) {
preparedStatement.setObject(each.getIndex(), each.getValue());
}
try (ResultSet resultSet = preparedStatement.executeQuery()) {
@@ -131,7 +114,7 @@ public final class AdditionalDQLIT extends BaseDQLIT {
private void assertExecuteForStatementWithResultSetTypeAndResultSetConcurrency(final Connection connection) throws SQLException, ParseException {
try (Statement statement = connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY)) {
- assertTrue("Not a query statement.", statement.execute(String.format(getSql(), assertion.getSQLValues().toArray())));
+ assertTrue("Not a query statement.", statement.execute(String.format(getStatement(), getAssertion().getSQLValues().toArray())));
try (ResultSet resultSet = statement.getResultSet()) {
assertResultSet(resultSet);
}
@@ -139,8 +122,8 @@ public final class AdditionalDQLIT extends BaseDQLIT {
}
private void assertExecuteForPreparedStatementWithResultSetTypeAndResultSetConcurrency(final Connection connection) throws SQLException, ParseException {
- try (PreparedStatement preparedStatement = connection.prepareStatement(getSql(), ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY)) {
- for (SQLValue each : assertion.getSQLValues()) {
+ try (PreparedStatement preparedStatement = connection.prepareStatement(getStatement(), ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY)) {
+ for (SQLValue each : getAssertion().getSQLValues()) {
preparedStatement.setObject(each.getIndex(), each.getValue());
}
assertTrue("Not a query statement.", preparedStatement.execute());
@@ -163,7 +146,7 @@ public final class AdditionalDQLIT extends BaseDQLIT {
private void assertExecuteForStatementWithResultSetTypeAndResultSetConcurrencyAndResultSetHoldability(final Connection connection) throws SQLException, ParseException {
try (Statement statement = connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT)) {
- assertTrue("Not a query statement.", statement.execute(String.format(getSql(), assertion.getSQLValues().toArray())));
+ assertTrue("Not a query statement.", statement.execute(String.format(getStatement(), getAssertion().getSQLValues().toArray())));
try (ResultSet resultSet = statement.getResultSet()) {
assertResultSet(resultSet);
}
@@ -171,8 +154,8 @@ public final class AdditionalDQLIT extends BaseDQLIT {
}
private void assertExecuteForPreparedStatementWithResultSetTypeAndResultSetConcurrencyAndResultSetHoldability(final Connection connection) throws SQLException, ParseException {
- try (PreparedStatement preparedStatement = connection.prepareStatement(getSql(), ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT)) {
- for (SQLValue each : assertion.getSQLValues()) {
+ try (PreparedStatement preparedStatement = connection.prepareStatement(getStatement(), ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT)) {
+ for (SQLValue each : getAssertion().getSQLValues()) {
preparedStatement.setObject(each.getIndex(), each.getValue());
}
assertTrue("Not a query statement.", preparedStatement.execute());
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dql/BaseDQLIT.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dql/BaseDQLIT.java
index 1cfea31..36679da 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dql/BaseDQLIT.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dql/BaseDQLIT.java
@@ -17,17 +17,17 @@
package org.apache.shardingsphere.test.integration.engine.it.dql;
-import org.apache.shardingsphere.infra.database.type.DatabaseType;
+import lombok.SneakyThrows;
import org.apache.shardingsphere.test.integration.cases.dataset.metadata.DataSetColumn;
import org.apache.shardingsphere.test.integration.cases.dataset.metadata.DataSetMetadata;
import org.apache.shardingsphere.test.integration.cases.dataset.row.DataSetRow;
-import org.apache.shardingsphere.test.integration.engine.it.SingleIT;
-import org.apache.shardingsphere.test.integration.engine.param.model.AssertionParameterizedArray;
+import org.apache.shardingsphere.test.integration.engine.it.SingleITCase;
import org.apache.shardingsphere.test.integration.env.EnvironmentPath;
+import org.apache.shardingsphere.test.integration.env.EnvironmentType;
import org.apache.shardingsphere.test.integration.env.IntegrationTestEnvironment;
import org.apache.shardingsphere.test.integration.env.dataset.DataSetEnvironmentManager;
import org.apache.shardingsphere.test.integration.env.datasource.builder.ActualDataSourceBuilder;
-import org.junit.BeforeClass;
+import org.apache.shardingsphere.test.integration.junit.annotation.BeforeAllCases;
import javax.xml.bind.JAXBException;
import java.io.IOException;
@@ -45,22 +45,29 @@ import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
-public abstract class BaseDQLIT extends SingleIT {
+public abstract class BaseDQLIT extends SingleITCase {
- protected BaseDQLIT(final AssertionParameterizedArray parameterizedArray) throws IOException, JAXBException, SQLException, ParseException {
- super(parameterizedArray);
- }
-
- @BeforeClass
- public static void fillData() throws IOException, JAXBException, SQLException, ParseException {
- for (DatabaseType each : IntegrationTestEnvironment.getInstance().getDataSourceEnvironments().keySet()) {
- fillData(each);
- }
- }
-
- private static void fillData(final DatabaseType databaseType) throws SQLException, ParseException, IOException, JAXBException {
- for (String each : IntegrationTestEnvironment.getInstance().getScenarios()) {
- new DataSetEnvironmentManager(EnvironmentPath.getDataSetFile(each), ActualDataSourceBuilder.createActualDataSources(each, databaseType)).fillData();
+ @BeforeAllCases
+ @SneakyThrows
+ protected void fillData() {
+ if (EnvironmentType.DOCKER == IntegrationTestEnvironment.getInstance().getEnvType()) {
+ new DataSetEnvironmentManager(
+ EnvironmentPath.getDataSetFile(getDescription().getScenario()),
+ getStorage().getDataSourceMap()
+ ).fillData();
+ } else {
+ IntegrationTestEnvironment.getInstance().getDataSourceEnvironments().keySet().forEach(e -> {
+ IntegrationTestEnvironment.getInstance().getScenarios().forEach(each -> {
+ try {
+ new DataSetEnvironmentManager(
+ EnvironmentPath.getDataSetFile(each),
+ ActualDataSourceBuilder.createActualDataSources(each, e)
+ ).fillData();
+ } catch (SQLException | ParseException | IOException | JAXBException jaxbException) {
+ jaxbException.printStackTrace();
+ }
+ });
+ });
}
}
@@ -79,7 +86,7 @@ public abstract class BaseDQLIT extends SingleIT {
private void assertMetaData(final ResultSetMetaData actual, final Collection<DataSetColumn> expected) throws SQLException {
// TODO Fix shadow
- if ("shadow".equals(getScenario())) {
+ if ("shadow".equals(getDescription().getScenario())) {
return;
}
assertThat(actual.getColumnCount(), is(expected.size()));
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dql/GeneralDQLIT.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dql/GeneralDQLIT.java
index 2cebd73..edb0eda 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dql/GeneralDQLIT.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dql/GeneralDQLIT.java
@@ -18,43 +18,26 @@
package org.apache.shardingsphere.test.integration.engine.it.dql;
import org.apache.shardingsphere.test.integration.cases.SQLCommandType;
-import org.apache.shardingsphere.test.integration.cases.assertion.IntegrationTestCaseAssertion;
import org.apache.shardingsphere.test.integration.cases.value.SQLValue;
-import org.apache.shardingsphere.test.integration.engine.junit.parallel.annotaion.ParallelLevel;
-import org.apache.shardingsphere.test.integration.engine.junit.parallel.annotaion.ParallelRuntimeStrategy;
-import org.apache.shardingsphere.test.integration.engine.param.ParameterizedArrayFactory;
-import org.apache.shardingsphere.test.integration.engine.param.SQLExecuteType;
-import org.apache.shardingsphere.test.integration.engine.param.model.AssertionParameterizedArray;
+import org.apache.shardingsphere.test.integration.common.SQLExecuteType;
+import org.apache.shardingsphere.test.integration.junit.annotation.TestCaseSpec;
+import org.apache.shardingsphere.test.integration.junit.runner.parallel.annotaion.ParallelLevel;
+import org.apache.shardingsphere.test.integration.junit.runner.parallel.annotaion.ParallelRuntimeStrategy;
import org.junit.Test;
-import org.junit.runners.Parameterized.Parameters;
-import javax.xml.bind.JAXBException;
-import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.ParseException;
-import java.util.Collection;
import static org.junit.Assert.assertTrue;
+@TestCaseSpec(name = "GeneralDQLIT", sqlCommandType = SQLCommandType.DQL)
@ParallelRuntimeStrategy(ParallelLevel.CASE)
public final class GeneralDQLIT extends BaseDQLIT {
- private final IntegrationTestCaseAssertion assertion;
-
- public GeneralDQLIT(final AssertionParameterizedArray parameterizedArray) throws IOException, JAXBException, SQLException, ParseException {
- super(parameterizedArray);
- assertion = parameterizedArray.getAssertion();
- }
-
- @Parameters(name = "{0}")
- public static Collection<Object[]> getParameters() {
- return ParameterizedArrayFactory.getAssertionParameterizedArray(SQLCommandType.DQL);
- }
-
@Test
public void assertExecuteQuery() throws SQLException, ParseException {
try (Connection connection = getTargetDataSource().getConnection()) {
@@ -66,17 +49,17 @@ public final class GeneralDQLIT extends BaseDQLIT {
}
}
- private void assertExecuteQueryForStatement(final Connection connection) throws SQLException {
+ private void assertExecuteQueryForStatement(final Connection connection) throws SQLException, ParseException {
try (
Statement statement = connection.createStatement();
- ResultSet resultSet = statement.executeQuery(getSql())) {
+ ResultSet resultSet = statement.executeQuery(getStatement())) {
assertResultSet(resultSet);
}
}
private void assertExecuteQueryForPreparedStatement(final Connection connection) throws SQLException, ParseException {
- try (PreparedStatement preparedStatement = connection.prepareStatement(getSql())) {
- for (SQLValue each : assertion.getSQLValues()) {
+ try (PreparedStatement preparedStatement = connection.prepareStatement(getStatement())) {
+ for (SQLValue each : getAssertion().getSQLValues()) {
preparedStatement.setObject(each.getIndex(), each.getValue());
}
try (ResultSet resultSet = preparedStatement.executeQuery()) {
@@ -96,9 +79,9 @@ public final class GeneralDQLIT extends BaseDQLIT {
}
}
- private void assertExecuteForStatement(final Connection connection) throws SQLException {
+ private void assertExecuteForStatement(final Connection connection) throws SQLException, ParseException {
try (Statement statement = connection.createStatement()) {
- assertTrue("Not a query statement.", statement.execute(getSql()));
+ assertTrue("Not a query statement.", statement.execute(getStatement()));
try (ResultSet resultSet = statement.getResultSet()) {
assertResultSet(resultSet);
}
@@ -106,8 +89,8 @@ public final class GeneralDQLIT extends BaseDQLIT {
}
private void assertExecuteForPreparedStatement(final Connection connection) throws SQLException, ParseException {
- try (PreparedStatement preparedStatement = connection.prepareStatement(getSql())) {
- for (SQLValue each : assertion.getSQLValues()) {
+ try (PreparedStatement preparedStatement = connection.prepareStatement(getStatement())) {
+ for (SQLValue each : getAssertion().getSQLValues()) {
preparedStatement.setObject(each.getIndex(), each.getValue());
}
assertTrue("Not a query statement.", preparedStatement.execute());
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/ITParameterized.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/ITParameterized.java
deleted file mode 100644
index 1e9a507..0000000
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/ITParameterized.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.shardingsphere.test.integration.engine.junit;
-
-import org.apache.shardingsphere.test.integration.engine.junit.parallel.annotaion.ParallelRuntimeStrategy;
-import org.apache.shardingsphere.test.integration.engine.junit.parallel.ParallelRunnerScheduler;
-import org.junit.runners.Parameterized;
-
-/**
- * IT parameterized.
- */
-public final class ITParameterized extends Parameterized {
-
- //CHECKSTYLE:OFF
- public ITParameterized(final Class<?> klass) throws Throwable {
- //CHECKSTYLE:ON
- super(klass);
- ParallelRuntimeStrategy parallelRuntimeStrategy = klass.getAnnotation(ParallelRuntimeStrategy.class);
- if (null != parallelRuntimeStrategy) {
- setScheduler(new ParallelRunnerScheduler(parallelRuntimeStrategy.value()));
- }
- }
-}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/dbtbl_with_read_write_splitting/proxy/conf/config-dbtbl-with-read-write-splitting.yaml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/dbtbl_with_read_write_splitting/proxy/conf/config-dbtbl-with-read-write-splitting.yaml
index cb3fa9b..8041331 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/dbtbl_with_read_write_splitting/proxy/conf/config-dbtbl-with-read-write-splitting.yaml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/dbtbl_with_read_write_splitting/proxy/conf/config-dbtbl-with-read-write-splitting.yaml
@@ -19,7 +19,7 @@ schemaName: dbtbl_with_read_write_splitting
dataSources:
write_ds_0:
- url: jdbc:mysql://mysql.dbtbl-with-read-write-splitting.host:3306/write_ds_0?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
+ url: jdbc:mysql://mysql.db.host:3306/write_ds_0?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
username: root
password:
connectionTimeoutMilliseconds: 30000
@@ -29,7 +29,7 @@ dataSources:
minPoolSize: 2
maintenanceIntervalMilliseconds: 30000
write_ds_1:
- url: jdbc:mysql://mysql.dbtbl-with-read-write-splitting.host:3306/write_ds_1?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
+ url: jdbc:mysql://mysql.db.host:3306/write_ds_1?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
username: root
password:
connectionTimeoutMilliseconds: 30000
@@ -39,7 +39,7 @@ dataSources:
minPoolSize: 2
maintenanceIntervalMilliseconds: 30000
write_ds_2:
- url: jdbc:mysql://mysql.dbtbl-with-read-write-splitting.host:3306/write_ds_2?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
+ url: jdbc:mysql://mysql.db.host:3306/write_ds_2?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
username: root
password:
connectionTimeoutMilliseconds: 30000
@@ -49,7 +49,7 @@ dataSources:
minPoolSize: 2
maintenanceIntervalMilliseconds: 30000
write_ds_3:
- url: jdbc:mysql://mysql.dbtbl-with-read-write-splitting.host:3306/write_ds_3?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
+ url: jdbc:mysql://mysql.db.host:3306/write_ds_3?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
username: root
password:
connectionTimeoutMilliseconds: 30000
@@ -59,7 +59,7 @@ dataSources:
minPoolSize: 2
maintenanceIntervalMilliseconds: 30000
write_ds_4:
- url: jdbc:mysql://mysql.dbtbl-with-read-write-splitting.host:3306/write_ds_4?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
+ url: jdbc:mysql://mysql.db.host:3306/write_ds_4?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
username: root
password:
connectionTimeoutMilliseconds: 30000
@@ -69,7 +69,7 @@ dataSources:
minPoolSize: 2
maintenanceIntervalMilliseconds: 30000
write_ds_5:
- url: jdbc:mysql://mysql.dbtbl-with-read-write-splitting.host:3306/write_ds_5?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
+ url: jdbc:mysql://mysql.db.host:3306/write_ds_5?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
username: root
password:
connectionTimeoutMilliseconds: 30000
@@ -79,7 +79,7 @@ dataSources:
minPoolSize: 2
maintenanceIntervalMilliseconds: 30000
write_ds_6:
- url: jdbc:mysql://mysql.dbtbl-with-read-write-splitting.host:3306/write_ds_6?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
+ url: jdbc:mysql://mysql.db.host:3306/write_ds_6?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
username: root
password:
connectionTimeoutMilliseconds: 30000
@@ -89,7 +89,7 @@ dataSources:
minPoolSize: 2
maintenanceIntervalMilliseconds: 30000
write_ds_7:
- url: jdbc:mysql://mysql.dbtbl-with-read-write-splitting.host:3306/write_ds_7?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
+ url: jdbc:mysql://mysql.db.host:3306/write_ds_7?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
username: root
password:
connectionTimeoutMilliseconds: 30000
@@ -99,7 +99,7 @@ dataSources:
minPoolSize: 2
maintenanceIntervalMilliseconds: 30000
write_ds_8:
- url: jdbc:mysql://mysql.dbtbl-with-read-write-splitting.host:3306/write_ds_8?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
+ url: jdbc:mysql://mysql.db.host:3306/write_ds_8?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
username: root
password:
connectionTimeoutMilliseconds: 30000
@@ -109,7 +109,7 @@ dataSources:
minPoolSize: 2
maintenanceIntervalMilliseconds: 30000
write_ds_9:
- url: jdbc:mysql://mysql.dbtbl-with-read-write-splitting.host:3306/write_ds_9?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
+ url: jdbc:mysql://mysql.db.host:3306/write_ds_9?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
username: root
password:
connectionTimeoutMilliseconds: 30000
@@ -119,7 +119,7 @@ dataSources:
minPoolSize: 2
maintenanceIntervalMilliseconds: 30000
read_ds_0:
- url: jdbc:mysql://mysql.dbtbl-with-read-write-splitting.host:3306/read_ds_0?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
+ url: jdbc:mysql://mysql.db.host:3306/read_ds_0?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
username: root
password:
connectionTimeoutMilliseconds: 30000
@@ -129,7 +129,7 @@ dataSources:
minPoolSize: 2
maintenanceIntervalMilliseconds: 30000
read_ds_1:
- url: jdbc:mysql://mysql.dbtbl-with-read-write-splitting.host:3306/read_ds_1?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
+ url: jdbc:mysql://mysql.db.host:3306/read_ds_1?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
username: root
password:
connectionTimeoutMilliseconds: 30000
@@ -139,7 +139,7 @@ dataSources:
minPoolSize: 2
maintenanceIntervalMilliseconds: 30000
read_ds_2:
- url: jdbc:mysql://mysql.dbtbl-with-read-write-splitting.host:3306/read_ds_2?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
+ url: jdbc:mysql://mysql.db.host:3306/read_ds_2?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
username: root
password:
connectionTimeoutMilliseconds: 30000
@@ -149,7 +149,7 @@ dataSources:
minPoolSize: 2
maintenanceIntervalMilliseconds: 30000
read_ds_3:
- url: jdbc:mysql://mysql.dbtbl-with-read-write-splitting.host:3306/read_ds_3?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
+ url: jdbc:mysql://mysql.db.host:3306/read_ds_3?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
username: root
password:
connectionTimeoutMilliseconds: 30000
@@ -159,7 +159,7 @@ dataSources:
minPoolSize: 2
maintenanceIntervalMilliseconds: 30000
read_ds_4:
- url: jdbc:mysql://mysql.dbtbl-with-read-write-splitting.host:3306/read_ds_4?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
+ url: jdbc:mysql://mysql.db.host:3306/read_ds_4?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
username: root
password:
connectionTimeoutMilliseconds: 30000
@@ -169,7 +169,7 @@ dataSources:
minPoolSize: 2
maintenanceIntervalMilliseconds: 30000
read_ds_5:
- url: jdbc:mysql://mysql.dbtbl-with-read-write-splitting.host:3306/read_ds_5?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
+ url: jdbc:mysql://mysql.db.host:3306/read_ds_5?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
username: root
password:
connectionTimeoutMilliseconds: 30000
@@ -179,7 +179,7 @@ dataSources:
minPoolSize: 2
maintenanceIntervalMilliseconds: 30000
read_ds_6:
- url: jdbc:mysql://mysql.dbtbl-with-read-write-splitting.host:3306/read_ds_6?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
+ url: jdbc:mysql://mysql.db.host:3306/read_ds_6?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
username: root
password:
connectionTimeoutMilliseconds: 30000
@@ -189,7 +189,7 @@ dataSources:
minPoolSize: 2
maintenanceIntervalMilliseconds: 30000
read_ds_7:
- url: jdbc:mysql://mysql.dbtbl-with-read-write-splitting.host:3306/read_ds_7?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
+ url: jdbc:mysql://mysql.db.host:3306/read_ds_7?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
username: root
password:
connectionTimeoutMilliseconds: 30000
@@ -199,7 +199,7 @@ dataSources:
minPoolSize: 2
maintenanceIntervalMilliseconds: 30000
read_ds_8:
- url: jdbc:mysql://mysql.dbtbl-with-read-write-splitting.host:3306/read_ds_8?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
+ url: jdbc:mysql://mysql.db.host:3306/read_ds_8?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
username: root
password:
connectionTimeoutMilliseconds: 30000
@@ -209,7 +209,7 @@ dataSources:
minPoolSize: 2
maintenanceIntervalMilliseconds: 30000
read_ds_9:
- url: jdbc:mysql://mysql.dbtbl-with-read-write-splitting.host:3306/read_ds_9?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
+ url: jdbc:mysql://mysql.db.host:3306/read_ds_9?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
username: root
password:
connectionTimeoutMilliseconds: 30000
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/dbtbl_with_read_write_splitting_and_encrypt/proxy/conf/config-dbtbl-with-read-write-splitting-and-encrypt.yaml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/dbtbl_with_read_write_splitting_and_encrypt/proxy/conf/config-dbtbl-with-read-write-splitting-and-encrypt.yaml
index d447340..ff370a2 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/dbtbl_with_read_write_splitting_and_encrypt/proxy/conf/config-dbtbl-with-read-write-splitting-and-encrypt.yaml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/dbtbl_with_read_write_splitting_and_encrypt/proxy/conf/config-dbtbl-with-read-write-splitting-and-encrypt.yaml
@@ -19,7 +19,7 @@ schemaName: dbtbl_with_read_write_splitting_and_encrypt
dataSources:
encrypt_write_ds_0:
- url: jdbc:mysql://mysql.dbtbl-with-read-write-splitting-and-encrypt.host:3306/encrypt_write_ds_0?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
+ url: jdbc:mysql://mysql.db.host:3306/encrypt_write_ds_0?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
username: root
password:
connectionTimeoutMilliseconds: 30000
@@ -29,7 +29,7 @@ dataSources:
minPoolSize: 2
maintenanceIntervalMilliseconds: 30000
encrypt_write_ds_1:
- url: jdbc:mysql://mysql.dbtbl-with-read-write-splitting-and-encrypt.host:3306/encrypt_write_ds_1?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
+ url: jdbc:mysql://mysql.db.host:3306/encrypt_write_ds_1?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
username: root
password:
connectionTimeoutMilliseconds: 30000
@@ -39,7 +39,7 @@ dataSources:
minPoolSize: 2
maintenanceIntervalMilliseconds: 30000
encrypt_write_ds_2:
- url: jdbc:mysql://mysql.dbtbl-with-read-write-splitting-and-encrypt.host:3306/encrypt_write_ds_2?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
+ url: jdbc:mysql://mysql.db.host:3306/encrypt_write_ds_2?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
username: root
password:
connectionTimeoutMilliseconds: 30000
@@ -49,7 +49,7 @@ dataSources:
minPoolSize: 2
maintenanceIntervalMilliseconds: 30000
encrypt_write_ds_3:
- url: jdbc:mysql://mysql.dbtbl-with-read-write-splitting-and-encrypt.host:3306/encrypt_write_ds_3?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
+ url: jdbc:mysql://mysql.db.host:3306/encrypt_write_ds_3?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
username: root
password:
connectionTimeoutMilliseconds: 30000
@@ -59,7 +59,7 @@ dataSources:
minPoolSize: 2
maintenanceIntervalMilliseconds: 30000
encrypt_write_ds_4:
- url: jdbc:mysql://mysql.dbtbl-with-read-write-splitting-and-encrypt.host:3306/encrypt_write_ds_4?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
+ url: jdbc:mysql://mysql.db.host:3306/encrypt_write_ds_4?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
username: root
password:
connectionTimeoutMilliseconds: 30000
@@ -69,7 +69,7 @@ dataSources:
minPoolSize: 2
maintenanceIntervalMilliseconds: 30000
encrypt_write_ds_5:
- url: jdbc:mysql://mysql.dbtbl-with-read-write-splitting-and-encrypt.host:3306/encrypt_write_ds_5?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
+ url: jdbc:mysql://mysql.db.host:3306/encrypt_write_ds_5?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
username: root
password:
connectionTimeoutMilliseconds: 30000
@@ -79,7 +79,7 @@ dataSources:
minPoolSize: 2
maintenanceIntervalMilliseconds: 30000
encrypt_write_ds_6:
- url: jdbc:mysql://mysql.dbtbl-with-read-write-splitting-and-encrypt.host:3306/encrypt_write_ds_6?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
+ url: jdbc:mysql://mysql.db.host:3306/encrypt_write_ds_6?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
username: root
password:
connectionTimeoutMilliseconds: 30000
@@ -89,7 +89,7 @@ dataSources:
minPoolSize: 2
maintenanceIntervalMilliseconds: 30000
encrypt_write_ds_7:
- url: jdbc:mysql://mysql.dbtbl-with-read-write-splitting-and-encrypt.host:3306/encrypt_write_ds_7?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
+ url: jdbc:mysql://mysql.db.host:3306/encrypt_write_ds_7?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
username: root
password:
connectionTimeoutMilliseconds: 30000
@@ -99,7 +99,7 @@ dataSources:
minPoolSize: 2
maintenanceIntervalMilliseconds: 30000
encrypt_write_ds_8:
- url: jdbc:mysql://mysql.dbtbl-with-read-write-splitting-and-encrypt.host:3306/encrypt_write_ds_8?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
+ url: jdbc:mysql://mysql.db.host:3306/encrypt_write_ds_8?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
username: root
password:
connectionTimeoutMilliseconds: 30000
@@ -109,7 +109,7 @@ dataSources:
minPoolSize: 2
maintenanceIntervalMilliseconds: 30000
encrypt_write_ds_9:
- url: jdbc:mysql://mysql.dbtbl-with-read-write-splitting-and-encrypt.host:3306/encrypt_write_ds_9?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
+ url: jdbc:mysql://mysql.db.host:3306/encrypt_write_ds_9?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
username: root
password:
connectionTimeoutMilliseconds: 30000
@@ -119,7 +119,7 @@ dataSources:
minPoolSize: 2
maintenanceIntervalMilliseconds: 30000
encrypt_read_ds_0:
- url: jdbc:mysql://mysql.dbtbl-with-read-write-splitting-and-encrypt.host:3306/encrypt_read_ds_0?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
+ url: jdbc:mysql://mysql.db.host:3306/encrypt_read_ds_0?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
username: root
password:
connectionTimeoutMilliseconds: 30000
@@ -129,7 +129,7 @@ dataSources:
minPoolSize: 2
maintenanceIntervalMilliseconds: 30000
encrypt_read_ds_1:
- url: jdbc:mysql://mysql.dbtbl-with-read-write-splitting-and-encrypt.host:3306/encrypt_read_ds_1?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
+ url: jdbc:mysql://mysql.db.host:3306/encrypt_read_ds_1?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
username: root
password:
connectionTimeoutMilliseconds: 30000
@@ -139,7 +139,7 @@ dataSources:
minPoolSize: 2
maintenanceIntervalMilliseconds: 30000
encrypt_read_ds_2:
- url: jdbc:mysql://mysql.dbtbl-with-read-write-splitting-and-encrypt.host:3306/encrypt_read_ds_2?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
+ url: jdbc:mysql://mysql.db.host:3306/encrypt_read_ds_2?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
username: root
password:
connectionTimeoutMilliseconds: 30000
@@ -149,7 +149,7 @@ dataSources:
minPoolSize: 2
maintenanceIntervalMilliseconds: 30000
encrypt_read_ds_3:
- url: jdbc:mysql://mysql.dbtbl-with-read-write-splitting-and-encrypt.host:3306/encrypt_read_ds_3?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
+ url: jdbc:mysql://mysql.db.host:3306/encrypt_read_ds_3?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
username: root
password:
connectionTimeoutMilliseconds: 30000
@@ -159,7 +159,7 @@ dataSources:
minPoolSize: 2
maintenanceIntervalMilliseconds: 30000
encrypt_read_ds_4:
- url: jdbc:mysql://mysql.dbtbl-with-read-write-splitting-and-encrypt.host:3306/encrypt_read_ds_4?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
+ url: jdbc:mysql://mysql.db.host:3306/encrypt_read_ds_4?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
username: root
password:
connectionTimeoutMilliseconds: 30000
@@ -169,7 +169,7 @@ dataSources:
minPoolSize: 2
maintenanceIntervalMilliseconds: 30000
encrypt_read_ds_5:
- url: jdbc:mysql://mysql.dbtbl-with-read-write-splitting-and-encrypt.host:3306/encrypt_read_ds_5?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
+ url: jdbc:mysql://mysql.db.host:3306/encrypt_read_ds_5?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
username: root
password:
connectionTimeoutMilliseconds: 30000
@@ -179,7 +179,7 @@ dataSources:
minPoolSize: 2
maintenanceIntervalMilliseconds: 30000
encrypt_read_ds_6:
- url: jdbc:mysql://mysql.dbtbl-with-read-write-splitting-and-encrypt.host:3306/encrypt_read_ds_6?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
+ url: jdbc:mysql://mysql.db.host:3306/encrypt_read_ds_6?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
username: root
password:
connectionTimeoutMilliseconds: 30000
@@ -189,7 +189,7 @@ dataSources:
minPoolSize: 2
maintenanceIntervalMilliseconds: 30000
encrypt_read_ds_7:
- url: jdbc:mysql://mysql.dbtbl-with-read-write-splitting-and-encrypt.host:3306/encrypt_read_ds_7?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
+ url: jdbc:mysql://mysql.db.host:3306/encrypt_read_ds_7?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
username: root
password:
connectionTimeoutMilliseconds: 30000
@@ -199,7 +199,7 @@ dataSources:
minPoolSize: 2
maintenanceIntervalMilliseconds: 30000
encrypt_read_ds_8:
- url: jdbc:mysql://mysql.dbtbl-with-read-write-splitting-and-encrypt.host:3306/encrypt_read_ds_8?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
+ url: jdbc:mysql://mysql.db.host:3306/encrypt_read_ds_8?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
username: root
password:
connectionTimeoutMilliseconds: 30000
@@ -209,7 +209,7 @@ dataSources:
minPoolSize: 2
maintenanceIntervalMilliseconds: 30000
encrypt_read_ds_9:
- url: jdbc:mysql://mysql.dbtbl-with-read-write-splitting-and-encrypt.host:3306/encrypt_read_ds_9?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
+ url: jdbc:mysql://mysql.db.host:3306/encrypt_read_ds_9?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
username: root
password:
connectionTimeoutMilliseconds: 30000
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/encrypt/proxy/conf/config-encrypt.yaml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/encrypt/proxy/conf/config-encrypt.yaml
index 1458461..59ef2bc 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/encrypt/proxy/conf/config-encrypt.yaml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/encrypt/proxy/conf/config-encrypt.yaml
@@ -19,7 +19,7 @@ schemaName: encrypt
dataSources:
encrypt:
- url: jdbc:mysql://mysql.encrypt.host:3306/encrypt?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
+ url: jdbc:mysql://mysql.db.host:3306/encrypt?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
username: root
password:
connectionTimeoutMilliseconds: 30000
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/read_write_splitting/proxy/conf/config-read-write-splitting.yaml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/read_write_splitting/proxy/conf/config-read-write-splitting.yaml
index 9a59c42..b127425 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/read_write_splitting/proxy/conf/config-read-write-splitting.yaml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/read_write_splitting/proxy/conf/config-read-write-splitting.yaml
@@ -19,7 +19,7 @@ schemaName: read_write_splitting
dataSources:
write_ds:
- url: jdbc:mysql://mysql.read-write-splitting.host:3306/write_ds?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
+ url: jdbc:mysql://mysql.db.host:3306/write_ds?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
username: root
password:
connectionTimeoutMilliseconds: 30000
@@ -29,7 +29,7 @@ dataSources:
minPoolSize: 2
maintenanceIntervalMilliseconds: 30000
read_0:
- url: jdbc:mysql://mysql.read-write-splitting.host:3306/read_0?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
+ url: jdbc:mysql://mysql.db.host:3306/read_0?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
username: root
password:
connectionTimeoutMilliseconds: 30000
@@ -39,7 +39,7 @@ dataSources:
minPoolSize: 2
maintenanceIntervalMilliseconds: 30000
read_1:
- url: jdbc:mysql://mysql.read-write-splitting.host:3306/read_1?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
+ url: jdbc:mysql://mysql.db.host:3306/read_1?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
username: root
password:
connectionTimeoutMilliseconds: 30000
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/tbl/proxy/conf/config-tbl.yaml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/tbl/proxy/conf/config-tbl.yaml
index 12c9198..65bafbb 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/tbl/proxy/conf/config-tbl.yaml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/tbl/proxy/conf/config-tbl.yaml
@@ -19,7 +19,7 @@ schemaName: tbl
dataSources:
tbl:
- url: jdbc:mysql://mysql.tbl.host:3306/tbl?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
+ url: jdbc:mysql://mysql.db.host:3306/tbl?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
username: root
password:
connectionTimeoutMilliseconds: 30000
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/logback-test.xml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/logback-test.xml
index d90fc4a..0c97702 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/logback-test.xml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/logback-test.xml
@@ -22,12 +22,7 @@
<pattern>[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %logger{36} - %msg%n</pattern>
</encoder>
</appender>
- <logger name="org.apache.shardingsphere" level="warn" additivity="false">
+ <logger name="org.apache.shardingsphere" level="info" additivity="true">
<appender-ref ref="console" />
</logger>
-
- <root>
- <level value="error" />
- <appender-ref ref="console" />
- </root>
</configuration>