You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by du...@apache.org on 2022/11/02 05:20:36 UTC
[shardingsphere] branch master updated: Refactor transaction it case (#21891)
This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang 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 59bc1f2065e Refactor transaction it case (#21891)
59bc1f2065e is described below
commit 59bc1f2065e138b8dda09576401f867733fc4f72
Author: ZhangCheng <fl...@outlook.com>
AuthorDate: Wed Nov 2 13:20:29 2022 +0800
Refactor transaction it case (#21891)
* Refactor transaction it case
* Add test case
* Fix
* Fix
---
.../cases/alterresource/AddResourceTestCase.java | 2 +-
.../cases/alterresource/CloseResourceTestCase.java | 2 +-
.../cases/base/BaseTransactionTestCase.java | 2 +
.../ExceptionInTransactionTestCase.java | 3 +-
.../PostgresSQLAndOpenGaussTruncateTestCase.java | 2 +
.../transaction/engine/base/BaseITCase.java | 41 +++------
.../engine/base/BaseTransactionITCase.java | 47 ----------
.../engine/base/TransactionTestCase.java | 4 +-
.../env/IntegrationTestEnvironment.java | 1 -
.../container/compose/DockerContainerComposer.java | 7 +-
.../ProxyClusterContainerConfigurationFactory.java | 11 +--
.../framework/param/TransactionParameterized.java | 4 +-
.../transaction/util/TestCaseClassScanner.java | 14 +--
.../env/scenario/default/data/actual/databases.xml | 23 +++++
.../env/scenario/default/data/actual/dataset.xml | 19 +++++
.../data/actual/init-sql/mysql/01-actual-init.sql | 25 ++++++
.../actual/init-sql/opengauss/01-actual-init.sql | 25 ++++++
.../actual/init-sql/postgresql/01-actual-init.sql | 25 ++++++
.../scenario/default/data/expected/databases.xml | 21 +++++
.../env/scenario/default/data/expected/dataset.xml | 19 +++++
.../data/expected/init-sql/mysql/expected-init.sql | 19 +++++
.../expected/init-sql/opengauss/expected-init.sql | 19 +++++
.../expected/init-sql/postgresql/expected-init.sql | 19 +++++
.../scenario/default/proxy/conf/mysql/rule.yaml | 99 ++++++++++++++++++++++
.../default/proxy/conf/opengauss/rule.yaml | 99 ++++++++++++++++++++++
.../default/proxy/conf/postgresql/rule.yaml | 99 ++++++++++++++++++++++
26 files changed, 553 insertions(+), 98 deletions(-)
diff --git a/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/alterresource/AddResourceTestCase.java b/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/alterresource/AddResourceTestCase.java
index 9c95d5a7cc8..07b1d2f8841 100644
--- a/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/alterresource/AddResourceTestCase.java
+++ b/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/alterresource/AddResourceTestCase.java
@@ -33,7 +33,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
/**
* Integration test of add resource.
*/
-@TransactionTestCase(adapters = AdapterContainerConstants.PROXY, group = "addResource")
+@TransactionTestCase(adapters = AdapterContainerConstants.PROXY, scenario = "addResource")
public final class AddResourceTestCase extends BaseTransactionTestCase {
public AddResourceTestCase(final BaseTransactionITCase baseTransactionITCase, final DataSource dataSource) {
diff --git a/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/alterresource/CloseResourceTestCase.java b/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/alterresource/CloseResourceTestCase.java
index b1010d9e1fe..fde8e3adc40 100644
--- a/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/alterresource/CloseResourceTestCase.java
+++ b/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/alterresource/CloseResourceTestCase.java
@@ -31,7 +31,7 @@ import java.sql.SQLException;
/**
* Integration test of close resource.
*/
-@TransactionTestCase(adapters = AdapterContainerConstants.PROXY, group = "closeResource")
+@TransactionTestCase(adapters = AdapterContainerConstants.PROXY, scenario = "closeResource")
@Slf4j
public final class CloseResourceTestCase extends BaseTransactionTestCase {
diff --git a/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/base/BaseTransactionTestCase.java b/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/base/BaseTransactionTestCase.java
index 7d290411b1c..e33bebf398c 100644
--- a/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/base/BaseTransactionTestCase.java
+++ b/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/base/BaseTransactionTestCase.java
@@ -60,9 +60,11 @@ public abstract class BaseTransactionTestCase {
protected void beforeTest() throws SQLException {
Connection conn = getDataSource().getConnection();
+ conn.setAutoCommit(false);
executeWithLog(conn, "delete from account;");
executeWithLog(conn, "delete from t_order;");
executeWithLog(conn, "delete from t_order_item;");
+ conn.commit();
conn.close();
}
diff --git a/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/commitrollback/ExceptionInTransactionTestCase.java b/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/commitrollback/ExceptionInTransactionTestCase.java
index 3a7623ba0f3..306a51a20bd 100644
--- a/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/commitrollback/ExceptionInTransactionTestCase.java
+++ b/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/commitrollback/ExceptionInTransactionTestCase.java
@@ -21,6 +21,7 @@ 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;
@@ -33,7 +34,7 @@ import static org.junit.Assert.fail;
/**
* An exception occurred within the transaction integration test.
*/
-@TransactionTestCase
+@TransactionTestCase(dbTypes = {TransactionTestConstants.MYSQL, TransactionTestConstants.OPENGAUSS})
@Slf4j
public final class ExceptionInTransactionTestCase extends BaseTransactionTestCase {
diff --git a/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/truncate/PostgresSQLAndOpenGaussTruncateTestCase.java b/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/truncate/PostgresSQLAndOpenGaussTruncateTestCase.java
index af0f3038973..acfd521cb9f 100644
--- a/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/truncate/PostgresSQLAndOpenGaussTruncateTestCase.java
+++ b/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/truncate/PostgresSQLAndOpenGaussTruncateTestCase.java
@@ -69,8 +69,10 @@ public final class PostgresSQLAndOpenGaussTruncateTestCase extends BaseTransacti
private void prepare() throws SQLException {
Connection conn = getDataSource().getConnection();
+ conn.setAutoCommit(false);
executeWithLog(conn, "delete from account;");
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),(7, 7, 7),(8, 8, 8);");
+ conn.commit();
conn.close();
}
}
diff --git a/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/base/BaseITCase.java b/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/base/BaseITCase.java
index e39a88e6bc4..f6da2a97985 100644
--- a/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/base/BaseITCase.java
+++ b/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/base/BaseITCase.java
@@ -83,10 +83,6 @@ public abstract class BaseITCase {
protected static final String DATA_SOURCE_1 = TRANSACTION_IT + "_1";
- protected static final String DATA_SOURCE_2 = TRANSACTION_IT + "_2";
-
- protected static final Collection<String> ALL_DATA_SOURCES = Arrays.asList(DATA_SOURCE_0, DATA_SOURCE_1, DATA_SOURCE_2);
-
protected static final List<String> ALL_XA_PROVIDERS = Arrays.asList(TransactionTestConstants.ATOMIKOS, TransactionTestConstants.BITRONIX, TransactionTestConstants.NARAYANA);
protected static final String SHARDING_DB = "sharding_db";
@@ -116,7 +112,6 @@ public abstract class BaseITCase {
adapter = parameterized.getAdapter();
containerComposer = initializeContainerComposer(parameterized);
commonSQLCommand = loadCommonSQLCommand();
- initActualDataSources();
dataSource = isProxyAdapter(parameterized) ? createProxyDataSource() : createJdbcDataSource();
}
@@ -132,16 +127,6 @@ public abstract class BaseITCase {
return JAXB.unmarshal(Objects.requireNonNull(BaseITCase.class.getClassLoader().getResource("env/common/command.xml")), CommonSQLCommand.class);
}
- private void initActualDataSources() throws SQLException {
- DockerStorageContainer storageContainer = ((DockerContainerComposer) containerComposer).getStorageContainer();
- String jdbcUrl = storageContainer.getJdbcUrl("");
- try (Connection connection = DriverManager.getConnection(jdbcUrl, storageContainer.getUsername(), storageContainer.getPassword())) {
- for (String each : ALL_DATA_SOURCES) {
- executeWithLog(connection, String.format("CREATE DATABASE %s", each));
- }
- }
- }
-
final boolean isProxyAdapter(final TransactionParameterized parameterized) {
return parameterized.getAdapter().equalsIgnoreCase(AdapterContainerConstants.PROXY);
}
@@ -243,8 +228,8 @@ public abstract class BaseITCase {
log.info("Collect transaction test case, runAdapter is not matched, skip: {}.", each.getName());
continue;
}
- String group = annotation.group();
- addParametersByTransactionTypes(version, currentTestCaseInfo, each, annotation, parameterizedMap, group);
+ String scenario = annotation.scenario();
+ addParametersByTransactionTypes(version, currentTestCaseInfo, each, annotation, parameterizedMap, scenario);
}
return parameterizedMap.values();
@@ -252,47 +237,47 @@ public abstract class BaseITCase {
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) {
+ final Map<String, TransactionParameterized> parameterizedMap, final String scenario) {
if (AdapterContainerConstants.PROXY.equals(currentTestCaseInfo.getRunningAdaptor())) {
List<TransactionType> allowTransactionTypes = ENV.getAllowTransactionTypes().isEmpty() ? Arrays.stream(TransactionType.values()).collect(Collectors.toList())
: ENV.getAllowTransactionTypes().stream().map(TransactionType::valueOf).collect(Collectors.toList());
List<String> allowProviders = ENV.getAllowXAProviders().isEmpty() ? ALL_XA_PROVIDERS : ENV.getAllowXAProviders();
- addTestParameters(version, currentTestCaseInfo, caseClass, allowTransactionTypes, allowProviders, parameterizedMap, group);
+ addTestParameters(version, currentTestCaseInfo, caseClass, allowTransactionTypes, allowProviders, parameterizedMap, scenario);
} else {
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;
}
- addParametersByTransactionProvidersInJDBC(version, currentTestCaseInfo, caseClass, each, parameterizedMap, group);
+ addParametersByTransactionProvidersInJDBC(version, currentTestCaseInfo, caseClass, each, parameterizedMap, scenario);
}
}
}
private static void addParametersByTransactionProvidersInJDBC(final String version, final TransactionTestCaseRegistry currentTestCaseInfo,
final Class<? extends BaseTransactionTestCase> caseClass, final TransactionType each,
- final Map<String, TransactionParameterized> parameterizedMap, final String group) {
+ final Map<String, TransactionParameterized> parameterizedMap, final String scenario) {
if (TransactionType.LOCAL.equals(each)) {
- addTestParameters(version, currentTestCaseInfo, caseClass, Collections.singletonList(each), Collections.singletonList(""), parameterizedMap, group);
+ addTestParameters(version, currentTestCaseInfo, caseClass, Collections.singletonList(each), Collections.singletonList(""), parameterizedMap, scenario);
} else if (TransactionType.XA.equals(each)) {
List<String> allowProviders = ENV.getAllowXAProviders().isEmpty() ? ALL_XA_PROVIDERS : ENV.getAllowXAProviders();
for (String provider : allowProviders) {
- addTestParameters(version, currentTestCaseInfo, caseClass, Collections.singletonList(each), Collections.singletonList(provider), parameterizedMap, group);
+ addTestParameters(version, currentTestCaseInfo, caseClass, Collections.singletonList(each), Collections.singletonList(provider), parameterizedMap, scenario);
}
}
}
private static void addTestParameters(final String version, final TransactionTestCaseRegistry currentTestCaseInfo,
final Class<? extends BaseTransactionTestCase> caseClass, final List<TransactionType> transactionTypes, final List<String> providers,
- final Map<String, TransactionParameterized> parameterizedMap, final String group) {
- String uniqueKey = getUniqueKey(currentTestCaseInfo.getDbType(), currentTestCaseInfo.getRunningAdaptor(), transactionTypes, providers, group);
+ final Map<String, TransactionParameterized> parameterizedMap, final String scenario) {
+ String uniqueKey = getUniqueKey(currentTestCaseInfo.getDbType(), currentTestCaseInfo.getRunningAdaptor(), transactionTypes, providers, scenario);
parameterizedMap.putIfAbsent(uniqueKey, new TransactionParameterized(getSqlDatabaseType(currentTestCaseInfo.getDbType()), currentTestCaseInfo.getRunningAdaptor(), transactionTypes, providers,
- getStorageContainerImage(currentTestCaseInfo.getDbType(), version), group, new LinkedList<>()));
+ getStorageContainerImage(currentTestCaseInfo.getDbType(), version), scenario, new LinkedList<>()));
parameterizedMap.get(uniqueKey).getTransactionTestCaseClasses().add(caseClass);
}
- private static String getUniqueKey(final String dbType, final String runningAdapter, final List<TransactionType> transactionTypes, final List<String> providers, final String group) {
- return dbType + File.separator + runningAdapter + File.separator + transactionTypes + File.separator + providers + File.separator + group;
+ private static String getUniqueKey(final String dbType, final String runningAdapter, final List<TransactionType> transactionTypes, final List<String> providers, final String scenario) {
+ return dbType + File.separator + runningAdapter + File.separator + transactionTypes + File.separator + providers + File.separator + scenario;
}
private static DatabaseType getSqlDatabaseType(final String databaseType) {
diff --git a/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/base/BaseTransactionITCase.java b/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/base/BaseTransactionITCase.java
index 7b66206a6fa..ae2bc5211e0 100644
--- a/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/base/BaseTransactionITCase.java
+++ b/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/base/BaseTransactionITCase.java
@@ -52,36 +52,9 @@ public abstract class BaseTransactionITCase extends BaseITCase {
private void initProxyConfig() throws SQLException {
addResources();
- assertTrue(waitShardingAlgorithmEffect());
- initTableRules();
createTables();
}
- private boolean waitShardingAlgorithmEffect() throws SQLException {
- long maxWaitTimes = 15;
- long startTime = System.currentTimeMillis();
- int waitTimes = 0;
- do {
- int result = countWithLog("SHOW SHARDING ALGORITHMS");
- if (result >= 5) {
- log.info("waitShardingAlgorithmEffect time consume: {}", System.currentTimeMillis() - startTime);
- return true;
- }
- ThreadUtil.sleep(2, TimeUnit.SECONDS);
- waitTimes++;
- } while (waitTimes <= maxWaitTimes);
- return false;
- }
-
- private void initTableRules() throws SQLException {
- Connection connection = getProxyConnection();
- createOrderTableRule(connection);
- createOrderItemTableRule(connection);
- bindingShardingRule(connection);
- createAccountTableRule(connection);
- createAddressBroadcastTableRule(connection);
- }
-
private void initJdbcConfig() throws SQLException {
createTables();
}
@@ -94,26 +67,6 @@ public abstract class BaseTransactionITCase extends BaseITCase {
createAddressTable(conn);
}
- private void createOrderTableRule(final Connection connection) throws SQLException {
- executeWithLog(connection, getCommonSQLCommand().getCreateOrderTableRule());
- }
-
- private void createOrderItemTableRule(final Connection connection) throws SQLException {
- executeWithLog(connection, getCommonSQLCommand().getCreateOrderItemTableRule());
- }
-
- private void createAccountTableRule(final Connection connection) throws SQLException {
- executeWithLog(connection, getCommonSQLCommand().getCreateAccountTableRule());
- }
-
- private void createAddressBroadcastTableRule(final Connection connection) throws SQLException {
- executeWithLog(connection, getCommonSQLCommand().getCreateAddressBroadcastTableRule());
- }
-
- private void bindingShardingRule(final Connection connection) throws SQLException {
- executeWithLog(connection, "CREATE SHARDING BINDING TABLE RULES (t_order, t_order_item)");
- }
-
/**
* Create account table.
*
diff --git a/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/base/TransactionTestCase.java b/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/base/TransactionTestCase.java
index 428e8fdfc41..0696fe1233e 100644
--- a/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/base/TransactionTestCase.java
+++ b/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/base/TransactionTestCase.java
@@ -53,9 +53,9 @@ public @interface TransactionTestCase {
TransactionType[] transactionTypes() default {TransactionType.LOCAL, TransactionType.XA, TransactionType.BASE};
/**
- * Specifies which group the test case belongs to.
+ * Specifies which scenario the test case belongs to.
*
* @return test group
*/
- String group() default "default";
+ String scenario() default "default";
}
diff --git a/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/env/IntegrationTestEnvironment.java b/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/env/IntegrationTestEnvironment.java
index 821fd4bbb6f..2c01958e294 100644
--- a/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/env/IntegrationTestEnvironment.java
+++ b/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/env/IntegrationTestEnvironment.java
@@ -61,7 +61,6 @@ public final class IntegrationTestEnvironment {
private IntegrationTestEnvironment() {
props = loadProperties();
-
itEnvType = TransactionITEnvTypeEnum.valueOf(props.getProperty("transaction.it.env.type", TransactionITEnvTypeEnum.NONE.name()).toUpperCase());
mysqlVersions = splitProperty("transaction.it.docker.mysql.version");
postgresVersions = splitProperty("transaction.it.docker.postgresql.version");
diff --git a/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/container/compose/DockerContainerComposer.java b/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/container/compose/DockerContainerComposer.java
index d5e2c97b0bb..0c56fd6f382 100644
--- a/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/container/compose/DockerContainerComposer.java
+++ b/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/container/compose/DockerContainerComposer.java
@@ -57,12 +57,13 @@ public final class DockerContainerComposer extends BaseContainerComposer {
public DockerContainerComposer(final TransactionParameterized parameterized) {
this.databaseType = parameterized.getDatabaseType();
governanceContainer = getContainers().registerContainer(new ZookeeperContainer());
- storageContainer = getContainers().registerContainer((DockerStorageContainer) StorageContainerFactory.newInstance(databaseType, parameterized.getStorageContainerImage(), "",
- StorageContainerConfigurationFactory.newInstance(databaseType)));
+ storageContainer =
+ getContainers().registerContainer((DockerStorageContainer) StorageContainerFactory.newInstance(databaseType, parameterized.getStorageContainerImage(), parameterized.getScenario(),
+ StorageContainerConfigurationFactory.newInstance(databaseType)));
if (AdapterContainerConstants.PROXY.equalsIgnoreCase(parameterized.getAdapter())) {
jdbcContainer = null;
proxyContainer = (ShardingSphereProxyClusterContainer) AdapterContainerFactory.newInstance(EnvironmentConstants.CLUSTER_MODE, AdapterContainerConstants.PROXY,
- databaseType, storageContainer, "", ProxyClusterContainerConfigurationFactory.newInstance(databaseType));
+ databaseType, storageContainer, parameterized.getScenario(), ProxyClusterContainerConfigurationFactory.newInstance(parameterized.getScenario(), databaseType));
proxyContainer.dependsOn(governanceContainer, storageContainer);
getContainers().registerContainer(proxyContainer);
} else {
diff --git a/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/container/config/proxy/ProxyClusterContainerConfigurationFactory.java b/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/container/config/proxy/ProxyClusterContainerConfigurationFactory.java
index ccc2dc54b6d..48bca34b2e4 100644
--- a/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/container/config/proxy/ProxyClusterContainerConfigurationFactory.java
+++ b/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/container/config/proxy/ProxyClusterContainerConfigurationFactory.java
@@ -36,22 +36,23 @@ public final class ProxyClusterContainerConfigurationFactory {
/**
* Create instance of adaptor container configuration.
- *
+ *
+ * @param scenario scenario
* @param databaseType database type
* @return created instance
*/
- public static AdaptorContainerConfiguration newInstance(final DatabaseType databaseType) {
- return new AdaptorContainerConfiguration(getProxyDatasourceName(databaseType), getMountedResource(databaseType), AdapterContainerUtil.getAdapterContainerImage());
+ public static AdaptorContainerConfiguration newInstance(final String scenario, final DatabaseType databaseType) {
+ return new AdaptorContainerConfiguration(getProxyDatasourceName(databaseType), getMountedResource(scenario, databaseType), AdapterContainerUtil.getAdapterContainerImage());
}
private static String getProxyDatasourceName(final DatabaseType databaseType) {
return (DatabaseTypeUtil.isPostgreSQL(databaseType) || DatabaseTypeUtil.isOpenGauss(databaseType)) ? "postgres" : "";
}
- private static Map<String, String> getMountedResource(final DatabaseType databaseType) {
+ private static Map<String, String> getMountedResource(final String scenario, final DatabaseType databaseType) {
Map<String, String> result = new HashMap<>(2, 1);
result.put(String.format("/env/%s/server.yaml", databaseType.getType().toLowerCase()), ProxyContainerConstants.CONFIG_PATH_IN_CONTAINER + "server.yaml");
- result.put("/logback-test.xml", ProxyContainerConstants.CONFIG_PATH_IN_CONTAINER + "logback.xml");
+ result.put("/env/scenario/" + scenario + "/proxy/conf/" + databaseType.getType().toLowerCase(), ProxyContainerConstants.CONFIG_PATH_IN_CONTAINER);
return result;
}
}
diff --git a/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/param/TransactionParameterized.java b/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/param/TransactionParameterized.java
index 6a85d2ef8ef..53d8c0e6226 100644
--- a/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/param/TransactionParameterized.java
+++ b/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/param/TransactionParameterized.java
@@ -43,12 +43,12 @@ public final class TransactionParameterized {
private final String storageContainerImage;
- private final String group;
+ private final String scenario;
private final Collection<Class<? extends BaseTransactionTestCase>> transactionTestCaseClasses;
@Override
public String toString() {
- return String.format("%s -> %s -> %s -> %s -> %s -> %s", databaseType.getType(), adapter, transactionTypes, providers, storageContainerImage, group);
+ return String.format("%s -> %s -> %s -> %s -> %s -> %s", databaseType.getType(), adapter, transactionTypes, providers, storageContainerImage, scenario);
}
}
diff --git a/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/util/TestCaseClassScanner.java b/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/util/TestCaseClassScanner.java
index 43f4f67cb51..b7ac42b1955 100644
--- a/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/util/TestCaseClassScanner.java
+++ b/test/integration-test/transaction/src/test/java/org/apache/shardingsphere/integration/transaction/util/TestCaseClassScanner.java
@@ -106,13 +106,6 @@ public final class TestCaseClassScanner {
}
}
- @SuppressWarnings("unchecked")
- private static void addClass(final List<Class<? extends BaseTransactionTestCase>> caseClasses, final Class<?> clazz) {
- if (clazz.isAssignableFrom(BaseTransactionTestCase.class)) {
- caseClasses.add((Class<? extends BaseTransactionTestCase>) clazz);
- }
- }
-
private static void scanClassFiles(final File file) {
if (file.isDirectory()) {
for (File f : Objects.requireNonNull(file.listFiles())) {
@@ -136,4 +129,11 @@ public final class TestCaseClassScanner {
}
}
}
+
+ @SuppressWarnings("unchecked")
+ private static void addClass(final List<Class<? extends BaseTransactionTestCase>> caseClasses, final Class<?> clazz) {
+ if (BaseTransactionTestCase.class.isAssignableFrom(clazz)) {
+ caseClasses.add((Class<? extends BaseTransactionTestCase>) clazz);
+ }
+ }
}
diff --git a/test/integration-test/transaction/src/test/resources/env/scenario/default/data/actual/databases.xml b/test/integration-test/transaction/src/test/resources/env/scenario/default/data/actual/databases.xml
new file mode 100644
index 00000000000..7ba6877df39
--- /dev/null
+++ b/test/integration-test/transaction/src/test/resources/env/scenario/default/data/actual/databases.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<databases>
+ <database>transaction_it_0</database>
+ <database>transaction_it_1</database>
+ <database>transaction_it_2</database>
+</databases>
diff --git a/test/integration-test/transaction/src/test/resources/env/scenario/default/data/actual/dataset.xml b/test/integration-test/transaction/src/test/resources/env/scenario/default/data/actual/dataset.xml
new file mode 100644
index 00000000000..840ad09871f
--- /dev/null
+++ b/test/integration-test/transaction/src/test/resources/env/scenario/default/data/actual/dataset.xml
@@ -0,0 +1,19 @@
+<!--
+ ~ 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.
+ -->
+
+<dataset>
+</dataset>
diff --git a/test/integration-test/transaction/src/test/resources/env/scenario/default/data/actual/init-sql/mysql/01-actual-init.sql b/test/integration-test/transaction/src/test/resources/env/scenario/default/data/actual/init-sql/mysql/01-actual-init.sql
new file mode 100644
index 00000000000..a0431f9fa45
--- /dev/null
+++ b/test/integration-test/transaction/src/test/resources/env/scenario/default/data/actual/init-sql/mysql/01-actual-init.sql
@@ -0,0 +1,25 @@
+--
+-- 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.
+--
+
+DROP DATABASE IF EXISTS transaction_it_0;
+CREATE DATABASE transaction_it_0;
+
+DROP DATABASE IF EXISTS transaction_it_1;
+CREATE DATABASE transaction_it_1;
+
+DROP DATABASE IF EXISTS transaction_it_2;
+CREATE DATABASE transaction_it_2;
diff --git a/test/integration-test/transaction/src/test/resources/env/scenario/default/data/actual/init-sql/opengauss/01-actual-init.sql b/test/integration-test/transaction/src/test/resources/env/scenario/default/data/actual/init-sql/opengauss/01-actual-init.sql
new file mode 100644
index 00000000000..a0431f9fa45
--- /dev/null
+++ b/test/integration-test/transaction/src/test/resources/env/scenario/default/data/actual/init-sql/opengauss/01-actual-init.sql
@@ -0,0 +1,25 @@
+--
+-- 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.
+--
+
+DROP DATABASE IF EXISTS transaction_it_0;
+CREATE DATABASE transaction_it_0;
+
+DROP DATABASE IF EXISTS transaction_it_1;
+CREATE DATABASE transaction_it_1;
+
+DROP DATABASE IF EXISTS transaction_it_2;
+CREATE DATABASE transaction_it_2;
diff --git a/test/integration-test/transaction/src/test/resources/env/scenario/default/data/actual/init-sql/postgresql/01-actual-init.sql b/test/integration-test/transaction/src/test/resources/env/scenario/default/data/actual/init-sql/postgresql/01-actual-init.sql
new file mode 100644
index 00000000000..a0431f9fa45
--- /dev/null
+++ b/test/integration-test/transaction/src/test/resources/env/scenario/default/data/actual/init-sql/postgresql/01-actual-init.sql
@@ -0,0 +1,25 @@
+--
+-- 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.
+--
+
+DROP DATABASE IF EXISTS transaction_it_0;
+CREATE DATABASE transaction_it_0;
+
+DROP DATABASE IF EXISTS transaction_it_1;
+CREATE DATABASE transaction_it_1;
+
+DROP DATABASE IF EXISTS transaction_it_2;
+CREATE DATABASE transaction_it_2;
diff --git a/test/integration-test/transaction/src/test/resources/env/scenario/default/data/expected/databases.xml b/test/integration-test/transaction/src/test/resources/env/scenario/default/data/expected/databases.xml
new file mode 100644
index 00000000000..7d313fee9d0
--- /dev/null
+++ b/test/integration-test/transaction/src/test/resources/env/scenario/default/data/expected/databases.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<databases>
+ <database>dataset</database>
+</databases>
diff --git a/test/integration-test/transaction/src/test/resources/env/scenario/default/data/expected/dataset.xml b/test/integration-test/transaction/src/test/resources/env/scenario/default/data/expected/dataset.xml
new file mode 100644
index 00000000000..840ad09871f
--- /dev/null
+++ b/test/integration-test/transaction/src/test/resources/env/scenario/default/data/expected/dataset.xml
@@ -0,0 +1,19 @@
+<!--
+ ~ 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.
+ -->
+
+<dataset>
+</dataset>
diff --git a/test/integration-test/transaction/src/test/resources/env/scenario/default/data/expected/init-sql/mysql/expected-init.sql b/test/integration-test/transaction/src/test/resources/env/scenario/default/data/expected/init-sql/mysql/expected-init.sql
new file mode 100644
index 00000000000..a7f01e4652d
--- /dev/null
+++ b/test/integration-test/transaction/src/test/resources/env/scenario/default/data/expected/init-sql/mysql/expected-init.sql
@@ -0,0 +1,19 @@
+--
+-- 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.
+--
+
+DROP DATABASE IF EXISTS dataset;
+CREATE DATABASE dataset;
diff --git a/test/integration-test/transaction/src/test/resources/env/scenario/default/data/expected/init-sql/opengauss/expected-init.sql b/test/integration-test/transaction/src/test/resources/env/scenario/default/data/expected/init-sql/opengauss/expected-init.sql
new file mode 100644
index 00000000000..a7f01e4652d
--- /dev/null
+++ b/test/integration-test/transaction/src/test/resources/env/scenario/default/data/expected/init-sql/opengauss/expected-init.sql
@@ -0,0 +1,19 @@
+--
+-- 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.
+--
+
+DROP DATABASE IF EXISTS dataset;
+CREATE DATABASE dataset;
diff --git a/test/integration-test/transaction/src/test/resources/env/scenario/default/data/expected/init-sql/postgresql/expected-init.sql b/test/integration-test/transaction/src/test/resources/env/scenario/default/data/expected/init-sql/postgresql/expected-init.sql
new file mode 100644
index 00000000000..a7f01e4652d
--- /dev/null
+++ b/test/integration-test/transaction/src/test/resources/env/scenario/default/data/expected/init-sql/postgresql/expected-init.sql
@@ -0,0 +1,19 @@
+--
+-- 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.
+--
+
+DROP DATABASE IF EXISTS dataset;
+CREATE DATABASE dataset;
diff --git a/test/integration-test/transaction/src/test/resources/env/scenario/default/proxy/conf/mysql/rule.yaml b/test/integration-test/transaction/src/test/resources/env/scenario/default/proxy/conf/mysql/rule.yaml
new file mode 100644
index 00000000000..b59153145dd
--- /dev/null
+++ b/test/integration-test/transaction/src/test/resources/env/scenario/default/proxy/conf/mysql/rule.yaml
@@ -0,0 +1,99 @@
+#
+# 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.
+#
+
+######################################################################################################
+#
+# If you want to configure governance, authorization and proxy properties, please refer to this file.
+#
+######################################################################################################
+
+databaseName: sharding_db
+rules:
+ - !TRANSACTION
+ defaultType: LOCAL
+ - !SHARDING
+ tables:
+ t_order:
+ actualDataNodes: ds_${0..1}.t_order_${0..1}
+ tableStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: t_order_inline
+ keyGenerateStrategy:
+ column: order_id
+ keyGeneratorName: snowflake
+ t_order_item:
+ actualDataNodes: ds_${0..1}.t_order_item_${0..1}
+ tableStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: t_order_item_inline
+ keyGenerateStrategy:
+ column: order_item_id
+ keyGeneratorName: snowflake
+ account:
+ actualDataNodes: ds_${0..1}.account_${0..1}
+ databaseStrategy:
+ standard:
+ shardingColumn: id
+ shardingAlgorithmName: database_id_inline
+ tableStrategy:
+ standard:
+ shardingColumn: id
+ shardingAlgorithmName: account_inline
+ keyGenerateStrategy:
+ column: id
+ keyGeneratorName: snowflake
+ bindingTables:
+ - t_order,t_order_item
+ broadcastTables:
+ - t_address
+ defaultDatabaseStrategy:
+ standard:
+ shardingColumn: user_id
+ shardingAlgorithmName: database_inline
+ defaultTableStrategy:
+ none:
+
+ shardingAlgorithms:
+ database_inline:
+ type: INLINE
+ props:
+ algorithm-expression: ds_${user_id % 2}
+ database_id_inline:
+ type: INLINE
+ props:
+ algorithm-expression: ds_${id % 2}
+ t_order_inline:
+ type: INLINE
+ props:
+ algorithm-expression: t_order_${order_id % 2}
+ t_order_item_inline:
+ type: INLINE
+ props:
+ algorithm-expression: t_order_item_${order_id % 2}
+ account_inline:
+ type: INLINE
+ props:
+ algorithm-expression: account_${Math.floorMod(Math.floorDiv(id.longValue(), 2L), 2L)}
+
+ keyGenerators:
+ snowflake:
+ type: SNOWFLAKE
+
+props:
+ sql-show: false
diff --git a/test/integration-test/transaction/src/test/resources/env/scenario/default/proxy/conf/opengauss/rule.yaml b/test/integration-test/transaction/src/test/resources/env/scenario/default/proxy/conf/opengauss/rule.yaml
new file mode 100644
index 00000000000..b59153145dd
--- /dev/null
+++ b/test/integration-test/transaction/src/test/resources/env/scenario/default/proxy/conf/opengauss/rule.yaml
@@ -0,0 +1,99 @@
+#
+# 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.
+#
+
+######################################################################################################
+#
+# If you want to configure governance, authorization and proxy properties, please refer to this file.
+#
+######################################################################################################
+
+databaseName: sharding_db
+rules:
+ - !TRANSACTION
+ defaultType: LOCAL
+ - !SHARDING
+ tables:
+ t_order:
+ actualDataNodes: ds_${0..1}.t_order_${0..1}
+ tableStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: t_order_inline
+ keyGenerateStrategy:
+ column: order_id
+ keyGeneratorName: snowflake
+ t_order_item:
+ actualDataNodes: ds_${0..1}.t_order_item_${0..1}
+ tableStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: t_order_item_inline
+ keyGenerateStrategy:
+ column: order_item_id
+ keyGeneratorName: snowflake
+ account:
+ actualDataNodes: ds_${0..1}.account_${0..1}
+ databaseStrategy:
+ standard:
+ shardingColumn: id
+ shardingAlgorithmName: database_id_inline
+ tableStrategy:
+ standard:
+ shardingColumn: id
+ shardingAlgorithmName: account_inline
+ keyGenerateStrategy:
+ column: id
+ keyGeneratorName: snowflake
+ bindingTables:
+ - t_order,t_order_item
+ broadcastTables:
+ - t_address
+ defaultDatabaseStrategy:
+ standard:
+ shardingColumn: user_id
+ shardingAlgorithmName: database_inline
+ defaultTableStrategy:
+ none:
+
+ shardingAlgorithms:
+ database_inline:
+ type: INLINE
+ props:
+ algorithm-expression: ds_${user_id % 2}
+ database_id_inline:
+ type: INLINE
+ props:
+ algorithm-expression: ds_${id % 2}
+ t_order_inline:
+ type: INLINE
+ props:
+ algorithm-expression: t_order_${order_id % 2}
+ t_order_item_inline:
+ type: INLINE
+ props:
+ algorithm-expression: t_order_item_${order_id % 2}
+ account_inline:
+ type: INLINE
+ props:
+ algorithm-expression: account_${Math.floorMod(Math.floorDiv(id.longValue(), 2L), 2L)}
+
+ keyGenerators:
+ snowflake:
+ type: SNOWFLAKE
+
+props:
+ sql-show: false
diff --git a/test/integration-test/transaction/src/test/resources/env/scenario/default/proxy/conf/postgresql/rule.yaml b/test/integration-test/transaction/src/test/resources/env/scenario/default/proxy/conf/postgresql/rule.yaml
new file mode 100644
index 00000000000..b59153145dd
--- /dev/null
+++ b/test/integration-test/transaction/src/test/resources/env/scenario/default/proxy/conf/postgresql/rule.yaml
@@ -0,0 +1,99 @@
+#
+# 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.
+#
+
+######################################################################################################
+#
+# If you want to configure governance, authorization and proxy properties, please refer to this file.
+#
+######################################################################################################
+
+databaseName: sharding_db
+rules:
+ - !TRANSACTION
+ defaultType: LOCAL
+ - !SHARDING
+ tables:
+ t_order:
+ actualDataNodes: ds_${0..1}.t_order_${0..1}
+ tableStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: t_order_inline
+ keyGenerateStrategy:
+ column: order_id
+ keyGeneratorName: snowflake
+ t_order_item:
+ actualDataNodes: ds_${0..1}.t_order_item_${0..1}
+ tableStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: t_order_item_inline
+ keyGenerateStrategy:
+ column: order_item_id
+ keyGeneratorName: snowflake
+ account:
+ actualDataNodes: ds_${0..1}.account_${0..1}
+ databaseStrategy:
+ standard:
+ shardingColumn: id
+ shardingAlgorithmName: database_id_inline
+ tableStrategy:
+ standard:
+ shardingColumn: id
+ shardingAlgorithmName: account_inline
+ keyGenerateStrategy:
+ column: id
+ keyGeneratorName: snowflake
+ bindingTables:
+ - t_order,t_order_item
+ broadcastTables:
+ - t_address
+ defaultDatabaseStrategy:
+ standard:
+ shardingColumn: user_id
+ shardingAlgorithmName: database_inline
+ defaultTableStrategy:
+ none:
+
+ shardingAlgorithms:
+ database_inline:
+ type: INLINE
+ props:
+ algorithm-expression: ds_${user_id % 2}
+ database_id_inline:
+ type: INLINE
+ props:
+ algorithm-expression: ds_${id % 2}
+ t_order_inline:
+ type: INLINE
+ props:
+ algorithm-expression: t_order_${order_id % 2}
+ t_order_item_inline:
+ type: INLINE
+ props:
+ algorithm-expression: t_order_item_${order_id % 2}
+ account_inline:
+ type: INLINE
+ props:
+ algorithm-expression: account_${Math.floorMod(Math.floorDiv(id.longValue(), 2L), 2L)}
+
+ keyGenerators:
+ snowflake:
+ type: SNOWFLAKE
+
+props:
+ sql-show: false