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

lujingshang 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 7d4e2ce860f Add test cases and modify transaction IT (#19590)
7d4e2ce860f is described below

commit 7d4e2ce860fafbb8df0bc9e576476b79e5818d10
Author: ZhangCheng <[email protected]>
AuthorDate: Wed Jul 27 23:04:33 2022 +0800

    Add test cases and modify transaction IT (#19590)
    
    * Add test cases and refactor transaction IT
    
    * Fix transaction IT test cases
---
 .../cases/alterresource/AddResourceTestCase.java   | 83 ++++++++++++++++++
 .../cases/alterresource/CloseResourceTestCase.java | 82 ++++++++++++++++++
 .../cases/autocommit/MySQLAutoCommitTestCase.java  |  5 +-
 .../autocommit/PostgresSQLAutoCommitTestCase.java  |  5 +-
 .../cases/base/BaseTransactionTestCase.java        | 11 ++-
 .../classictransfer/ClassicTransferTestCase.java   |  5 +-
 .../MultiOperationsCommitAndRollbackTestCase.java  | 98 ++++++++++++++++++++++
 .../MultiTableCommitAndRollbackTestCase.java       |  5 +-
 .../SingleTableCommitAndRollbackTestCase.java      |  5 +-
 .../cases/readonly/MySQLSetReadOnlyTestCase.java   |  5 +-
 .../readonly/PostgreSQLSetReadOnlyTestCase.java    |  5 +-
 .../cases/readonly/SetReadOnlyTestCase.java        |  5 +-
 .../cases/savepoint/BaseSavePointTestCase.java     |  5 +-
 .../cases/savepoint/MySQLSavePointTestCase.java    |  5 +-
 .../savepoint/OpenGaussSavePointTestCase.java      |  5 +-
 .../savepoint/PostgreSQLSavePointTestCase.java     |  5 +-
 .../transaction/engine/base/BaseITCase.java        | 55 +++++++++++-
 .../engine/base/BaseTransactionITCase.java         | 27 ++++--
 .../engine/base/TransactionTestCase.java           |  6 +-
 .../engine/command/CommonSQLCommand.java           |  9 ++
 .../engine/constants/TransactionTestConstants.java |  7 ++
 .../engine/mysql/MySQLJdbcTransactionIT.java       |  2 +-
 .../engine/mysql/MySQLProxyTransactionIT.java      |  4 +-
 .../opengauss/OpenGaussJdbcTransactionIT.java      |  2 +-
 .../opengauss/OpenGaussProxyTransactionIT.java     |  4 +-
 .../postgresql/PostgreSQLJdbcTransactionIT.java    |  2 +-
 .../postgresql/PostgreSQLProxyTransactionIT.java   |  4 +-
 .../src/test/resources/env/common/command.xml      | 30 ++++++-
 .../resources/env/transaction-it-env.properties    |  2 +-
 29 files changed, 434 insertions(+), 54 deletions(-)

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
new file mode 100644
index 00000000000..dc160c3e7f8
--- /dev/null
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/alterresource/AddResourceTestCase.java
@@ -0,0 +1,83 @@
+/*
+ * 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.integration.transaction.cases.alterresource;
+
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import 
org.apache.shardingsphere.integration.transaction.cases.base.BaseTransactionTestCase;
+import 
org.apache.shardingsphere.integration.transaction.engine.base.BaseTransactionITCase;
+import 
org.apache.shardingsphere.integration.transaction.engine.base.TransactionTestCase;
+import 
org.apache.shardingsphere.integration.transaction.engine.constants.TransactionTestConstants;
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.SQLException;
+
+/**
+ * Integration test of add resource.
+ */
+@Slf4j
+@TransactionTestCase(adapters = TransactionTestConstants.PROXY)
+public final class AddResourceTestCase extends BaseTransactionTestCase {
+    
+    public AddResourceTestCase(final BaseTransactionITCase 
baseTransactionITCase, final DataSource dataSource) {
+        super(baseTransactionITCase, dataSource);
+    }
+    
+    @Override
+    @SneakyThrows
+    public void executeTest() {
+        assertAddResource();
+    }
+    
+    private void assertAddResource() throws SQLException {
+        Connection conn = getDataSource().getConnection();
+        getBaseTransactionITCase().addNewResource(conn);
+        getBaseTransactionITCase().createThreeDataSourceAccountTableRule(conn);
+        reCreateAccountTable(conn);
+        assertRollback();
+        assertCommit();
+        conn.close();
+    }
+    
+    private void reCreateAccountTable(final Connection conn) throws 
SQLException {
+        getBaseTransactionITCase().dropAccountTable(conn);
+        getBaseTransactionITCase().createAccountTable(conn);
+    }
+    
+    private void assertRollback() throws SQLException {
+        Connection conn = getDataSource().getConnection();
+        conn.setAutoCommit(false);
+        assertTableRowCount(conn, TransactionTestConstants.ACCOUNT, 0);
+        executeWithLog(conn, "insert into account(id, BALANCE, TRANSACTION_ID) 
values(1, 1, 1),(2, 2, 2),(3, 3, 3),(4, 4, 4),(5, 5, 5),(6, 6, 6);");
+        assertTableRowCount(conn, TransactionTestConstants.ACCOUNT, 6);
+        conn.rollback();
+        assertTableRowCount(conn, TransactionTestConstants.ACCOUNT, 0);
+    }
+    
+    private void assertCommit() throws SQLException {
+        Connection conn = getDataSource().getConnection();
+        conn.setAutoCommit(false);
+        assertTableRowCount(conn, TransactionTestConstants.ACCOUNT, 0);
+        executeWithLog(conn, "insert into account(id, BALANCE, TRANSACTION_ID) 
values(1, 1, 1),(2, 2, 2),(3, 3, 3),(4, 4, 4),(5, 5, 5),(6, 6, 6);");
+        assertTableRowCount(conn, TransactionTestConstants.ACCOUNT, 6);
+        conn.commit();
+        assertTableRowCount(conn, TransactionTestConstants.ACCOUNT, 6);
+    }
+    
+}
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
new file mode 100644
index 00000000000..92f4815b91c
--- /dev/null
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/alterresource/CloseResourceTestCase.java
@@ -0,0 +1,82 @@
+/*
+ * 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.integration.transaction.cases.alterresource;
+
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import 
org.apache.shardingsphere.integration.transaction.cases.base.BaseTransactionTestCase;
+import 
org.apache.shardingsphere.integration.transaction.engine.base.BaseTransactionITCase;
+import 
org.apache.shardingsphere.integration.transaction.engine.base.TransactionTestCase;
+import 
org.apache.shardingsphere.integration.transaction.engine.constants.TransactionTestConstants;
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.SQLException;
+
+/**
+ * Integration test of close resource.
+ */
+@Slf4j
+@TransactionTestCase(adapters = TransactionTestConstants.PROXY)
+public final class CloseResourceTestCase extends BaseTransactionTestCase {
+    
+    public CloseResourceTestCase(final BaseTransactionITCase 
baseTransactionITCase, final DataSource dataSource) {
+        super(baseTransactionITCase, dataSource);
+    }
+    
+    @Override
+    @SneakyThrows
+    public void executeTest() {
+        assertCloseResource();
+    }
+    
+    private void assertCloseResource() throws SQLException {
+        Connection conn = getDataSource().getConnection();
+        getBaseTransactionITCase().createOriginalAccountTableRule(conn);
+        reCreateAccountTable(conn);
+        assertRollback();
+        assertCommit();
+        conn.close();
+    }
+    
+    private void reCreateAccountTable(final Connection conn) throws 
SQLException {
+        getBaseTransactionITCase().dropAccountTable(conn);
+        getBaseTransactionITCase().createAccountTable(conn);
+    }
+    
+    private void assertRollback() throws SQLException {
+        Connection conn = getDataSource().getConnection();
+        conn.setAutoCommit(false);
+        assertTableRowCount(conn, TransactionTestConstants.ACCOUNT, 0);
+        executeWithLog(conn, "insert into account(id, BALANCE, TRANSACTION_ID) 
values(1, 1, 1),(2, 2, 2),(3, 3, 3),(4, 4, 4),(5, 5, 5),(6, 6, 6);");
+        assertTableRowCount(conn, TransactionTestConstants.ACCOUNT, 6);
+        conn.rollback();
+        assertTableRowCount(conn, TransactionTestConstants.ACCOUNT, 0);
+    }
+    
+    private void assertCommit() throws SQLException {
+        Connection conn = getDataSource().getConnection();
+        conn.setAutoCommit(false);
+        assertTableRowCount(conn, TransactionTestConstants.ACCOUNT, 0);
+        executeWithLog(conn, "insert into account(id, BALANCE, TRANSACTION_ID) 
values(1, 1, 1),(2, 2, 2),(3, 3, 3),(4, 4, 4),(5, 5, 5),(6, 6, 6);");
+        assertTableRowCount(conn, TransactionTestConstants.ACCOUNT, 6);
+        conn.commit();
+        assertTableRowCount(conn, TransactionTestConstants.ACCOUNT, 6);
+    }
+    
+}
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/autocommit/MySQLAutoCommitTestCase.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/autocommit/MySQLAutoCommitTestCase.java
index 4fdddd4d068..e1558ae8711 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/autocommit/MySQLAutoCommitTestCase.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/autocommit/MySQLAutoCommitTestCase.java
@@ -21,6 +21,7 @@ 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.base.BaseTransactionITCase;
 import 
org.apache.shardingsphere.integration.transaction.engine.base.TransactionTestCase;
 import 
org.apache.shardingsphere.integration.transaction.engine.constants.TransactionTestConstants;
 import org.junit.Assert;
@@ -38,8 +39,8 @@ import java.util.concurrent.TimeUnit;
 @TransactionTestCase(dbTypes = {TransactionTestConstants.MYSQL})
 public final class MySQLAutoCommitTestCase extends BaseTransactionTestCase {
     
-    public MySQLAutoCommitTestCase(final DataSource dataSource) {
-        super(dataSource);
+    public MySQLAutoCommitTestCase(final BaseTransactionITCase 
baseTransactionITCase, final DataSource dataSource) {
+        super(baseTransactionITCase, dataSource);
     }
     
     @Override
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 3a84e4c094b..d8c0405f14d 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
@@ -21,6 +21,7 @@ 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.base.BaseTransactionITCase;
 import 
org.apache.shardingsphere.integration.transaction.engine.base.TransactionTestCase;
 import 
org.apache.shardingsphere.integration.transaction.engine.constants.TransactionTestConstants;
 import org.junit.Assert;
@@ -38,8 +39,8 @@ import java.util.concurrent.TimeUnit;
 @TransactionTestCase(dbTypes = {TransactionTestConstants.POSTGRESQL})
 public final class PostgresSQLAutoCommitTestCase extends 
BaseTransactionTestCase {
     
-    public PostgresSQLAutoCommitTestCase(final DataSource dataSource) {
-        super(dataSource);
+    public PostgresSQLAutoCommitTestCase(final BaseTransactionITCase 
baseTransactionITCase, final DataSource dataSource) {
+        super(baseTransactionITCase, dataSource);
     }
     
     @Override
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 def66699d08..16dafa961d0 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
@@ -17,9 +17,11 @@
 
 package org.apache.shardingsphere.integration.transaction.cases.base;
 
+import lombok.AccessLevel;
 import lombok.Getter;
 import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
+import 
org.apache.shardingsphere.integration.transaction.engine.base.BaseTransactionITCase;
 import 
org.apache.shardingsphere.integration.transaction.engine.constants.TransactionTestConstants;
 
 import javax.sql.DataSource;
@@ -34,12 +36,15 @@ import static org.junit.Assert.assertEquals;
  * Base transaction test case.
  */
 @Slf4j
+@Getter(AccessLevel.PROTECTED)
 public abstract class BaseTransactionTestCase {
     
-    @Getter
-    private DataSource dataSource;
+    private final BaseTransactionITCase baseTransactionITCase;
     
-    public BaseTransactionTestCase(final DataSource dataSource) {
+    private final DataSource dataSource;
+    
+    public BaseTransactionTestCase(final BaseTransactionITCase 
baseTransactionITCase, final DataSource dataSource) {
+        this.baseTransactionITCase = baseTransactionITCase;
         this.dataSource = dataSource;
     }
     
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/classictransfer/ClassicTransferTestCase.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/classictransfer/ClassicTransferTestCase.java
index 377139bcda8..754b42c293f 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/classictransfer/ClassicTransferTestCase.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/classictransfer/ClassicTransferTestCase.java
@@ -21,6 +21,7 @@ import lombok.AllArgsConstructor;
 import lombok.Getter;
 import lombok.SneakyThrows;
 import 
org.apache.shardingsphere.integration.transaction.cases.base.BaseTransactionTestCase;
+import 
org.apache.shardingsphere.integration.transaction.engine.base.BaseTransactionITCase;
 import 
org.apache.shardingsphere.integration.transaction.engine.base.TransactionTestCase;
 import org.junit.Assert;
 
@@ -38,8 +39,8 @@ import java.util.List;
 @TransactionTestCase
 public final class ClassicTransferTestCase extends BaseTransactionTestCase {
     
-    public ClassicTransferTestCase(final DataSource dataSource) {
-        super(dataSource);
+    public ClassicTransferTestCase(final BaseTransactionITCase 
baseTransactionITCase, final DataSource dataSource) {
+        super(baseTransactionITCase, dataSource);
     }
     
     @Override
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/commitrollback/MultiOperationsCommitAndRollbackTestCase.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/commitrollback/MultiOperationsCommitAndRollbackTestCase.java
new file mode 100644
index 00000000000..9a8396b30b6
--- /dev/null
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/commitrollback/MultiOperationsCommitAndRollbackTestCase.java
@@ -0,0 +1,98 @@
+/*
+ * 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.integration.transaction.cases.commitrollback;
+
+import com.google.common.base.Preconditions;
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import 
org.apache.shardingsphere.integration.transaction.cases.base.BaseTransactionTestCase;
+import 
org.apache.shardingsphere.integration.transaction.engine.base.BaseTransactionITCase;
+import 
org.apache.shardingsphere.integration.transaction.engine.base.TransactionTestCase;
+import 
org.apache.shardingsphere.integration.transaction.engine.constants.TransactionTestConstants;
+import org.junit.Assert;
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+/**
+ * Integration test of multiple operations in one transaction.
+ */
+@Slf4j
+@TransactionTestCase
+public final class MultiOperationsCommitAndRollbackTestCase extends 
BaseTransactionTestCase {
+    
+    public MultiOperationsCommitAndRollbackTestCase(final 
BaseTransactionITCase baseTransactionITCase, final DataSource dataSource) {
+        super(baseTransactionITCase, dataSource);
+    }
+    
+    @Override
+    @SneakyThrows
+    public void executeTest() {
+        assertRollback();
+        assertCommit();
+    }
+    
+    private void assertRollback() throws SQLException {
+        Connection conn = getDataSource().getConnection();
+        conn.setAutoCommit(false);
+        assertTableRowCount(conn, TransactionTestConstants.ACCOUNT, 0);
+        executeWithLog(conn, "insert into account(id, balance, transaction_id) 
values(1, 1, 1);");
+        executeWithLog(conn, "insert into account(id, balance, transaction_id) 
values(2, 2, 2);");
+        executeUpdateWithLog(conn, "update account set balance=3, 
transaction_id=3 where id=2;");
+        assertQueryAccount(conn, 1, 3);
+        conn.rollback();
+        assertTableRowCount(conn, TransactionTestConstants.ACCOUNT, 0);
+        assertQueryAccount(conn, 1, 2);
+    }
+    
+    private void assertCommit() throws SQLException {
+        Connection conn = getDataSource().getConnection();
+        conn.setAutoCommit(false);
+        assertTableRowCount(conn, TransactionTestConstants.ACCOUNT, 0);
+        executeWithLog(conn, "insert into account(id, balance, transaction_id) 
values(1, 1, 1);");
+        executeWithLog(conn, "insert into account(id, balance, transaction_id) 
values(2, 2, 2);");
+        executeUpdateWithLog(conn, "update account set balance=3, 
transaction_id=3 where id=2;");
+        assertQueryAccount(conn, 1, 3);
+        conn.commit();
+        assertTableRowCount(conn, TransactionTestConstants.ACCOUNT, 2);
+        assertQueryAccount(conn, 1, 3);
+    }
+    
+    private void assertQueryAccount(final Connection conn, final int... 
expectedBalances) throws SQLException {
+        Preconditions.checkArgument(2 == expectedBalances.length);
+        Statement queryStatement = conn.createStatement();
+        ResultSet rs = queryStatement.executeQuery("select * from account;");
+        while (rs.next()) {
+            int id = rs.getInt("id");
+            int actualBalance = rs.getInt("balance");
+            if (id == 1) {
+                assertBalance(actualBalance, expectedBalances[0]);
+            }
+            if (id == 2) {
+                assertBalance(actualBalance, expectedBalances[1]);
+            }
+        }
+    }
+    
+    private void assertBalance(final int balance, final int expectedBalance) {
+        Assert.assertEquals(String.format("Balance is %s, should be %s.", 
balance, expectedBalance), balance, expectedBalance);
+    }
+}
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/commitrollback/MultiTableCommitAndRollbackTestCase.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/commitrollback/MultiTableCommitAndRollbackTestCase.java
index 719e6d34a86..3437ae0d057 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/commitrollback/MultiTableCommitAndRollbackTestCase.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/commitrollback/MultiTableCommitAndRollbackTestCase.java
@@ -20,6 +20,7 @@ package 
org.apache.shardingsphere.integration.transaction.cases.commitrollback;
 import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
 import 
org.apache.shardingsphere.integration.transaction.cases.base.BaseTransactionTestCase;
+import 
org.apache.shardingsphere.integration.transaction.engine.base.BaseTransactionITCase;
 import 
org.apache.shardingsphere.integration.transaction.engine.base.TransactionTestCase;
 
 import javax.sql.DataSource;
@@ -37,8 +38,8 @@ public final class MultiTableCommitAndRollbackTestCase 
extends BaseTransactionTe
     
     private static final String T_ORDER_ITEM = "t_order_item";
     
-    public MultiTableCommitAndRollbackTestCase(final DataSource dataSource) {
-        super(dataSource);
+    public MultiTableCommitAndRollbackTestCase(final BaseTransactionITCase 
baseTransactionITCase, final DataSource dataSource) {
+        super(baseTransactionITCase, dataSource);
     }
     
     @Override
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/commitrollback/SingleTableCommitAndRollbackTestCase.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/commitrollback/SingleTableCommitAndRollbackTestCase.java
index c00122ec063..a2e7fad2233 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/commitrollback/SingleTableCommitAndRollbackTestCase.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/commitrollback/SingleTableCommitAndRollbackTestCase.java
@@ -19,6 +19,7 @@ package 
org.apache.shardingsphere.integration.transaction.cases.commitrollback;
 
 import lombok.SneakyThrows;
 import 
org.apache.shardingsphere.integration.transaction.cases.base.BaseTransactionTestCase;
+import 
org.apache.shardingsphere.integration.transaction.engine.base.BaseTransactionITCase;
 import 
org.apache.shardingsphere.integration.transaction.engine.base.TransactionTestCase;
 
 import javax.sql.DataSource;
@@ -32,8 +33,8 @@ import java.sql.Statement;
 @TransactionTestCase
 public final class SingleTableCommitAndRollbackTestCase extends 
BaseTransactionTestCase {
     
-    public SingleTableCommitAndRollbackTestCase(final DataSource dataSource) {
-        super(dataSource);
+    public SingleTableCommitAndRollbackTestCase(final BaseTransactionITCase 
baseTransactionITCase, final DataSource dataSource) {
+        super(baseTransactionITCase, dataSource);
     }
     
     @Override
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/readonly/MySQLSetReadOnlyTestCase.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/readonly/MySQLSetReadOnlyTestCase.java
index 6e6604357c5..a1fa520efcb 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/readonly/MySQLSetReadOnlyTestCase.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/readonly/MySQLSetReadOnlyTestCase.java
@@ -19,6 +19,7 @@ package 
org.apache.shardingsphere.integration.transaction.cases.readonly;
 
 import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
+import 
org.apache.shardingsphere.integration.transaction.engine.base.BaseTransactionITCase;
 import 
org.apache.shardingsphere.integration.transaction.engine.base.TransactionTestCase;
 import 
org.apache.shardingsphere.integration.transaction.engine.constants.TransactionTestConstants;
 import org.junit.Assert;
@@ -35,8 +36,8 @@ import java.sql.Statement;
 @TransactionTestCase(dbTypes = {TransactionTestConstants.MYSQL})
 public final class MySQLSetReadOnlyTestCase extends SetReadOnlyTestCase {
     
-    public MySQLSetReadOnlyTestCase(final DataSource dataSource) {
-        super(dataSource);
+    public MySQLSetReadOnlyTestCase(final BaseTransactionITCase 
baseTransactionITCase, final DataSource dataSource) {
+        super(baseTransactionITCase, dataSource);
     }
     
     @Override
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/readonly/PostgreSQLSetReadOnlyTestCase.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/readonly/PostgreSQLSetReadOnlyTestCase.java
index b276760ab91..2501e62cbc5 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/readonly/PostgreSQLSetReadOnlyTestCase.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/readonly/PostgreSQLSetReadOnlyTestCase.java
@@ -19,6 +19,7 @@ package 
org.apache.shardingsphere.integration.transaction.cases.readonly;
 
 import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
+import 
org.apache.shardingsphere.integration.transaction.engine.base.BaseTransactionITCase;
 import 
org.apache.shardingsphere.integration.transaction.engine.base.TransactionTestCase;
 import 
org.apache.shardingsphere.integration.transaction.engine.constants.TransactionTestConstants;
 import org.junit.Assert;
@@ -35,8 +36,8 @@ import java.sql.Statement;
 @TransactionTestCase(dbTypes = {TransactionTestConstants.POSTGRESQL})
 public final class PostgreSQLSetReadOnlyTestCase extends SetReadOnlyTestCase {
     
-    public PostgreSQLSetReadOnlyTestCase(final DataSource dataSource) {
-        super(dataSource);
+    public PostgreSQLSetReadOnlyTestCase(final BaseTransactionITCase 
baseTransactionITCase, final DataSource dataSource) {
+        super(baseTransactionITCase, dataSource);
     }
     
     @Override
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/readonly/SetReadOnlyTestCase.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/readonly/SetReadOnlyTestCase.java
index d03efa6878d..1ad56d138b1 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/readonly/SetReadOnlyTestCase.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/readonly/SetReadOnlyTestCase.java
@@ -20,6 +20,7 @@ package 
org.apache.shardingsphere.integration.transaction.cases.readonly;
 import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
 import 
org.apache.shardingsphere.integration.transaction.cases.base.BaseTransactionTestCase;
+import 
org.apache.shardingsphere.integration.transaction.engine.base.BaseTransactionITCase;
 import org.junit.Assert;
 
 import javax.sql.DataSource;
@@ -34,8 +35,8 @@ import java.sql.Statement;
 @Slf4j
 public abstract class SetReadOnlyTestCase extends BaseTransactionTestCase {
     
-    public SetReadOnlyTestCase(final DataSource dataSource) {
-        super(dataSource);
+    public SetReadOnlyTestCase(final BaseTransactionITCase 
baseTransactionITCase, final DataSource dataSource) {
+        super(baseTransactionITCase, dataSource);
     }
     
     @SneakyThrows
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/savepoint/BaseSavePointTestCase.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/savepoint/BaseSavePointTestCase.java
index e4bb0cca96c..7c832e823cd 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/savepoint/BaseSavePointTestCase.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/savepoint/BaseSavePointTestCase.java
@@ -20,6 +20,7 @@ package 
org.apache.shardingsphere.integration.transaction.cases.savepoint;
 import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
 import 
org.apache.shardingsphere.integration.transaction.cases.base.BaseTransactionTestCase;
+import 
org.apache.shardingsphere.integration.transaction.engine.base.BaseTransactionITCase;
 
 import javax.sql.DataSource;
 import java.sql.Connection;
@@ -32,8 +33,8 @@ import java.sql.Savepoint;
 @Slf4j
 public abstract class BaseSavePointTestCase extends BaseTransactionTestCase {
     
-    public BaseSavePointTestCase(final DataSource dataSource) {
-        super(dataSource);
+    public BaseSavePointTestCase(final BaseTransactionITCase 
baseTransactionITCase, final DataSource dataSource) {
+        super(baseTransactionITCase, dataSource);
     }
     
     @SneakyThrows(SQLException.class)
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/savepoint/MySQLSavePointTestCase.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/savepoint/MySQLSavePointTestCase.java
index 3589e385ac0..9cd7f30bbfb 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/savepoint/MySQLSavePointTestCase.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/savepoint/MySQLSavePointTestCase.java
@@ -19,6 +19,7 @@ package 
org.apache.shardingsphere.integration.transaction.cases.savepoint;
 
 import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
+import 
org.apache.shardingsphere.integration.transaction.engine.base.BaseTransactionITCase;
 import 
org.apache.shardingsphere.integration.transaction.engine.base.TransactionTestCase;
 import 
org.apache.shardingsphere.integration.transaction.engine.constants.TransactionTestConstants;
 
@@ -31,8 +32,8 @@ import javax.sql.DataSource;
 @TransactionTestCase(dbTypes = {TransactionTestConstants.MYSQL})
 public final class MySQLSavePointTestCase extends BaseSavePointTestCase {
     
-    public MySQLSavePointTestCase(final DataSource dataSource) {
-        super(dataSource);
+    public MySQLSavePointTestCase(final BaseTransactionITCase 
baseTransactionITCase, final DataSource dataSource) {
+        super(baseTransactionITCase, dataSource);
     }
     
     @Override
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/savepoint/OpenGaussSavePointTestCase.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/savepoint/OpenGaussSavePointTestCase.java
index 58486926b27..a7e26be69cb 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/savepoint/OpenGaussSavePointTestCase.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/savepoint/OpenGaussSavePointTestCase.java
@@ -19,6 +19,7 @@ package 
org.apache.shardingsphere.integration.transaction.cases.savepoint;
 
 import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
+import 
org.apache.shardingsphere.integration.transaction.engine.base.BaseTransactionITCase;
 import 
org.apache.shardingsphere.integration.transaction.engine.base.TransactionTestCase;
 import 
org.apache.shardingsphere.integration.transaction.engine.constants.TransactionTestConstants;
 import org.junit.Assert;
@@ -35,8 +36,8 @@ import java.sql.SQLException;
 @TransactionTestCase(dbTypes = {TransactionTestConstants.OPENGAUSS})
 public final class OpenGaussSavePointTestCase extends BaseSavePointTestCase {
     
-    public OpenGaussSavePointTestCase(final DataSource dataSource) {
-        super(dataSource);
+    public OpenGaussSavePointTestCase(final BaseTransactionITCase 
baseTransactionITCase, final DataSource dataSource) {
+        super(baseTransactionITCase, dataSource);
     }
     
     @Override
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/savepoint/PostgreSQLSavePointTestCase.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/savepoint/PostgreSQLSavePointTestCase.java
index b0c6a4cc574..061b7eaed24 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/savepoint/PostgreSQLSavePointTestCase.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/savepoint/PostgreSQLSavePointTestCase.java
@@ -19,6 +19,7 @@ package 
org.apache.shardingsphere.integration.transaction.cases.savepoint;
 
 import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
+import 
org.apache.shardingsphere.integration.transaction.engine.base.BaseTransactionITCase;
 import 
org.apache.shardingsphere.integration.transaction.engine.base.TransactionTestCase;
 import 
org.apache.shardingsphere.integration.transaction.engine.constants.TransactionTestConstants;
 import org.junit.Assert;
@@ -35,8 +36,8 @@ import java.sql.SQLException;
 @TransactionTestCase(dbTypes = {TransactionTestConstants.POSTGRESQL})
 public final class PostgreSQLSavePointTestCase extends BaseSavePointTestCase {
     
-    public PostgreSQLSavePointTestCase(final DataSource dataSource) {
-        super(dataSource);
+    public PostgreSQLSavePointTestCase(final BaseTransactionITCase 
baseTransactionITCase, final DataSource dataSource) {
+        super(baseTransactionITCase, dataSource);
     }
     
     @Override
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 456ec52f84b..4b84fe5b5c3 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
@@ -80,7 +80,12 @@ public abstract class BaseITCase {
     
     protected static final String DS_1 = TRANSACTION_IT + "_1";
     
-    protected static final Collection<String> ALL_DS = Arrays.asList(DS_0, 
DS_1);
+    /**
+     * For adding resource tests.
+     */
+    protected static final String DS_2 = TRANSACTION_IT + "_2";
+    
+    protected static final Collection<String> ALL_DS = Arrays.asList(DS_0, 
DS_1, DS_2);
     
     protected static final String SHARDING_DB = "sharding_db";
     
@@ -189,9 +194,9 @@ public abstract class BaseITCase {
                 log.info("Collect transaction test case, dbType is not 
matched, skip: {}.", caseClass.getName());
                 continue;
             }
-            Optional<String> runMode = 
Arrays.stream(annotation.runModes()).filter(each -> 
currentTestCaseInfo.getRunningAdaptor().equalsIgnoreCase(each)).findAny();
-            if (!runMode.isPresent()) {
-                log.info("Collect transaction test case, runMode is not 
matched, skip: {}.", caseClass.getName());
+            Optional<String> runAdapters = 
Arrays.stream(annotation.adapters()).filter(each -> 
currentTestCaseInfo.getRunningAdaptor().equalsIgnoreCase(each)).findAny();
+            if (!runAdapters.isPresent()) {
+                log.info("Collect transaction test case, runAdapter is not 
matched, skip: {}.", caseClass.getName());
                 continue;
             }
             addParametersByTransactionTypes(result, version, 
currentTestCaseInfo, caseClass, annotation);
@@ -380,6 +385,48 @@ public abstract class BaseITCase {
         executeWithLog(connection, addSourceResource);
     }
     
+    /**
+     * Add ds_2 resource to proxy.
+     * 
+     * @param connection connection
+     */
+    @SneakyThrows(SQLException.class)
+    public void addNewResource(final Connection connection) {
+        String addSourceResource = 
commonSQLCommand.getSourceAddNewResourceTemplate()
+                .replace("${user}", 
ENV.getActualDataSourceUsername(databaseType))
+                .replace("${password}", 
ENV.getActualDataSourcePassword(databaseType))
+                .replace("${ds2}", getActualJdbcUrlTemplate(DS_2));
+        executeWithLog(connection, addSourceResource);
+        int resourceCount = countWithLog("SHOW DATABASE RESOURCES FROM 
sharding_db");
+        assertThat(resourceCount, is(3));
+    }
+    
+    /**
+     * Drop previous account table rule and create the table rule with three 
data sources.
+     * 
+     * @param connection connection
+     */
+    @SneakyThrows(SQLException.class)
+    public void createThreeDataSourceAccountTableRule(final Connection 
connection) {
+        executeWithLog(connection, "DROP SHARDING TABLE RULE account;");
+        executeWithLog(connection, 
getCommonSQLCommand().getCreateThreeDataSourceAccountTableRule());
+        int ruleCount = countWithLog("SHOW SHARDING TABLE RULES FROM 
sharding_db;");
+        assertThat(ruleCount, is(3));
+    }
+    
+    /**
+     * Create the account table rule with one data source.
+     * 
+     * @param connection connection
+     */
+    @SneakyThrows(SQLException.class)
+    public void createOriginalAccountTableRule(final Connection connection) {
+        executeWithLog(connection, "DROP SHARDING TABLE RULE account;");
+        executeWithLog(connection, 
getCommonSQLCommand().getCreateOneDataSourceAccountTableRule());
+        int ruleCount = countWithLog("SHOW SHARDING TABLE RULES FROM 
sharding_db;");
+        assertThat(ruleCount, is(3));
+    }
+    
     private String getActualJdbcUrlTemplate(final String databaseName) {
         if (ENV.getItEnvType() == TransactionITEnvTypeEnum.DOCKER) {
             final DatabaseContainer databaseContainer = 
((DockerComposedContainer) composedContainer).getDatabaseContainer();
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 03b0d265ffa..7c124d53afe 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
@@ -91,12 +91,24 @@ public abstract class BaseTransactionITCase extends 
BaseITCase {
         executeWithLog(connection, "CREATE SHARDING BINDING TABLE RULES 
(t_order, t_order_item)");
     }
     
-    protected void createAccountTable(final Connection connection) throws 
SQLException {
+    /**
+     * Create account table.
+     * 
+     * @param connection connection 
+     * @throws SQLException SQL exception
+     */
+    public void createAccountTable(final Connection connection) throws 
SQLException {
         executeWithLog(connection, 
getCommonSQLCommand().getCreateAccountTable());
     }
     
-    protected void dropAccountTable(final Connection connection) throws 
SQLException {
-        executeWithLog(connection, "DROP TABLE IF EXISTS account;");
+    /**
+     * Drop account table.
+     *
+     * @param connection connection 
+     * @throws SQLException SQL exception
+     */
+    public void dropAccountTable(final Connection connection) throws 
SQLException {
+        executeWithLog(connection, "drop table if exists account;");
     }
     
     protected void createOrderItemTable(final Connection connection) throws 
SQLException {
@@ -141,14 +153,15 @@ public abstract class BaseTransactionITCase extends 
BaseITCase {
         assertTrue(waitExpectedTransactionRule(TransactionType.LOCAL, "", 5));
     }
     
-    protected void alterXaAtomikosTransactionRule() throws SQLException {
+    protected void alterXaTransactionRule() throws SQLException {
+        String providerType = TransactionTestConstants.ATOMIKOS;
         Connection connection = getProxyConnection();
-        if (isExpectedTransactionRule(connection, TransactionType.XA, 
"Atomikos")) {
+        if (isExpectedTransactionRule(connection, TransactionType.XA, 
providerType)) {
             return;
         }
-        String alterXaAtomikosTransactionRule = 
getCommonSQLCommand().getAlterXaAtomikosTransactionRule();
+        String alterXaAtomikosTransactionRule = 
getCommonSQLCommand().getAlterXaAtomikosTransactionRule().replace("${providerType}",
 providerType);
         executeWithLog(connection, alterXaAtomikosTransactionRule);
-        assertTrue(waitExpectedTransactionRule(TransactionType.XA, "Atomikos", 
5));
+        assertTrue(waitExpectedTransactionRule(TransactionType.XA, 
providerType, 5));
     }
     
     private boolean isExpectedTransactionRule(final Connection connection, 
final TransactionType expectedTransType, final String expectedProviderType) {
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 cda319786df..dce402758b8 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
@@ -39,11 +39,11 @@ public @interface TransactionTestCase {
     String[] dbTypes() default {"mysql", "PostgreSQL", "OpenGauss"};
     
     /**
-     * Specifies which modes do the case run on.
+     * Specifies which adapters do the case run on.
      * 
-     * @return run modes
+     * @return run adapters
      */
-    String[] runModes() default {"jdbc", "proxy"};
+    String[] adapters() default {"jdbc", "proxy"};
     
     /**
      * Specifies which transaction types do the case run on.
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/command/CommonSQLCommand.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/command/CommonSQLCommand.java
index b59366f5c70..75c1e4dc779 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/command/CommonSQLCommand.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/command/CommonSQLCommand.java
@@ -53,6 +53,12 @@ public final class CommonSQLCommand {
     @XmlElement(name = "create-account-table-rule")
     private String createAccountTableRule;
     
+    @XmlElement(name = "create-one-data-source-account-table-rule")
+    private String createOneDataSourceAccountTableRule;
+    
+    @XmlElement(name = "create-three-data-source-account-table-rule")
+    private String createThreeDataSourceAccountTableRule;
+    
     @XmlElement(name = "alter-local-transaction-rule")
     private String alterLocalTransactionRule;
     
@@ -62,6 +68,9 @@ public final class CommonSQLCommand {
     @XmlElement(name = "source-add-resource-template")
     private String sourceAddResourceTemplate;
     
+    @XmlElement(name = "source-add-new-resource-template")
+    private String sourceAddNewResourceTemplate;
+    
     @XmlElement(name = "create-account-table")
     private String createAccountTable;
     
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/constants/TransactionTestConstants.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/constants/TransactionTestConstants.java
index e572203e8b0..2bc640dab7c 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/constants/TransactionTestConstants.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/constants/TransactionTestConstants.java
@@ -37,4 +37,11 @@ public final class TransactionTestConstants {
     public static final String DEFAULT_TYPE = "default_type";
     
     public static final String PROVIDER_TYPE = "provider_type";
+    
+    public static final String ATOMIKOS = "Atomikos";
+    
+    public static final String NARAYANA = "Narayana";
+    
+    public static final String BITRONIX = "Bitronix";
+    
 }
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 a5598a8e5ab..e62e6296e07 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
@@ -66,6 +66,6 @@ public final class MySQLJdbcTransactionIT extends 
BaseTransactionITCase {
     
     @SneakyThrows
     private void callTestCases() {
-        
parameterized.getTransactionTestCaseClass().getConstructor(DataSource.class).newInstance(getDataSource()).executeTest();
+        
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 1369ec73653..b6797ee9bc0 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
@@ -62,7 +62,7 @@ public final class MySQLProxyTransactionIT extends 
BaseTransactionITCase {
             if (Objects.equals(parameterized.getTransactionType(), 
TransactionType.LOCAL)) {
                 alterLocalTransactionRule();
             } else if (Objects.equals(parameterized.getTransactionType(), 
TransactionType.XA)) {
-                alterXaAtomikosTransactionRule();
+                alterXaTransactionRule();
             }
         }
     }
@@ -82,7 +82,7 @@ public final class MySQLProxyTransactionIT extends 
BaseTransactionITCase {
     
     @SneakyThrows
     private void callTestCases() {
-        
parameterized.getTransactionTestCaseClass().getConstructor(DataSource.class).newInstance(getDataSource()).executeTest();
+        
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/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 87311837c4f..b7e55c9f74a 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
@@ -66,7 +66,7 @@ public final class OpenGaussJdbcTransactionIT extends 
BaseTransactionITCase {
     
     @SneakyThrows
     private void callTestCases() {
-        
parameterized.getTransactionTestCaseClass().getConstructor(DataSource.class).newInstance(getDataSource()).executeTest();
+        
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/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 495ad59bcf2..e422471696c 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
@@ -62,7 +62,7 @@ public final class OpenGaussProxyTransactionIT extends 
BaseTransactionITCase {
             if (Objects.equals(parameterized.getTransactionType(), 
TransactionType.LOCAL)) {
                 alterLocalTransactionRule();
             } else if (Objects.equals(parameterized.getTransactionType(), 
TransactionType.XA)) {
-                alterXaAtomikosTransactionRule();
+                alterXaTransactionRule();
             }
         }
     }
@@ -82,7 +82,7 @@ public final class OpenGaussProxyTransactionIT extends 
BaseTransactionITCase {
     
     @SneakyThrows
     private void callTestCases() {
-        
parameterized.getTransactionTestCaseClass().getConstructor(DataSource.class).newInstance(getDataSource()).executeTest();
+        
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/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 4e0b74a7530..e4c4c167ea0 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
@@ -66,7 +66,7 @@ public final class PostgreSQLJdbcTransactionIT extends 
BaseTransactionITCase {
     
     @SneakyThrows
     private void callTestCases() {
-        
parameterized.getTransactionTestCaseClass().getConstructor(DataSource.class).newInstance(getDataSource()).executeTest();
+        
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/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 981fd716e3d..acab6ab9fea 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
@@ -62,7 +62,7 @@ public final class PostgreSQLProxyTransactionIT extends 
BaseTransactionITCase {
             if (Objects.equals(parameterized.getTransactionType(), 
TransactionType.LOCAL)) {
                 alterLocalTransactionRule();
             } else if (Objects.equals(parameterized.getTransactionType(), 
TransactionType.XA)) {
-                alterXaAtomikosTransactionRule();
+                alterXaTransactionRule();
             }
         }
     }
@@ -82,7 +82,7 @@ public final class PostgreSQLProxyTransactionIT extends 
BaseTransactionITCase {
     
     @SneakyThrows
     private void callTestCases() {
-        
parameterized.getTransactionTestCaseClass().getConstructor(DataSource.class).newInstance(getDataSource()).executeTest();
+        
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/resources/env/common/command.xml
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/resources/env/common/command.xml
index d67cafac5ad..b8403d17daf 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/resources/env/common/command.xml
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/resources/env/common/command.xml
@@ -67,12 +67,28 @@
     <create-account-table-rule>
         CREATE SHARDING TABLE RULE account (
         DATANODES("ds_${0..1}.account_${0..1}"),
-        
DATABASE_STRATEGY(TYPE=standard,SHARDING_COLUMN=id,SHARDING_ALGORITHM=database_id_inline),
-        
TABLE_STRATEGY(TYPE=standard,SHARDING_COLUMN=id,SHARDING_ALGORITHM=account_inline),
+        DATABASE_STRATEGY(TYPE=standard, SHARDING_COLUMN=id, 
SHARDING_ALGORITHM=database_id_inline),
+        TABLE_STRATEGY(TYPE=standard, SHARDING_COLUMN=id, 
SHARDING_ALGORITHM=account_inline),
         KEY_GENERATE_STRATEGY(COLUMN=id,TYPE(NAME=snowflake))
         )
     </create-account-table-rule>
 
+    <create-one-data-source-account-table-rule>
+        CREATE SHARDING TABLE RULE account (
+        DATANODES("ds_0.account_${0..1}"),
+        DATABASE_STRATEGY(TYPE=standard, SHARDING_COLUMN=id, 
SHARDING_ALGORITHM(TYPE(NAME=inline, PROPERTIES("algorithm-expression"="ds_${id 
% 1}")))),
+        TABLE_STRATEGY(TYPE=standard, SHARDING_COLUMN=id, 
SHARDING_ALGORITHM(TYPE(NAME=inline, 
PROPERTIES("algorithm-expression"="account_${Math.floorMod(Math.floorDiv(id.longValue(),
 1L), 2L)}"))))
+        )
+    </create-one-data-source-account-table-rule>
+
+    <create-three-data-source-account-table-rule>
+        CREATE SHARDING TABLE RULE account (
+        DATANODES("ds_${0..2}.account_${0..1}"),
+        DATABASE_STRATEGY(TYPE=standard, SHARDING_COLUMN=id, 
SHARDING_ALGORITHM(TYPE(NAME=inline, PROPERTIES("algorithm-expression"="ds_${id 
% 3}")))),
+        TABLE_STRATEGY(TYPE=standard, SHARDING_COLUMN=id, 
SHARDING_ALGORITHM(TYPE(NAME=inline, 
PROPERTIES("algorithm-expression"="account_${Math.floorMod(Math.floorDiv(id.longValue(),
 3L), 2L)}"))))
+        )
+    </create-three-data-source-account-table-rule>
+
     <alter-local-transaction-rule>
         ALTER TRANSACTION RULE ( DEFAULT=LOCAL )
     </alter-local-transaction-rule>
@@ -81,7 +97,7 @@
         ALTER TRANSACTION RULE
         (
         DEFAULT=XA,
-        TYPE(NAME=Atomikos)
+        TYPE(NAME=${providerType})
         )
     </alter-xa-atomikos-transaction-rule>
 
@@ -97,6 +113,14 @@
         )
     </source-add-resource-template>
 
+    <source-add-new-resource-template>
+        ADD RESOURCE ds_2 (
+            URL="${ds2}",
+            USER=${user},
+            PASSWORD=${password}
+        )
+    </source-add-new-resource-template>
+    
     <create-account-table>
         CREATE TABLE account
         (
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 3f41f2c24aa..cc99b538141 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
+transaction.it.env.cases=PostgresSQLAutoCommitTestCase, 
MultiTableCommitAndRollbackTestCase, SingleTableCommitAndRollbackTestCase, 
MySQLSetReadOnlyTestCase, MySQLSavePointTestCase, AddResourceTestCase, 
CloseResourceTestCase
 # transaction.it.env.transtypes=LOCAL, XA, BASE
 transaction.it.env.transtypes=LOCAL, XA
 # transaction.it.docker.mysql.version=5.7,8.0

Reply via email to