You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2025/09/26 13:12:57 UTC
(shardingsphere) branch master updated: Remove PipelineE2EEnvironment.type (#36721)
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 679856d6d55 Remove PipelineE2EEnvironment.type (#36721)
679856d6d55 is described below
commit 679856d6d5518ffd4c23cb98becbe95472c9e7ca
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Fri Sep 26 21:12:51 2025 +0800
Remove PipelineE2EEnvironment.type (#36721)
---
.../pipeline/cases/PipelineContainerComposer.java | 15 ++++++++-------
.../pipeline/cases/migration/AbstractMigrationE2EIT.java | 4 ++--
.../general/PostgreSQLToMySQLMigrationE2EIT.java | 14 ++++++++------
.../operation/pipeline/env/PipelineE2EEnvironment.java | 12 ++----------
.../pipeline/framework/param/PipelineE2ECondition.java | 3 ++-
5 files changed, 22 insertions(+), 26 deletions(-)
diff --git a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/cases/PipelineContainerComposer.java b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/cases/PipelineContainerComposer.java
index 22b99ed3b72..86b375b63f0 100644
--- a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/cases/PipelineContainerComposer.java
+++ b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/cases/PipelineContainerComposer.java
@@ -125,10 +125,11 @@ public final class PipelineContainerComposer implements AutoCloseable {
public PipelineContainerComposer(final PipelineTestParameter testParam, final PipelineJobType jobType) {
databaseType = testParam.getDatabaseType();
- containerComposer = Type.DOCKER == PipelineE2EEnvironment.getInstance().getType()
+ Type type = E2ETestEnvironment.getInstance().getRunEnvironment().getType();
+ containerComposer = Type.DOCKER == type
? new PipelineDockerContainerComposer(testParam.getDatabaseType(), testParam.getStorageContainerImage(), testParam.getStorageContainerCount())
: new PipelineNativeContainerComposer(testParam.getDatabaseType());
- if (Type.DOCKER == PipelineE2EEnvironment.getInstance().getType()) {
+ if (Type.DOCKER == type) {
username = StorageContainerConstants.OPERATION_USER;
password = StorageContainerConstants.OPERATION_PASSWORD;
} else {
@@ -157,7 +158,7 @@ public final class PipelineContainerComposer implements AutoCloseable {
}
private void cleanUpPipelineJobs(final Connection connection, final PipelineJobType jobType) throws SQLException {
- if (Type.NATIVE != PipelineE2EEnvironment.getInstance().getType()) {
+ if (Type.NATIVE != E2ETestEnvironment.getInstance().getRunEnvironment().getType()) {
return;
}
String jobTypeName = jobType.getType();
@@ -197,7 +198,7 @@ public final class PipelineContainerComposer implements AutoCloseable {
}
private void cleanUpProxyDatabase(final Connection connection) {
- if (Type.NATIVE != PipelineE2EEnvironment.getInstance().getType()) {
+ if (Type.NATIVE != E2ETestEnvironment.getInstance().getRunEnvironment().getType()) {
return;
}
try (Statement statement = connection.createStatement()) {
@@ -218,7 +219,7 @@ public final class PipelineContainerComposer implements AutoCloseable {
}
private void cleanUpDataSource() {
- if (Type.NATIVE != PipelineE2EEnvironment.getInstance().getType()) {
+ if (Type.NATIVE != E2ETestEnvironment.getInstance().getRunEnvironment().getType()) {
return;
}
DatabaseTypeRegistry databaseTypeRegistry = new DatabaseTypeRegistry(databaseType);
@@ -282,7 +283,7 @@ public final class PipelineContainerComposer implements AutoCloseable {
*/
public String getActualJdbcUrlTemplate(final String databaseName, final boolean isInContainer, final int storageContainerIndex) {
StorageContainerConnectOption option = DatabaseTypedSPILoader.getService(StorageContainerOption.class, databaseType).getConnectOption();
- if (Type.DOCKER == PipelineE2EEnvironment.getInstance().getType()) {
+ if (Type.DOCKER == E2ETestEnvironment.getInstance().getRunEnvironment().getType()) {
DockerStorageContainer storageContainer = ((PipelineDockerContainerComposer) containerComposer).getStorageContainers().get(storageContainerIndex);
return isInContainer
? option.getURL(storageContainer.getNetworkAliases().get(0), storageContainer.getExposedPort(), databaseName)
@@ -618,7 +619,7 @@ public final class PipelineContainerComposer implements AutoCloseable {
YamlRootConfiguration rootConfig = getYamlRootConfig();
ShardingSpherePreconditions.checkNotNull(rootConfig.getDataSources(), () -> new IllegalStateException("dataSources is null"));
ShardingSpherePreconditions.checkNotNull(rootConfig.getRules(), () -> new IllegalStateException("rules is null"));
- if (Type.DOCKER == PipelineE2EEnvironment.getInstance().getType()) {
+ if (Type.DOCKER == E2ETestEnvironment.getInstance().getRunEnvironment().getType()) {
DockerStorageContainer storageContainer = ((PipelineDockerContainerComposer) containerComposer).getStorageContainers().get(0);
String sourceUrl = String.join(":", storageContainer.getNetworkAliases().get(0), Integer.toString(storageContainer.getExposedPort()));
String targetUrl = String.join(":", storageContainer.getHost(), Integer.toString(storageContainer.getMappedPort()));
diff --git a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/cases/migration/AbstractMigrationE2EIT.java b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/cases/migration/AbstractMigrationE2EIT.java
index 28ebd01d338..537883f5d52 100644
--- a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/cases/migration/AbstractMigrationE2EIT.java
+++ b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/cases/migration/AbstractMigrationE2EIT.java
@@ -22,10 +22,10 @@ import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.database.connector.opengauss.type.OpenGaussDatabaseType;
import org.apache.shardingsphere.database.connector.postgresql.type.PostgreSQLDatabaseType;
+import org.apache.shardingsphere.test.e2e.env.runtime.E2ETestEnvironment;
import org.apache.shardingsphere.test.e2e.env.runtime.type.RunEnvironment.Type;
import org.apache.shardingsphere.test.e2e.operation.pipeline.cases.PipelineContainerComposer;
import org.apache.shardingsphere.test.e2e.operation.pipeline.command.MigrationDistSQLCommand;
-import org.apache.shardingsphere.test.e2e.operation.pipeline.env.PipelineE2EEnvironment;
import org.awaitility.Awaitility;
import org.opengauss.util.PSQLException;
@@ -56,7 +56,7 @@ public abstract class AbstractMigrationE2EIT {
}
protected void addMigrationSourceResource(final PipelineContainerComposer containerComposer) throws SQLException {
- if (Type.NATIVE == PipelineE2EEnvironment.getInstance().getType()) {
+ if (Type.NATIVE == E2ETestEnvironment.getInstance().getRunEnvironment().getType()) {
try {
containerComposer.proxyExecuteWithLog("UNREGISTER MIGRATION SOURCE STORAGE UNIT ds_0", 2);
} catch (final SQLException ex) {
diff --git a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/cases/migration/general/PostgreSQLToMySQLMigrationE2EIT.java b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/cases/migration/general/PostgreSQLToMySQLMigrationE2EIT.java
index ff08714af90..cb27f7301f3 100644
--- a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/cases/migration/general/PostgreSQLToMySQLMigrationE2EIT.java
+++ b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/cases/migration/general/PostgreSQLToMySQLMigrationE2EIT.java
@@ -25,10 +25,10 @@ import org.apache.shardingsphere.data.pipeline.core.job.JobStatus;
import org.apache.shardingsphere.data.pipeline.scenario.migration.MigrationJobType;
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.E2ETestEnvironment;
import org.apache.shardingsphere.test.e2e.env.runtime.type.RunEnvironment.Type;
import org.apache.shardingsphere.test.e2e.operation.pipeline.cases.PipelineContainerComposer;
import org.apache.shardingsphere.test.e2e.operation.pipeline.cases.migration.AbstractMigrationE2EIT;
-import org.apache.shardingsphere.test.e2e.operation.pipeline.env.PipelineE2EEnvironment;
import org.apache.shardingsphere.test.e2e.operation.pipeline.framework.param.PipelineE2ECondition;
import org.apache.shardingsphere.test.e2e.operation.pipeline.framework.param.PipelineE2ESettings;
import org.apache.shardingsphere.test.e2e.operation.pipeline.framework.param.PipelineE2ESettings.PipelineE2EDatabaseSettings;
@@ -63,13 +63,14 @@ class PostgreSQLToMySQLMigrationE2EIT extends AbstractMigrationE2EIT {
@ArgumentsSource(PipelineE2ETestCaseArgumentsProvider.class)
void assertMigrationSuccess(final PipelineTestParameter testParam) throws SQLException {
PostgreSQLContainer<?> postgresqlContainer = null;
+ Type type = E2ETestEnvironment.getInstance().getRunEnvironment().getType();
try (PipelineContainerComposer containerComposer = new PipelineContainerComposer(testParam, new MigrationJobType())) {
- if (Type.DOCKER == PipelineE2EEnvironment.getInstance().getType()) {
+ if (Type.DOCKER == type) {
postgresqlContainer = new PostgreSQLContainer<>("postgres:13");
postgresqlContainer.withNetwork(containerComposer.getContainerComposer().getContainers().getNetwork()).withNetworkAliases("postgresql.host")
.withDatabaseName("postgres").withUsername("postgres").withPassword("postgres").withCommand("-c wal_level=logical").start();
}
- String jdbcUrl = Type.DOCKER == PipelineE2EEnvironment.getInstance().getType() ? postgresqlContainer.getJdbcUrl() : "jdbc:postgresql://localhost:5432/postgres";
+ String jdbcUrl = Type.DOCKER == type ? postgresqlContainer.getJdbcUrl() : "jdbc:postgresql://localhost:5432/postgres";
initSourceTable(jdbcUrl);
registerMigrationSourceStorageUnit(containerComposer);
containerComposer.registerStorageUnit(PipelineContainerComposer.DS_0);
@@ -97,7 +98,7 @@ class PostgreSQLToMySQLMigrationE2EIT extends AbstractMigrationE2EIT {
}
private void initSourceTable(final String jdbcUrl) throws SQLException {
- Type type = PipelineE2EEnvironment.getInstance().getType();
+ Type type = E2ETestEnvironment.getInstance().getRunEnvironment().getType();
try (Connection connection = DriverManager.getConnection(jdbcUrl, "postgres", "postgres")) {
if (Type.NATIVE == type) {
connection.createStatement().execute("DROP TABLE IF EXISTS t_order;");
@@ -124,14 +125,15 @@ class PostgreSQLToMySQLMigrationE2EIT extends AbstractMigrationE2EIT {
}
private void registerMigrationSourceStorageUnit(final PipelineContainerComposer containerComposer) throws SQLException {
- if (Type.NATIVE == PipelineE2EEnvironment.getInstance().getType()) {
+ Type type = E2ETestEnvironment.getInstance().getRunEnvironment().getType();
+ if (Type.NATIVE == type) {
try {
containerComposer.proxyExecuteWithLog("UNREGISTER MIGRATION SOURCE STORAGE UNIT source_ds", 2);
} catch (final SQLException ex) {
log.warn("Unregister migration source storage unit `source_ds` failed, maybe it does not exist. Error msg: {}", ex.getMessage());
}
}
- String jdbcUrl = String.format("jdbc:postgresql://%s:5432/postgres", Type.DOCKER == PipelineE2EEnvironment.getInstance().getType() ? "postgresql.host" : "localhost");
+ String jdbcUrl = String.format("jdbc:postgresql://%s:5432/postgres", Type.DOCKER == type ? "postgresql.host" : "localhost");
String sql = String.format("REGISTER MIGRATION SOURCE STORAGE UNIT source_ds (URL='%s', USER='postgres', PASSWORD='postgres')", jdbcUrl);
containerComposer.proxyExecuteWithLog(sql, 2);
}
diff --git a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/env/PipelineE2EEnvironment.java b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/env/PipelineE2EEnvironment.java
index a7ff96ee570..44ee8bd3ed9 100644
--- a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/env/PipelineE2EEnvironment.java
+++ b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/env/PipelineE2EEnvironment.java
@@ -22,9 +22,9 @@ import lombok.Getter;
import org.apache.shardingsphere.database.connector.core.spi.DatabaseTypedSPILoader;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import org.apache.shardingsphere.test.e2e.env.container.storage.option.StorageContainerOption;
+import org.apache.shardingsphere.test.e2e.env.runtime.E2ETestEnvironment;
import org.apache.shardingsphere.test.e2e.env.runtime.EnvironmentPropertiesLoader;
import org.apache.shardingsphere.test.e2e.env.runtime.type.RunEnvironment;
-import org.apache.shardingsphere.test.e2e.env.runtime.type.RunEnvironment.Type;
import org.apache.shardingsphere.test.e2e.operation.pipeline.env.enums.PipelineProxyTypeEnum;
import java.util.Arrays;
@@ -40,21 +40,13 @@ public final class PipelineE2EEnvironment {
private final Properties props;
- private final Type type;
-
private final PipelineProxyTypeEnum itProxyType;
private PipelineE2EEnvironment() {
props = EnvironmentPropertiesLoader.loadProperties();
- type = getType(props);
itProxyType = PipelineProxyTypeEnum.valueOf(props.getProperty("pipeline.e2e.proxy.type", PipelineProxyTypeEnum.NONE.name()).toUpperCase());
}
- private Type getType(final Properties props) {
- String value = props.getProperty("e2e.run.type");
- return Strings.isNullOrEmpty(value) ? null : Type.valueOf(value.toUpperCase());
- }
-
/**
* Get actual database port.
*
@@ -92,7 +84,7 @@ public final class PipelineE2EEnvironment {
*/
public List<String> listStorageContainerImages(final DatabaseType databaseType) {
// Native mode needn't use docker image, just return a list which contain one item
- if (RunEnvironment.Type.NATIVE == type) {
+ if (RunEnvironment.Type.NATIVE == E2ETestEnvironment.getInstance().getRunEnvironment().getType()) {
return databaseType.getType().equalsIgnoreCase(getNativeDatabaseType()) ? Collections.singletonList("") : Collections.emptyList();
}
return Arrays.stream(props.getOrDefault(String.format("e2e.artifact.database.%s.image", databaseType.getType().toLowerCase()), "").toString()
diff --git a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/framework/param/PipelineE2ECondition.java b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/framework/param/PipelineE2ECondition.java
index 1ed9eecd237..d565b687115 100644
--- a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/framework/param/PipelineE2ECondition.java
+++ b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/operation/pipeline/framework/param/PipelineE2ECondition.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.test.e2e.operation.pipeline.framework.param;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
+import org.apache.shardingsphere.test.e2e.env.runtime.E2ETestEnvironment;
import org.apache.shardingsphere.test.e2e.operation.pipeline.env.PipelineE2EEnvironment;
import java.util.Arrays;
@@ -37,7 +38,7 @@ public final class PipelineE2ECondition {
* @return enabled or not
*/
public static boolean isEnabled(final DatabaseType... databaseTypes) {
- if (null == PipelineE2EEnvironment.getInstance().getType()) {
+ if (null == E2ETestEnvironment.getInstance().getRunEnvironment().getType()) {
return false;
}
return 0 == databaseTypes.length || Arrays.stream(databaseTypes).anyMatch(each -> !PipelineE2EEnvironment.getInstance().listStorageContainerImages(each).isEmpty());