This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 4620edc97d6 Refactor TransactionTestCaseRegistry (#36715)
4620edc97d6 is described below
commit 4620edc97d64a15a3ce790344d4c23da9c2cd2b5
Author: Liang Zhang <[email protected]>
AuthorDate: Fri Sep 26 01:35:35 2025 +0800
Refactor TransactionTestCaseRegistry (#36715)
---
.../transaction/engine/base/TransactionBaseE2EIT.java | 18 +++++++++---------
.../engine/constants/TransactionTestConstants.java | 2 +-
.../env/enums/TransactionTestCaseRegistry.java | 17 +++++++++--------
3 files changed, 19 insertions(+), 18 deletions(-)
diff --git
a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/engine/base/TransactionBaseE2EIT.java
b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/engine/base/TransactionBaseE2EIT.java
index 06fe3268126..ad87c211cd1 100644
---
a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/engine/base/TransactionBaseE2EIT.java
+++
b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/engine/base/TransactionBaseE2EIT.java
@@ -359,7 +359,7 @@ public abstract class TransactionBaseE2EIT {
if (TEST_CASES.isEmpty()) {
log.warn("Transaction test cases are empty.");
}
- String databaseVersion =
ENV.getArtifactEnvironment().getDatabaseImage(TypedSPILoader.getService(DatabaseType.class,
registry.getDbType()));
+ String databaseVersion =
ENV.getArtifactEnvironment().getDatabaseImage(registry.getDatabaseType());
for (Class<? extends BaseTransactionTestCase> each : TEST_CASES) {
if (!TRANSACTION_ENV.getCases().isEmpty() &&
!ENV.getScenarios().contains(each.getSimpleName())) {
log.info("Collect transaction test case, need to run cases
don't contain this, skip: {}.", each.getName());
@@ -370,7 +370,7 @@ public abstract class TransactionBaseE2EIT {
log.info("Collect transaction test case, annotation is
null, skip: {}.", each.getName());
continue;
}
- Optional<String> databaseType =
Arrays.stream(transactionTestCase.dbTypes()).filter(registry.getDbType()::equalsIgnoreCase).findAny();
+ Optional<String> databaseType =
Arrays.stream(transactionTestCase.dbTypes()).filter(dbTypes ->
registry.getDatabaseType().getType().equalsIgnoreCase(dbTypes)).findAny();
if (!databaseType.isPresent()) {
log.info("Collect transaction test case, dbType is not
matched, skip: {}.", each.getName());
continue;
@@ -418,19 +418,19 @@ public abstract class TransactionBaseE2EIT {
private void setTestParameters(final Map<String,
TransactionTestParameter> testParams, final TransactionTestCaseRegistry
registry, final String databaseVersion,
final List<TransactionType>
transactionTypes, final List<String> providers, final String scenario, final
Class<? extends BaseTransactionTestCase> caseClass) {
- String key = getUniqueKey(registry.getDbType(),
registry.getRunningAdaptor(), transactionTypes, providers, scenario);
- testParams.putIfAbsent(key, new
TransactionTestParameter(TypedSPILoader.getService(DatabaseType.class,
registry.getDbType()),
+ String key = getUniqueKey(registry.getDatabaseType(),
registry.getRunningAdaptor(), transactionTypes, providers, scenario);
+ testParams.putIfAbsent(key, new
TransactionTestParameter(TypedSPILoader.getService(DatabaseType.class,
registry.getDatabaseType()),
registry.getRunningAdaptor(),
ENV.getArtifactEnvironment().getProxyPortBindings(), transactionTypes,
providers,
- getStorageContainerImageName(registry.getDbType(),
databaseVersion), scenario, new LinkedList<>()));
+ getStorageContainerImageName(registry.getDatabaseType(),
databaseVersion), scenario, new LinkedList<>()));
testParams.get(key).getTransactionTestCaseClasses().add(caseClass);
}
- private String getUniqueKey(final String databaseType, final String
runningAdapter, final List<TransactionType> transactionTypes, final
List<String> providers, final String scenario) {
- return String.join(File.separator, databaseType, runningAdapter,
transactionTypes.toString(), providers.toString(), scenario);
+ private String getUniqueKey(final DatabaseType databaseType, final
String runningAdapter, final List<TransactionType> transactionTypes, final
List<String> providers, final String scenario) {
+ return String.join(File.separator, databaseType.getType(),
runningAdapter, transactionTypes.toString(), providers.toString(), scenario);
}
- private String getStorageContainerImageName(final String databaseType,
final String databaseVersion) {
- switch (databaseType) {
+ private String getStorageContainerImageName(final DatabaseType
databaseType, final String databaseVersion) {
+ switch (databaseType.getType()) {
case TransactionTestConstants.MYSQL:
case TransactionTestConstants.POSTGRESQL:
case TransactionTestConstants.OPENGAUSS:
diff --git
a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/engine/constants/TransactionTestConstants.java
b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/engine/constants/TransactionTestConstants.java
index 32fecd10722..7e082c1cd54 100644
---
a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/engine/constants/TransactionTestConstants.java
+++
b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/engine/constants/TransactionTestConstants.java
@@ -28,7 +28,7 @@ public final class TransactionTestConstants {
public static final String MYSQL = "MySQL";
- public static final String OPENGAUSS = "OpenGauss";
+ public static final String OPENGAUSS = "openGauss";
public static final String POSTGRESQL = "PostgreSQL";
diff --git
a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/env/enums/TransactionTestCaseRegistry.java
b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/env/enums/TransactionTestCaseRegistry.java
index 3f521c2456a..bc994f45536 100644
---
a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/env/enums/TransactionTestCaseRegistry.java
+++
b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/env/enums/TransactionTestCaseRegistry.java
@@ -19,9 +19,10 @@ package
org.apache.shardingsphere.test.e2e.operation.transaction.env.enums;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
+import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import
org.apache.shardingsphere.test.e2e.env.runtime.type.ArtifactEnvironment.Adapter;
import
org.apache.shardingsphere.test.e2e.operation.transaction.engine.base.TransactionBaseE2EIT;
-import
org.apache.shardingsphere.test.e2e.operation.transaction.engine.constants.TransactionTestConstants;
import
org.apache.shardingsphere.test.e2e.operation.transaction.engine.database.mysql.MySQLJdbcTransactionE2ETT;
import
org.apache.shardingsphere.test.e2e.operation.transaction.engine.database.mysql.MySQLProxyTransactionE2EIT;
import
org.apache.shardingsphere.test.e2e.operation.transaction.engine.database.opengauss.OpenGaussJdbcTransactionE2EIT;
@@ -33,21 +34,21 @@ import
org.apache.shardingsphere.test.e2e.operation.transaction.engine.database.
@Getter
public enum TransactionTestCaseRegistry {
- MYSQL_JDBC_IT(MySQLJdbcTransactionE2ETT.class,
TransactionTestConstants.MYSQL, Adapter.JDBC.getValue()),
+ MYSQL_JDBC_IT(MySQLJdbcTransactionE2ETT.class,
TypedSPILoader.getService(DatabaseType.class, "MySQL"),
Adapter.JDBC.getValue()),
- MYSQL_PROXY_IT(MySQLProxyTransactionE2EIT.class,
TransactionTestConstants.MYSQL, Adapter.PROXY.getValue()),
+ MYSQL_PROXY_IT(MySQLProxyTransactionE2EIT.class,
TypedSPILoader.getService(DatabaseType.class, "MySQL"),
Adapter.PROXY.getValue()),
- OPENGAUSS_JDBC_IT(OpenGaussJdbcTransactionE2EIT.class,
TransactionTestConstants.OPENGAUSS, Adapter.JDBC.getValue()),
+ OPENGAUSS_JDBC_IT(OpenGaussJdbcTransactionE2EIT.class,
TypedSPILoader.getService(DatabaseType.class, "openGauss"),
Adapter.JDBC.getValue()),
- OPENGAUSS_PROXY_IT(OpenGaussProxyTransactionE2EIT.class,
TransactionTestConstants.OPENGAUSS, Adapter.PROXY.getValue()),
+ OPENGAUSS_PROXY_IT(OpenGaussProxyTransactionE2EIT.class,
TypedSPILoader.getService(DatabaseType.class, "openGauss"),
Adapter.PROXY.getValue()),
- POSTGRESQL_JDBC_IT(PostgreSQLJdbcTransactionE2EIT.class,
TransactionTestConstants.POSTGRESQL, Adapter.JDBC.getValue()),
+ POSTGRESQL_JDBC_IT(PostgreSQLJdbcTransactionE2EIT.class,
TypedSPILoader.getService(DatabaseType.class, "PostgreSQL"),
Adapter.JDBC.getValue()),
- POSTGRESQL_PROXY_IT(PostgreSQLProxyTransactionE2EIT.class,
TransactionTestConstants.POSTGRESQL, Adapter.PROXY.getValue());
+ POSTGRESQL_PROXY_IT(PostgreSQLProxyTransactionE2EIT.class,
TypedSPILoader.getService(DatabaseType.class, "PostgreSQL"),
Adapter.PROXY.getValue());
private final Class<? extends TransactionBaseE2EIT> testCaseClass;
- private final String dbType;
+ private final DatabaseType databaseType;
private final String runningAdaptor;
}