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

tuichenchuxin 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 ed2ccd1951a Optimize distributed transaction integration test 
execution time (#20086)
ed2ccd1951a is described below

commit ed2ccd1951a48010587533d701d787c77e6f750e
Author: ZhangCheng <[email protected]>
AuthorDate: Fri Aug 12 14:00:28 2022 +0800

    Optimize distributed transaction integration test execution time (#20086)
    
    * Optimize distributed transaction integration test execution time
    
    * Fix test case error
    
    * Remove bitronix test cases to reduce execution time
    
    * Test error
    
    * Test error
    
    * Test error
    
    * Test error
    
    * Test error
    
    * Fix test case error
---
 .github/workflows/it-transaction.yml               |  8 +---
 .../cases/alterresource/AddResourceTestCase.java   |  2 +-
 .../cases/alterresource/CloseResourceTestCase.java |  2 +-
 .../autocommit/PostgresSQLAutoCommitTestCase.java  |  3 +-
 .../cases/base/BaseTransactionTestCase.java        | 23 ++++++++-
 .../transaction/engine/base/BaseITCase.java        | 54 ++++++++++++++--------
 .../engine/base/BaseTransactionITCase.java         | 12 +++++
 .../engine/base/TransactionTestCase.java           |  7 +++
 .../engine/mysql/MySQLJdbcTransactionIT.java       |  7 +--
 .../engine/mysql/MySQLProxyTransactionIT.java      |  8 +---
 .../opengauss/OpenGaussJdbcTransactionIT.java      |  3 +-
 .../opengauss/OpenGaussProxyTransactionIT.java     |  3 +-
 .../postgresql/PostgreSQLJdbcTransactionIT.java    |  3 +-
 .../postgresql/PostgreSQLProxyTransactionIT.java   |  3 +-
 .../framework/param/TransactionParameterized.java  |  8 +++-
 .../resources/env/transaction-it-env.properties    |  2 +-
 16 files changed, 92 insertions(+), 56 deletions(-)

diff --git a/.github/workflows/it-transaction.yml 
b/.github/workflows/it-transaction.yml
index a680a06f640..23abbdd9f14 100644
--- a/.github/workflows/it-transaction.yml
+++ b/.github/workflows/it-transaction.yml
@@ -58,7 +58,7 @@ jobs:
       postgresql_version: postgres:12-alpine
       opengauss_version: enmotech/opengauss:2.1.0
       mysql_version: 5.7
-    timeout-minutes: 120
+    timeout-minutes: 80
     steps:
       - uses: actions/checkout@v3
       - name: Cache Maven Repos
@@ -77,23 +77,17 @@ jobs:
         run: ./mvnw -nsu -B install -f 
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/pom.xml
 -Dtransaction.it.env.type=docker -Dtransaction.it.env.transtypes=LOCAL 
-Dtransaction.it.docker.mysql.version=${{ env.mysql_version }}
       - name: Run Transaction MySQL Integration Test With Atomikos
         run: ./mvnw -nsu -B install -f 
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/pom.xml
 -Dtransaction.it.env.type=docker -Dtransaction.it.env.transtypes=XA 
-Dtransaction.it.env.xa.providers=Atomikos 
-Dtransaction.it.docker.mysql.version=${{ env.mysql_version }}
-      - name: Run Transaction MySQL Integration Test With Bitronix
-        run: ./mvnw -nsu -B install -f 
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/pom.xml
 -Dtransaction.it.env.type=docker -Dtransaction.it.env.transtypes=XA 
-Dtransaction.it.env.xa.providers=Bitronix 
-Dtransaction.it.docker.mysql.version=${{ env.mysql_version }}
       - name: Run Transaction MySQL Integration Test With Narayana
         run: ./mvnw -nsu -B install -f 
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/pom.xml
 -Dtransaction.it.env.type=docker -Dtransaction.it.env.transtypes=XA 
-Dtransaction.it.env.xa.providers=Narayana 
-Dtransaction.it.docker.mysql.version=${{ env.mysql_version }}
       - name: Run PostgreSQL Local Transaction Integration Test
         run: ./mvnw -nsu -B install -f 
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/pom.xml
 -Dtransaction.it.env.type=docker -Dtransaction.it.env.transtypes=LOCAL 
-Dtransaction.it.docker.postgresql.version=${{ env.postgresql_version }}
       - name: Run Transaction PostgreSQL Integration Test With Atomikos
         run: ./mvnw -nsu -B install -f 
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/pom.xml
 -Dtransaction.it.env.type=docker -Dtransaction.it.env.transtypes=XA 
-Dtransaction.it.env.xa.providers=Atomikos 
-Dtransaction.it.docker.postgresql.version=${{ env.postgresql_version }}
-      - name: Run Transaction PostgreSQL Integration Test With Bitronix
-        run: ./mvnw -nsu -B install -f 
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/pom.xml
 -Dtransaction.it.env.type=docker -Dtransaction.it.env.transtypes=XA 
-Dtransaction.it.env.xa.providers=Bitronix 
-Dtransaction.it.docker.postgresql.version=${{ env.postgresql_version }}
       - name: Run Transaction PostgreSQL Integration Test With Narayana
         run: ./mvnw -nsu -B install -f 
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/pom.xml
 -Dtransaction.it.env.type=docker -Dtransaction.it.env.transtypes=XA 
-Dtransaction.it.env.xa.providers=Narayana 
-Dtransaction.it.docker.postgresql.version=${{ env.postgresql_version }}
       - name: Run OpenGauss Local Transaction Integration Test
         run: ./mvnw -nsu -B install -f 
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/pom.xml
 -Dtransaction.it.env.type=docker -Dtransaction.it.env.transtypes=LOCAL 
-Dtransaction.it.docker.opengauss.version=${{ env.opengauss_version }}
       - name: Run Transaction OpenGauss Integration Test With Atomikos
         run: ./mvnw -nsu -B install -f 
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/pom.xml
 -Dtransaction.it.env.type=docker -Dtransaction.it.env.transtypes=XA 
-Dtransaction.it.env.xa.providers=Atomikos 
-Dtransaction.it.docker.opengauss.version=${{ env.opengauss_version }}
-      - name: Run Transaction OpenGauss Integration Test With Bitronix
-        run: ./mvnw -nsu -B install -f 
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/pom.xml
 -Dtransaction.it.env.type=docker -Dtransaction.it.env.transtypes=XA 
-Dtransaction.it.env.xa.providers=Bitronix 
-Dtransaction.it.docker.opengauss.version=${{ env.opengauss_version }}
       - name: Run Transaction OpenGauss Integration Test With Narayana
         run: ./mvnw -nsu -B install -f 
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/pom.xml
 -Dtransaction.it.env.type=docker -Dtransaction.it.env.transtypes=XA 
-Dtransaction.it.env.xa.providers=Narayana 
-Dtransaction.it.docker.opengauss.version=${{ env.opengauss_version }}
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/alterresource/AddResourceTestCase.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/alterresource/AddResourceTestCase.java
index dc160c3e7f8..ccc65895c6e 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/alterresource/AddResourceTestCase.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/alterresource/AddResourceTestCase.java
@@ -32,7 +32,7 @@ import java.sql.SQLException;
  * Integration test of add resource.
  */
 @Slf4j
-@TransactionTestCase(adapters = TransactionTestConstants.PROXY)
+@TransactionTestCase(adapters = TransactionTestConstants.PROXY, group = 
"addResource")
 public final class AddResourceTestCase extends BaseTransactionTestCase {
     
     public AddResourceTestCase(final BaseTransactionITCase 
baseTransactionITCase, final DataSource dataSource) {
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/alterresource/CloseResourceTestCase.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/alterresource/CloseResourceTestCase.java
index 92f4815b91c..ec76d24fdd2 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/alterresource/CloseResourceTestCase.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/alterresource/CloseResourceTestCase.java
@@ -32,7 +32,7 @@ import java.sql.SQLException;
  * Integration test of close resource.
  */
 @Slf4j
-@TransactionTestCase(adapters = TransactionTestConstants.PROXY)
+@TransactionTestCase(adapters = TransactionTestConstants.PROXY, group = 
"closeResource")
 public final class CloseResourceTestCase extends BaseTransactionTestCase {
     
     public CloseResourceTestCase(final BaseTransactionITCase 
baseTransactionITCase, final DataSource dataSource) {
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/autocommit/PostgresSQLAutoCommitTestCase.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/autocommit/PostgresSQLAutoCommitTestCase.java
index 4bd19d2ed13..ef0b0aa05f8 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/autocommit/PostgresSQLAutoCommitTestCase.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/autocommit/PostgresSQLAutoCommitTestCase.java
@@ -53,8 +53,6 @@ public final class PostgresSQLAutoCommitTestCase extends 
BaseTransactionTestCase
     private void assertAutoCommit() throws SQLException {
         Connection conn1 = getDataSource().getConnection();
         Connection conn2 = getDataSource().getConnection();
-        executeWithLog(conn1, "set transaction isolation level read 
committed;");
-        executeWithLog(conn2, "set transaction isolation level read 
committed;");
         executeWithLog(conn1, "begin;");
         executeWithLog(conn2, "begin;");
         executeWithLog(conn1, "insert into account(id, balance, 
transaction_id) values(1, 100, 1)");
@@ -68,5 +66,6 @@ public final class PostgresSQLAutoCommitTestCase extends 
BaseTransactionTestCase
         if (!notEmptyResultSet.next()) {
             fail("There should be result.");
         }
+        executeWithLog(conn2, "commit;");
     }
 }
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/base/BaseTransactionTestCase.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/base/BaseTransactionTestCase.java
index 8b891bd0c54..77f969c1539 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/base/BaseTransactionTestCase.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/base/BaseTransactionTestCase.java
@@ -49,10 +49,31 @@ public abstract class BaseTransactionTestCase {
         this.dataSource = dataSource;
     }
     
+    /**
+     * Execute test cases.
+     */
+    public void execute() {
+        beforeTest();
+        executeTest();
+        afterTest();
+    }
+    
     /**
      * Integration testing method with assertions.
      */
-    public abstract void executeTest();
+    protected abstract void executeTest();
+    
+    @SneakyThrows(SQLException.class)
+    protected void beforeTest() {
+        Connection conn = getDataSource().getConnection();
+        executeWithLog(conn, "delete from account;");
+        executeWithLog(conn, "delete from t_order;");
+        executeWithLog(conn, "delete from t_order_item;");
+        conn.close();
+    }
+    
+    protected void afterTest() {
+    }
     
     @SneakyThrows(SQLException.class)
     protected static void executeWithLog(final Connection connection, final 
String sql) {
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/base/BaseITCase.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/base/BaseITCase.java
index e1d532b1da5..6a0eb0a4698 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/base/BaseITCase.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/base/BaseITCase.java
@@ -48,6 +48,7 @@ import 
org.apache.shardingsphere.transaction.core.TransactionType;
 
 import javax.sql.DataSource;
 import javax.xml.bind.JAXB;
+import java.io.File;
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.ResultSet;
@@ -55,6 +56,7 @@ import java.sql.SQLException;
 import java.sql.Statement;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.LinkedHashMap;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
@@ -176,11 +178,12 @@ public abstract class BaseITCase {
     
     private static void addParametersByVersions(final List<String> 
databaseVersion, final Collection<TransactionParameterized> result, final 
TransactionTestCaseRegistry currentTestCaseInfo) {
         for (String each : databaseVersion) {
-            addParametersByTestCaseClasses(result, each, currentTestCaseInfo);
+            result.addAll(addParametersByTestCaseClasses(each, 
currentTestCaseInfo));
         }
     }
     
-    private static void addParametersByTestCaseClasses(final 
Collection<TransactionParameterized> result, final String version, final 
TransactionTestCaseRegistry currentTestCaseInfo) {
+    private static Collection<TransactionParameterized> 
addParametersByTestCaseClasses(final String version, final 
TransactionTestCaseRegistry currentTestCaseInfo) {
+        Map<String, TransactionParameterized> parameterizedMap = new 
LinkedHashMap<>();
         for (Class<? extends BaseTransactionTestCase> caseClass : TEST_CASES) {
             if (!ENV.getNeedToRunTestCases().isEmpty() && 
!ENV.getNeedToRunTestCases().contains(caseClass.getSimpleName())) {
                 log.info("Collect transaction test case, need to run cases 
don't contain this, skip: {}.", caseClass.getName());
@@ -201,42 +204,54 @@ public abstract class BaseITCase {
                 log.info("Collect transaction test case, runAdapter is not 
matched, skip: {}.", caseClass.getName());
                 continue;
             }
-            addParametersByTransactionTypes(result, version, 
currentTestCaseInfo, caseClass, annotation);
+            String group = annotation.group();
+            addParametersByTransactionTypes(version, currentTestCaseInfo, 
caseClass, annotation, parameterizedMap, group);
         }
+        
+        return parameterizedMap.values();
     }
     
-    private static void addParametersByTransactionTypes(final 
Collection<TransactionParameterized> result, final String version, final 
TransactionTestCaseRegistry currentTestCaseInfo,
-                                                        final Class<? extends 
BaseTransactionTestCase> caseClass, final TransactionTestCase annotation) {
+    private static void addParametersByTransactionTypes(final String version, 
final TransactionTestCaseRegistry currentTestCaseInfo,
+                                                        final Class<? extends 
BaseTransactionTestCase> caseClass, final TransactionTestCase annotation,
+                                                        final Map<String, 
TransactionParameterized> parameterizedMap, final String group) {
         for (TransactionType each : annotation.transactionTypes()) {
             if (!ENV.getAllowTransactionTypes().isEmpty() && 
!ENV.getAllowTransactionTypes().contains(each.toString())) {
                 log.info("Collect transaction test case, need to run 
transaction types don't contain this, skip: {}-{}.", caseClass.getName(), each);
                 continue;
             }
-            addParametersByTransactionProviders(result, version, 
currentTestCaseInfo, caseClass, each);
+            addParametersByTransactionProviders(version, currentTestCaseInfo, 
caseClass, each, parameterizedMap, group);
         }
     }
     
-    private static void addParametersByTransactionProviders(final 
Collection<TransactionParameterized> result, final String version, final 
TransactionTestCaseRegistry currentTestCaseInfo,
-                                                            final Class<? 
extends BaseTransactionTestCase> caseClass, final TransactionType each) {
+    private static void addParametersByTransactionProviders(final String 
version, final TransactionTestCaseRegistry currentTestCaseInfo,
+                                                            final Class<? 
extends BaseTransactionTestCase> caseClass, final TransactionType each,
+                                                            final Map<String, 
TransactionParameterized> parameterizedMap, final String group) {
         if (TransactionType.LOCAL.equals(each)) {
-            result.add(createTransactionParameter(version, 
currentTestCaseInfo, caseClass, each, ""));
+            addTestParameters(version, currentTestCaseInfo, caseClass, each, 
"", parameterizedMap, group);
         } else if (TransactionType.XA.equals(each)) {
             if (ENV.getAllowXAProviders().isEmpty()) {
                 for (String provider : ALL_XA_PROVIDERS) {
-                    result.add(createTransactionParameter(version, 
currentTestCaseInfo, caseClass, each, provider));
+                    addTestParameters(version, currentTestCaseInfo, caseClass, 
each, provider, parameterizedMap, group);
                 }
             } else {
                 for (String provider : ENV.getAllowXAProviders()) {
-                    result.add(createTransactionParameter(version, 
currentTestCaseInfo, caseClass, each, provider));
+                    addTestParameters(version, currentTestCaseInfo, caseClass, 
each, provider, parameterizedMap, group);
                 }
             }
         }
     }
     
-    private static TransactionParameterized createTransactionParameter(final 
String version, final TransactionTestCaseRegistry currentTestCaseInfo,
-                                                                       final 
Class<? extends BaseTransactionTestCase> caseClass, final TransactionType 
transactionType, final String provider) {
-        return new 
TransactionParameterized(getSqlDatabaseType(currentTestCaseInfo.getDbType()), 
currentTestCaseInfo.getRunningAdaptor(), transactionType, provider,
-                getDockerImageName(currentTestCaseInfo.getDbType(), version), 
caseClass);
+    private static void addTestParameters(final String version, final 
TransactionTestCaseRegistry currentTestCaseInfo,
+                                          final Class<? extends 
BaseTransactionTestCase> caseClass, final TransactionType transactionType, 
final String provider,
+                                          final Map<String, 
TransactionParameterized> parameterizedMap, final String group) {
+        String uniqueKey = getUniqueKey(currentTestCaseInfo.getDbType(), 
currentTestCaseInfo.getRunningAdaptor(), transactionType, provider, group);
+        parameterizedMap.putIfAbsent(uniqueKey, new 
TransactionParameterized(getSqlDatabaseType(currentTestCaseInfo.getDbType()), 
currentTestCaseInfo.getRunningAdaptor(), transactionType, provider,
+                getDockerImageName(currentTestCaseInfo.getDbType(), version), 
group, new LinkedList<>()));
+        
parameterizedMap.get(uniqueKey).getTransactionTestCaseClasses().add(caseClass);
+    }
+    
+    private static String getUniqueKey(final String dbType, final String 
runningAdapter, final TransactionType transactionType, final String provider, 
final String group) {
+        return dbType + File.separator + runningAdapter + File.separator + 
transactionType + File.separator + provider + File.separator + group;
     }
     
     private static DatabaseType getSqlDatabaseType(final String databaseType) {
@@ -362,8 +377,7 @@ public abstract class BaseITCase {
     }
     
     protected AutoDataSource getProxyDataSource(final String databaseName) {
-        AutoDataSource result = new ProxyDataSource(composedContainer, 
databaseName, ENV.getProxyUserName(), ENV.getProxyPassword());
-        return result;
+        return new ProxyDataSource(composedContainer, databaseName, 
ENV.getProxyUserName(), ENV.getProxyPassword());
     }
     
     protected boolean waitShardingAlgorithmEffect(final int maxWaitTimes) {
@@ -411,7 +425,7 @@ public abstract class BaseITCase {
     
     /**
      * Add ds_2 resource to proxy.
-     * 
+     *
      * @param connection connection
      */
     @SneakyThrows({SQLException.class, InterruptedException.class})
@@ -428,7 +442,7 @@ public abstract class BaseITCase {
     
     /**
      * Drop previous account table rule and create the table rule with three 
data sources.
-     * 
+     *
      * @param connection connection
      */
     @SneakyThrows(SQLException.class)
@@ -441,7 +455,7 @@ public abstract class BaseITCase {
     
     /**
      * Create the account table rule with one data source.
-     * 
+     *
      * @param connection connection
      */
     @SneakyThrows(SQLException.class)
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/base/BaseTransactionITCase.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/base/BaseTransactionITCase.java
index e9d39ddab13..52a86f32521 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/base/BaseTransactionITCase.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/base/BaseTransactionITCase.java
@@ -20,10 +20,12 @@ package 
org.apache.shardingsphere.integration.transaction.engine.base;
 import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.shardingsphere.data.pipeline.core.util.ThreadUtil;
+import 
org.apache.shardingsphere.integration.transaction.cases.base.BaseTransactionTestCase;
 import 
org.apache.shardingsphere.integration.transaction.engine.constants.TransactionTestConstants;
 import 
org.apache.shardingsphere.integration.transaction.framework.param.TransactionParameterized;
 import org.apache.shardingsphere.transaction.core.TransactionType;
 
+import javax.sql.DataSource;
 import java.sql.Connection;
 import java.sql.ResultSet;
 import java.sql.SQLException;
@@ -197,4 +199,14 @@ public abstract class BaseTransactionITCase extends 
BaseITCase {
         statement.close();
         return result;
     }
+    
+    @SneakyThrows
+    protected void callTestCases(final TransactionParameterized parameterized) 
{
+        for (Class<? extends BaseTransactionTestCase> each : 
parameterized.getTransactionTestCaseClasses()) {
+            log.info("Transaction IT {} -> {} test begin.", parameterized, 
each.getSimpleName());
+            each.getConstructor(BaseTransactionITCase.class, 
DataSource.class).newInstance(this, getDataSource()).execute();
+            log.info("Transaction IT {} -> {} test end.", parameterized, 
each.getSimpleName());
+            getDataSource().close();
+        }
+    }
 }
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/base/TransactionTestCase.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/base/TransactionTestCase.java
index dce402758b8..428e8fdfc41 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/base/TransactionTestCase.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/base/TransactionTestCase.java
@@ -51,4 +51,11 @@ public @interface TransactionTestCase {
      * @return transaction types
      */
     TransactionType[] transactionTypes() default {TransactionType.LOCAL, 
TransactionType.XA, TransactionType.BASE};
+    
+    /**
+     * Specifies which group the test case belongs to.
+     * 
+     * @return test group
+     */
+    String group() default "default";
 }
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/mysql/MySQLJdbcTransactionIT.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/mysql/MySQLJdbcTransactionIT.java
index e62e6296e07..93fa2b63d83 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/mysql/MySQLJdbcTransactionIT.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/mysql/MySQLJdbcTransactionIT.java
@@ -27,7 +27,6 @@ import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 import org.junit.runners.Parameterized.Parameters;
 
-import javax.sql.DataSource;
 import java.sql.SQLException;
 import java.util.Collection;
 
@@ -61,11 +60,7 @@ public final class MySQLJdbcTransactionIT extends 
BaseTransactionITCase {
     @Test
     @SneakyThrows
     public void assertTransaction() {
-        callTestCases();
+        callTestCases(parameterized);
     }
     
-    @SneakyThrows
-    private void callTestCases() {
-        
parameterized.getTransactionTestCaseClass().getConstructor(BaseTransactionITCase.class,
 DataSource.class).newInstance(this, getDataSource()).executeTest();
-    }
 }
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/mysql/MySQLProxyTransactionIT.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/mysql/MySQLProxyTransactionIT.java
index a10551f95c7..b20b71c72ee 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/mysql/MySQLProxyTransactionIT.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/mysql/MySQLProxyTransactionIT.java
@@ -30,7 +30,6 @@ import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 import org.junit.runners.Parameterized.Parameters;
 
-import javax.sql.DataSource;
 import java.sql.SQLException;
 import java.util.Collection;
 import java.util.Objects;
@@ -77,12 +76,7 @@ public final class MySQLProxyTransactionIT extends 
BaseTransactionITCase {
     @Test
     @SneakyThrows
     public void assertTransaction() {
-        callTestCases();
-    }
-    
-    @SneakyThrows
-    private void callTestCases() {
-        
parameterized.getTransactionTestCaseClass().getConstructor(BaseTransactionITCase.class,
 DataSource.class).newInstance(this, getDataSource()).executeTest();
+        callTestCases(parameterized);
     }
     
 }
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/opengauss/OpenGaussJdbcTransactionIT.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/opengauss/OpenGaussJdbcTransactionIT.java
index b7e55c9f74a..4d442403597 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/opengauss/OpenGaussJdbcTransactionIT.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/opengauss/OpenGaussJdbcTransactionIT.java
@@ -27,7 +27,6 @@ import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 import org.junit.runners.Parameterized.Parameters;
 
-import javax.sql.DataSource;
 import java.sql.SQLException;
 import java.util.Collection;
 
@@ -66,7 +65,7 @@ public final class OpenGaussJdbcTransactionIT extends 
BaseTransactionITCase {
     
     @SneakyThrows
     private void callTestCases() {
-        
parameterized.getTransactionTestCaseClass().getConstructor(BaseTransactionITCase.class,
 DataSource.class).newInstance(this, getDataSource()).executeTest();
+        callTestCases(parameterized);
     }
     
 }
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/opengauss/OpenGaussProxyTransactionIT.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/opengauss/OpenGaussProxyTransactionIT.java
index 30bc28e8af2..a2057a43d88 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/opengauss/OpenGaussProxyTransactionIT.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/opengauss/OpenGaussProxyTransactionIT.java
@@ -30,7 +30,6 @@ import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 import org.junit.runners.Parameterized.Parameters;
 
-import javax.sql.DataSource;
 import java.sql.SQLException;
 import java.util.Collection;
 import java.util.Objects;
@@ -82,7 +81,7 @@ public final class OpenGaussProxyTransactionIT extends 
BaseTransactionITCase {
     
     @SneakyThrows
     private void callTestCases() {
-        
parameterized.getTransactionTestCaseClass().getConstructor(BaseTransactionITCase.class,
 DataSource.class).newInstance(this, getDataSource()).executeTest();
+        callTestCases(parameterized);
     }
     
 }
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/postgresql/PostgreSQLJdbcTransactionIT.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/postgresql/PostgreSQLJdbcTransactionIT.java
index e4c4c167ea0..74d12157b41 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/postgresql/PostgreSQLJdbcTransactionIT.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/postgresql/PostgreSQLJdbcTransactionIT.java
@@ -27,7 +27,6 @@ import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 import org.junit.runners.Parameterized.Parameters;
 
-import javax.sql.DataSource;
 import java.sql.SQLException;
 import java.util.Collection;
 
@@ -66,7 +65,7 @@ public final class PostgreSQLJdbcTransactionIT extends 
BaseTransactionITCase {
     
     @SneakyThrows
     private void callTestCases() {
-        
parameterized.getTransactionTestCaseClass().getConstructor(BaseTransactionITCase.class,
 DataSource.class).newInstance(this, getDataSource()).executeTest();
+        callTestCases(parameterized);
     }
     
 }
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/postgresql/PostgreSQLProxyTransactionIT.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/postgresql/PostgreSQLProxyTransactionIT.java
index c0b4a2e29d7..16c065f8f53 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/postgresql/PostgreSQLProxyTransactionIT.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/postgresql/PostgreSQLProxyTransactionIT.java
@@ -30,7 +30,6 @@ import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 import org.junit.runners.Parameterized.Parameters;
 
-import javax.sql.DataSource;
 import java.sql.SQLException;
 import java.util.Collection;
 import java.util.Objects;
@@ -82,7 +81,7 @@ public final class PostgreSQLProxyTransactionIT extends 
BaseTransactionITCase {
     
     @SneakyThrows
     private void callTestCases() {
-        
parameterized.getTransactionTestCaseClass().getConstructor(BaseTransactionITCase.class,
 DataSource.class).newInstance(this, getDataSource()).executeTest();
+        callTestCases(parameterized);
     }
     
 }
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/param/TransactionParameterized.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/param/TransactionParameterized.java
index a6532f429f9..a1a06d9410d 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/param/TransactionParameterized.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/param/TransactionParameterized.java
@@ -23,6 +23,8 @@ import 
org.apache.shardingsphere.infra.database.type.DatabaseType;
 import 
org.apache.shardingsphere.integration.transaction.cases.base.BaseTransactionTestCase;
 import org.apache.shardingsphere.transaction.core.TransactionType;
 
+import java.util.Collection;
+
 /**
  * Transaction test parameters.
  */
@@ -40,10 +42,12 @@ public final class TransactionParameterized {
     
     private final String dockerImageName;
     
-    private final Class<? extends BaseTransactionTestCase> 
transactionTestCaseClass;
+    private final String group;
+    
+    private final Collection<Class<? extends BaseTransactionTestCase>> 
transactionTestCaseClasses;
     
     @Override
     public String toString() {
-        return String.format("%s -> %s -> %s -> %s -> %s -> %s", 
databaseType.getType(), adapter, transactionType, provider, dockerImageName, 
transactionTestCaseClass.getSimpleName());
+        return String.format("%s -> %s -> %s -> %s -> %s -> %s", 
databaseType.getType(), adapter, transactionType, provider, dockerImageName, 
group);
     }
 }
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/resources/env/transaction-it-env.properties
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/resources/env/transaction-it-env.properties
index 76f5fd1150d..91a14d971df 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/resources/env/transaction-it-env.properties
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/resources/env/transaction-it-env.properties
@@ -17,7 +17,7 @@
 # transaction.it.type=DOCKER,NATIVE
 transaction.it.env.type=
 # transaction.it.env.cases= MySQLAutoCommitTestCase, 
PostgresSQLAutoCommitTestCase, ClassicTransferTestCase, 
MultiTableCommitAndRollbackTestCase, SingleTableCommitAndRollbackTestCase, 
MySQLSetReadOnlyTestCase, MySQLSavePointTestCase, PostgreSQLSavePointTestCase 
-transaction.it.env.cases=PostgresSQLAutoCommitTestCase, 
MultiTableCommitAndRollbackTestCase, SingleTableCommitAndRollbackTestCase, 
MySQLSetReadOnlyTestCase, MySQLSavePointTestCase, AddResourceTestCase, 
CloseResourceTestCase, PostgresSQLAndOpenGaussTruncateTestCase, 
MySQLLocalTruncateTestCase, MySQLXATruncateTestCase
+transaction.it.env.cases=PostgresSQLAutoCommitTestCase, 
MultiTableCommitAndRollbackTestCase, SingleTableCommitAndRollbackTestCase, 
MySQLSetReadOnlyTestCase, MySQLSavePointTestCase, MySQLLocalTruncateTestCase, 
MySQLXATruncateTestCase
 # transaction.it.env.transtypes=LOCAL, XA, BASE
 transaction.it.env.transtypes=LOCAL, XA
 # transaction.it.env.xa.providers=Atomikos, Bitronix, Narayana

Reply via email to