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 9997eb3f6b8 Merge TransactionE2EEnvTypeEnum and RunEnvironment.Type
(#36707)
9997eb3f6b8 is described below
commit 9997eb3f6b8b44049de8051bff4c97088aabd39d
Author: Liang Zhang <[email protected]>
AuthorDate: Thu Sep 25 15:40:02 2025 +0800
Merge TransactionE2EEnvTypeEnum and RunEnvironment.Type (#36707)
* Revise release notes
* Merge TransactionE2EEnvTypeEnum and RunEnvironment.Type
* Merge TransactionE2EEnvTypeEnum and RunEnvironment.Type
---
.../engine/base/TransactionBaseE2EIT.java | 11 ++++-----
.../engine/base/TransactionContainerComposer.java | 4 ++--
.../transaction/env/TransactionE2EEnvironment.java | 26 +++++++++++-----------
.../env/enums/TransactionE2EEnvTypeEnum.java | 23 -------------------
.../TransactionDockerContainerComposer.java | 8 +++----
.../src/test/resources/env/e2e-env.properties | 4 ++--
6 files changed, 25 insertions(+), 51 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 e950da98b57..7e283b3ce0f 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
@@ -28,12 +28,12 @@ import
org.apache.shardingsphere.test.e2e.env.container.storage.option.StorageCo
import
org.apache.shardingsphere.test.e2e.env.container.storage.option.StorageContainerOption;
import
org.apache.shardingsphere.test.e2e.env.container.storage.type.DockerStorageContainer;
import
org.apache.shardingsphere.test.e2e.env.runtime.type.ArtifactEnvironment.Adapter;
+import org.apache.shardingsphere.test.e2e.env.runtime.type.RunEnvironment.Type;
import
org.apache.shardingsphere.test.e2e.operation.transaction.cases.base.BaseTransactionTestCase;
import
org.apache.shardingsphere.test.e2e.operation.transaction.cases.base.BaseTransactionTestCase.TransactionTestCaseParameter;
import
org.apache.shardingsphere.test.e2e.operation.transaction.engine.command.CommonSQLCommand;
import
org.apache.shardingsphere.test.e2e.operation.transaction.engine.constants.TransactionTestConstants;
import
org.apache.shardingsphere.test.e2e.operation.transaction.env.TransactionE2EEnvironment;
-import
org.apache.shardingsphere.test.e2e.operation.transaction.env.enums.TransactionE2EEnvTypeEnum;
import
org.apache.shardingsphere.test.e2e.operation.transaction.env.enums.TransactionTestCaseRegistry;
import
org.apache.shardingsphere.test.e2e.operation.transaction.framework.container.compose.TransactionDockerContainerComposer;
import
org.apache.shardingsphere.test.e2e.operation.transaction.framework.param.TransactionTestParameter;
@@ -278,7 +278,7 @@ public abstract class TransactionBaseE2EIT {
private String getActualJdbcUrlTemplate(final String databaseName, final
TransactionContainerComposer containerComposer) {
StorageContainerConnectOption option =
DatabaseTypedSPILoader.getService(StorageContainerOption.class,
containerComposer.getDatabaseType()).getConnectOption();
- if (ENV.getItEnvType() == TransactionE2EEnvTypeEnum.DOCKER) {
+ if (Type.DOCKER == ENV.getType()) {
DockerStorageContainer storageContainer = (DockerStorageContainer)
((TransactionDockerContainerComposer)
containerComposer.getContainerComposer()).getStorageContainer();
return
option.getURL(containerComposer.getDatabaseType().getType().toLowerCase() +
".host", storageContainer.getExposedPort(), databaseName);
}
@@ -329,7 +329,7 @@ public abstract class TransactionBaseE2EIT {
}
private static boolean isEnabled() {
- return ENV.getItEnvType() != TransactionE2EEnvTypeEnum.NONE;
+ return !ENV.getNeedToRunTestCases().isEmpty() && null != ENV.getType();
}
private static final class TestCaseArgumentsProvider implements
ArgumentsProvider {
@@ -343,10 +343,7 @@ public abstract class TransactionBaseE2EIT {
private Collection<TransactionTestParameter>
getTransactionTestParameters(final Class<? extends TransactionBaseE2EIT>
testCaseClass) {
TransactionTestCaseRegistry currentTestCaseInfo =
ENV.getTransactionTestCaseRegistryMap().get(testCaseClass.getName());
- Collection<TransactionTestParameter> result = new LinkedList<>();
- if (TransactionE2EEnvTypeEnum.NONE != ENV.getItEnvType()) {
- result.addAll(getTestParameters(currentTestCaseInfo));
- }
+ Collection<TransactionTestParameter> result =
getTestParameters(currentTestCaseInfo);
// TODO zhangcheng make sure the test cases should not empty
if (result.isEmpty()) {
result.add(null);
diff --git
a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/engine/base/TransactionContainerComposer.java
b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/engine/base/TransactionContainerComposer.java
index 8c18464a014..574bf67e87b 100644
---
a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/engine/base/TransactionContainerComposer.java
+++
b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/engine/base/TransactionContainerComposer.java
@@ -20,8 +20,8 @@ package
org.apache.shardingsphere.test.e2e.operation.transaction.engine.base;
import lombok.Getter;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import
org.apache.shardingsphere.test.e2e.env.runtime.type.ArtifactEnvironment.Adapter;
+import org.apache.shardingsphere.test.e2e.env.runtime.type.RunEnvironment.Type;
import
org.apache.shardingsphere.test.e2e.operation.transaction.env.TransactionE2EEnvironment;
-import
org.apache.shardingsphere.test.e2e.operation.transaction.env.enums.TransactionE2EEnvTypeEnum;
import
org.apache.shardingsphere.test.e2e.operation.transaction.framework.container.compose.TransactionBaseContainerComposer;
import
org.apache.shardingsphere.test.e2e.operation.transaction.framework.container.compose.TransactionDockerContainerComposer;
import
org.apache.shardingsphere.test.e2e.operation.transaction.framework.container.compose.TransactionNativeContainerComposer;
@@ -50,7 +50,7 @@ public final class TransactionContainerComposer implements
AutoCloseable {
}
private TransactionBaseContainerComposer initContainerComposer(final
TransactionTestParameter testParam) {
- TransactionBaseContainerComposer result =
TransactionE2EEnvTypeEnum.NONE == ENV.getItEnvType() ? new
TransactionNativeContainerComposer() : new
TransactionDockerContainerComposer(testParam);
+ TransactionBaseContainerComposer result = Type.NATIVE == ENV.getType()
? new TransactionNativeContainerComposer() : new
TransactionDockerContainerComposer(testParam);
result.start();
return result;
}
diff --git
a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/env/TransactionE2EEnvironment.java
b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/env/TransactionE2EEnvironment.java
index 9601e65c103..132e19d1b7b 100644
---
a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/env/TransactionE2EEnvironment.java
+++
b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/env/TransactionE2EEnvironment.java
@@ -26,7 +26,7 @@ import
org.apache.shardingsphere.test.e2e.env.container.constants.StorageContain
import
org.apache.shardingsphere.test.e2e.env.container.storage.option.dialect.mysql.MySQLStorageContainerCreateOption;
import
org.apache.shardingsphere.test.e2e.env.container.storage.option.dialect.opengauss.OpenGaussStorageContainerCreateOption;
import
org.apache.shardingsphere.test.e2e.env.container.storage.option.dialect.postgresql.PostgreSQLStorageContainerCreateOption;
-import
org.apache.shardingsphere.test.e2e.operation.transaction.env.enums.TransactionE2EEnvTypeEnum;
+import org.apache.shardingsphere.test.e2e.env.runtime.type.RunEnvironment.Type;
import
org.apache.shardingsphere.test.e2e.operation.transaction.env.enums.TransactionTestCaseRegistry;
import java.io.IOException;
@@ -46,7 +46,7 @@ public final class TransactionE2EEnvironment {
private final Properties props;
- private final TransactionE2EEnvTypeEnum itEnvType;
+ private final Type type;
private final List<String> portBindings;
@@ -66,7 +66,7 @@ public final class TransactionE2EEnvironment {
private TransactionE2EEnvironment() {
props = loadProperties();
- itEnvType =
TransactionE2EEnvTypeEnum.valueOf(props.getProperty("transaction.e2e.env.type",
TransactionE2EEnvTypeEnum.NONE.name()).toUpperCase());
+ type = props.containsKey("transaction.e2e.env.type") ? null :
Type.valueOf(props.getProperty("transaction.e2e.env.type").toUpperCase());
portBindings = splitProperty("transaction.e2e.proxy.port.bindings");
mysqlVersions = splitProperty("transaction.e2e.docker.mysql.version");
postgresqlVersions =
splitProperty("transaction.e2e.docker.postgresql.version");
@@ -78,14 +78,6 @@ public final class TransactionE2EEnvironment {
transactionTestCaseRegistryMap = initTransactionTestCaseRegistryMap();
}
- private Map<String, TransactionTestCaseRegistry>
initTransactionTestCaseRegistryMap() {
- Map<String, TransactionTestCaseRegistry> result = new
HashMap<>(TransactionTestCaseRegistry.values().length, 1F);
- for (TransactionTestCaseRegistry each :
TransactionTestCaseRegistry.values()) {
- result.put(each.getTestCaseClass().getName(), each);
- }
- return result;
- }
-
private List<String> splitProperty(final String key) {
return Arrays.stream(props.getOrDefault(key,
"").toString().split(",")).filter(each ->
!Strings.isNullOrEmpty(each)).map(String::trim).collect(Collectors.toList());
}
@@ -103,6 +95,14 @@ public final class TransactionE2EEnvironment {
return result;
}
+ private Map<String, TransactionTestCaseRegistry>
initTransactionTestCaseRegistryMap() {
+ Map<String, TransactionTestCaseRegistry> result = new
HashMap<>(TransactionTestCaseRegistry.values().length, 1F);
+ for (TransactionTestCaseRegistry each :
TransactionTestCaseRegistry.values()) {
+ result.put(each.getTestCaseClass().getName(), each);
+ }
+ return result;
+ }
+
/**
* Get actual data source default port.
*
@@ -130,7 +130,7 @@ public final class TransactionE2EEnvironment {
* @return actual data source username
*/
public String getActualDataSourceUsername(final DatabaseType databaseType)
{
- return itEnvType == TransactionE2EEnvTypeEnum.NATIVE
+ return type == Type.NATIVE
?
String.valueOf(props.getOrDefault(String.format("transaction.e2e.native.%s.username",
databaseType.getType().toLowerCase()), ProxyContainerConstants.USER))
: StorageContainerConstants.OPERATION_USER;
}
@@ -142,7 +142,7 @@ public final class TransactionE2EEnvironment {
* @return actual data source username
*/
public String getActualDataSourcePassword(final DatabaseType databaseType)
{
- return itEnvType == TransactionE2EEnvTypeEnum.NATIVE
+ return type == Type.NATIVE
?
props.getOrDefault(String.format("transaction.e2e.native.%s.password",
databaseType.getType().toLowerCase()),
ProxyContainerConstants.PASSWORD).toString()
: StorageContainerConstants.OPERATION_PASSWORD;
}
diff --git
a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/env/enums/TransactionE2EEnvTypeEnum.java
b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/env/enums/TransactionE2EEnvTypeEnum.java
deleted file mode 100644
index 1c839beb572..00000000000
---
a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/env/enums/TransactionE2EEnvTypeEnum.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.test.e2e.operation.transaction.env.enums;
-
-public enum TransactionE2EEnvTypeEnum {
-
- NONE, DOCKER, NATIVE
-}
diff --git
a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/framework/container/compose/TransactionDockerContainerComposer.java
b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/framework/container/compose/TransactionDockerContainerComposer.java
index c370cd26c8c..739b2153b14 100644
---
a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/framework/container/compose/TransactionDockerContainerComposer.java
+++
b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/framework/container/compose/TransactionDockerContainerComposer.java
@@ -36,8 +36,8 @@ import
org.apache.shardingsphere.test.e2e.env.container.storage.option.StorageCo
import
org.apache.shardingsphere.test.e2e.env.container.storage.type.DockerStorageContainer;
import
org.apache.shardingsphere.test.e2e.env.container.storage.type.NativeStorageContainer;
import
org.apache.shardingsphere.test.e2e.env.runtime.type.ArtifactEnvironment.Adapter;
+import org.apache.shardingsphere.test.e2e.env.runtime.type.RunEnvironment.Type;
import
org.apache.shardingsphere.test.e2e.operation.transaction.env.TransactionE2EEnvironment;
-import
org.apache.shardingsphere.test.e2e.operation.transaction.env.enums.TransactionE2EEnvTypeEnum;
import
org.apache.shardingsphere.test.e2e.operation.transaction.framework.container.config.TransactionProxyContainerConfigurationFactory;
import
org.apache.shardingsphere.test.e2e.operation.transaction.framework.param.TransactionTestParameter;
@@ -61,8 +61,7 @@ public final class TransactionDockerContainerComposer extends
TransactionBaseCon
super(testParam.getScenario());
DatabaseType databaseType = testParam.getDatabaseType();
GovernanceContainer governanceContainer =
getContainers().registerContainer(new
GovernanceContainer(TypedSPILoader.getService(GovernanceContainerOption.class,
"ZooKeeper")));
- TransactionE2EEnvTypeEnum envType =
TransactionE2EEnvironment.getInstance().getItEnvType();
- if (TransactionE2EEnvTypeEnum.DOCKER == envType) {
+ if (Type.DOCKER == TransactionE2EEnvironment.getInstance().getType()) {
storageContainer = getContainers().registerContainer(new
DockerStorageContainer(
testParam.getStorageContainerImage(),
DatabaseTypedSPILoader.getService(StorageContainerOption.class, databaseType),
testParam.getScenario()));
} else {
@@ -71,7 +70,8 @@ public final class TransactionDockerContainerComposer extends
TransactionBaseCon
if (Adapter.PROXY.getValue().equalsIgnoreCase(testParam.getAdapter()))
{
jdbcContainer = null;
AdaptorContainerConfiguration containerConfig =
TransactionProxyContainerConfigurationFactory.newInstance(testParam.getScenario(),
databaseType, testParam.getPortBindings());
- proxyContainer =
AdapterContainerFactory.newInstance(Adapter.PROXY, databaseType,
testParam.getScenario(), containerConfig, storageContainer, envType.name());
+ proxyContainer = AdapterContainerFactory.newInstance(
+ Adapter.PROXY, databaseType, testParam.getScenario(),
containerConfig, storageContainer,
TransactionE2EEnvironment.getInstance().getType().name());
if (proxyContainer instanceof DockerE2EContainer) {
((DockerE2EContainer)
proxyContainer).dependsOn(governanceContainer, storageContainer);
}
diff --git
a/test/e2e/operation/transaction/src/test/resources/env/e2e-env.properties
b/test/e2e/operation/transaction/src/test/resources/env/e2e-env.properties
index 1f277145515..65f115246b6 100644
--- a/test/e2e/operation/transaction/src/test/resources/env/e2e-env.properties
+++ b/test/e2e/operation/transaction/src/test/resources/env/e2e-env.properties
@@ -14,8 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-# transaction.e2e.type=NONE,DOCKER,NATIVE
-transaction.e2e.env.type=NONE
+# transaction.e2e.type=DOCKER,NATIVE
+transaction.e2e.env.type=
# transaction.e2e.proxy.binding.ports=63308:3308
# transaction.e2e.env.cases=ClassicTransferTestCase
transaction.e2e.env.cases=TransactionDeadlockTestCase,
MultiJDBCConnectionsTestCase, MultiTransactionInConnectionTestCase,
MultiOperationsCommitAndRollbackTestCase, MySQLAutoCommitTestCase,
PostgreSQLAutoCommitTestCase, BroadcastTableTransactionTestCase,
ExceptionInTransactionTestCase, MultiTableCommitAndRollbackTestCase,
SingleTableCommitAndRollbackTestCase, MySQLSetReadOnlyTestCase,
MySQLLocalTruncateTestCase, MySQLXATruncateTestCase, OpenGaussCursorTestCase,
NestedTransactionTestCase, [...]