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 2cacd29c646 Refactor StorageContainerConfigurationFactory on shardingsphere-test-e2e-transaction (#36463) 2cacd29c646 is described below commit 2cacd29c646a4caf82670856b15c270f9f0c8f50 Author: Liang Zhang <zhangli...@apache.org> AuthorDate: Wed Sep 3 15:55:41 2025 +0800 Refactor StorageContainerConfigurationFactory on shardingsphere-test-e2e-transaction (#36463) * Refactor StorageContainerConfigurationFactory on shardingsphere-test-e2e-transaction * Refactor StorageContainerConfigurationFactory on shardingsphere-test-e2e-transaction --- .../container/compose/DockerContainerComposer.java | 2 +- .../{ => storage}/StorageContainerConfigurationFactory.java | 8 ++++---- .../dialect}/MySQLContainerConfigurationFactory.java | 13 ++++++------- .../dialect}/OpenGaussContainerConfigurationFactory.java | 13 ++++++------- .../dialect}/PostgreSQLContainerConfigurationFactory.java | 13 ++++++------- 5 files changed, 23 insertions(+), 26 deletions(-) diff --git a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/framework/container/compose/DockerContainerComposer.java b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/framework/container/compose/DockerContainerComposer.java index fdf35647d3e..4c3c27d4675 100644 --- a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/framework/container/compose/DockerContainerComposer.java +++ b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/framework/container/compose/DockerContainerComposer.java @@ -37,7 +37,7 @@ import org.apache.shardingsphere.test.e2e.env.container.atomic.storage.StorageCo import org.apache.shardingsphere.test.e2e.env.container.atomic.storage.impl.NativeStorageContainer; 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.StorageContainerConfigurationFactory; +import org.apache.shardingsphere.test.e2e.operation.transaction.framework.container.config.storage.StorageContainerConfigurationFactory; import org.apache.shardingsphere.test.e2e.operation.transaction.framework.container.config.proxy.TransactionProxyContainerConfigurationFactory; import org.apache.shardingsphere.test.e2e.operation.transaction.framework.param.TransactionTestParameter; diff --git a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/framework/container/config/StorageContainerConfigurationFactory.java b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/framework/container/config/storage/StorageContainerConfigurationFactory.java similarity index 90% rename from test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/framework/container/config/StorageContainerConfigurationFactory.java rename to test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/framework/container/config/storage/StorageContainerConfigurationFactory.java index af519c18071..d7dc252efc5 100644 --- a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/framework/container/config/StorageContainerConfigurationFactory.java +++ b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/framework/container/config/storage/StorageContainerConfigurationFactory.java @@ -15,16 +15,16 @@ * limitations under the License. */ -package org.apache.shardingsphere.test.e2e.operation.transaction.framework.container.config; +package org.apache.shardingsphere.test.e2e.operation.transaction.framework.container.config.storage; import lombok.AccessLevel; import lombok.NoArgsConstructor; import org.apache.shardingsphere.database.connector.core.type.DatabaseType; import org.apache.shardingsphere.test.e2e.env.container.atomic.storage.config.StorageContainerConfiguration; import org.apache.shardingsphere.test.e2e.env.container.atomic.storage.config.dialect.H2ContainerConfigurationFactory; -import org.apache.shardingsphere.test.e2e.operation.transaction.framework.container.config.mysql.MySQLContainerConfigurationFactory; -import org.apache.shardingsphere.test.e2e.operation.transaction.framework.container.config.opengauss.OpenGaussContainerConfigurationFactory; -import org.apache.shardingsphere.test.e2e.operation.transaction.framework.container.config.postgresql.PostgreSQLContainerConfigurationFactory; +import org.apache.shardingsphere.test.e2e.operation.transaction.framework.container.config.storage.dialect.MySQLContainerConfigurationFactory; +import org.apache.shardingsphere.test.e2e.operation.transaction.framework.container.config.storage.dialect.OpenGaussContainerConfigurationFactory; +import org.apache.shardingsphere.test.e2e.operation.transaction.framework.container.config.storage.dialect.PostgreSQLContainerConfigurationFactory; /** * Storage container configuration factory. diff --git a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/framework/container/config/mysql/MySQLContainerConfigurationFactory.java b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/framework/container/config/storage/dialect/MySQLContainerConfigurationFactory.java similarity index 83% rename from test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/framework/container/config/mysql/MySQLContainerConfigurationFactory.java rename to test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/framework/container/config/storage/dialect/MySQLContainerConfigurationFactory.java index 0e970ed2810..e54a7d8b732 100644 --- a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/framework/container/config/mysql/MySQLContainerConfigurationFactory.java +++ b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/framework/container/config/storage/dialect/MySQLContainerConfigurationFactory.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shardingsphere.test.e2e.operation.transaction.framework.container.config.mysql; +package org.apache.shardingsphere.test.e2e.operation.transaction.framework.container.config.storage.dialect; import lombok.AccessLevel; import lombok.NoArgsConstructor; @@ -36,6 +36,8 @@ import java.util.Map; @NoArgsConstructor(access = AccessLevel.PRIVATE) public final class MySQLContainerConfigurationFactory { + private static final DatabaseType DATABASE_TYPE = TypedSPILoader.getService(DatabaseType.class, "MySQL"); + /** * Create new instance of MySQL container configuration. * @@ -44,8 +46,7 @@ public final class MySQLContainerConfigurationFactory { */ public static StorageContainerConfiguration newInstance(final String scenario) { return new StorageContainerConfiguration(getCommand(), getContainerEnvironments(), getMountedResources(scenario), - DatabaseEnvironmentManager.getDatabaseTypes(scenario, TypedSPILoader.getService(DatabaseType.class, "MySQL")), - DatabaseEnvironmentManager.getExpectedDatabaseTypes(scenario, TypedSPILoader.getService(DatabaseType.class, "MySQL"))); + DatabaseEnvironmentManager.getDatabaseTypes(scenario, DATABASE_TYPE), DatabaseEnvironmentManager.getExpectedDatabaseTypes(scenario, DATABASE_TYPE)); } private static String getCommand() { @@ -62,10 +63,8 @@ public final class MySQLContainerConfigurationFactory { private static Map<String, String> getMountedResources(final String scenario) { Map<String, String> result = new HashMap<>(3, 1F); - result.put(new ScenarioDataPath(scenario).getInitSQLResourcePath(Type.ACTUAL, TypedSPILoader.getService(DatabaseType.class, "MySQL")) + "/01-actual-init.sql", - "/docker-entrypoint-initdb.d/01-actual-init.sql"); - result.put(new ScenarioDataPath(scenario).getInitSQLResourcePath(Type.EXPECTED, TypedSPILoader.getService(DatabaseType.class, "MySQL")) + "/01-expected-init.sql", - "/docker-entrypoint-initdb.d/01-expected-init.sql"); + result.put(new ScenarioDataPath(scenario).getInitSQLResourcePath(Type.ACTUAL, DATABASE_TYPE) + "/01-actual-init.sql", "/docker-entrypoint-initdb.d/01-actual-init.sql"); + result.put(new ScenarioDataPath(scenario).getInitSQLResourcePath(Type.EXPECTED, DATABASE_TYPE) + "/01-expected-init.sql", "/docker-entrypoint-initdb.d/01-expected-init.sql"); result.put("/env/mysql/my.cnf", MySQLContainer.MYSQL_CONF_IN_CONTAINER); return result; } diff --git a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/framework/container/config/opengauss/OpenGaussContainerConfigurationFactory.java b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/framework/container/config/storage/dialect/OpenGaussContainerConfigurationFactory.java similarity index 83% rename from test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/framework/container/config/opengauss/OpenGaussContainerConfigurationFactory.java rename to test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/framework/container/config/storage/dialect/OpenGaussContainerConfigurationFactory.java index 4c7f7172b8b..c6d4505f1b3 100644 --- a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/framework/container/config/opengauss/OpenGaussContainerConfigurationFactory.java +++ b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/framework/container/config/storage/dialect/OpenGaussContainerConfigurationFactory.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shardingsphere.test.e2e.operation.transaction.framework.container.config.opengauss; +package org.apache.shardingsphere.test.e2e.operation.transaction.framework.container.config.storage.dialect; import lombok.AccessLevel; import lombok.NoArgsConstructor; @@ -38,6 +38,8 @@ import java.util.Map; @NoArgsConstructor(access = AccessLevel.PRIVATE) public final class OpenGaussContainerConfigurationFactory { + private static final DatabaseType DATABASE_TYPE = TypedSPILoader.getService(DatabaseType.class, "openGauss"); + /** * Create new instance of openGauss container configuration. * @@ -46,8 +48,7 @@ public final class OpenGaussContainerConfigurationFactory { */ public static StorageContainerConfiguration newInstance(final String scenario) { return new StorageContainerConfiguration(getCommand(), getContainerEnvironments(), getMountedResources(scenario), - DatabaseEnvironmentManager.getDatabaseTypes(scenario, TypedSPILoader.getService(DatabaseType.class, "openGauss")), - DatabaseEnvironmentManager.getExpectedDatabaseTypes(scenario, TypedSPILoader.getService(DatabaseType.class, "openGauss"))); + DatabaseEnvironmentManager.getDatabaseTypes(scenario, DATABASE_TYPE), DatabaseEnvironmentManager.getExpectedDatabaseTypes(scenario, DATABASE_TYPE)); } private static String getCommand() { @@ -60,10 +61,8 @@ public final class OpenGaussContainerConfigurationFactory { private static Map<String, String> getMountedResources(final String scenario) { Map<String, String> result = new HashMap<>(3, 1F); - result.put(new ScenarioDataPath(scenario).getInitSQLResourcePath(Type.ACTUAL, TypedSPILoader.getService(DatabaseType.class, "openGauss")) + "/01-actual-init.sql", - "/docker-entrypoint-initdb.d/01-actual-init.sql"); - result.put(new ScenarioDataPath(scenario).getInitSQLResourcePath(Type.EXPECTED, TypedSPILoader.getService(DatabaseType.class, "openGauss")) + "/01-expected-init.sql", - "/docker-entrypoint-initdb.d/01-expected-init.sql"); + result.put(new ScenarioDataPath(scenario).getInitSQLResourcePath(Type.ACTUAL, DATABASE_TYPE) + "/01-actual-init.sql", "/docker-entrypoint-initdb.d/01-actual-init.sql"); + result.put(new ScenarioDataPath(scenario).getInitSQLResourcePath(Type.EXPECTED, DATABASE_TYPE) + "/01-expected-init.sql", "/docker-entrypoint-initdb.d/01-expected-init.sql"); result.put("/env/postgresql/postgresql.conf", OpenGaussContainer.OPENGAUSS_CONF_IN_CONTAINER); return result; } diff --git a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/framework/container/config/postgresql/PostgreSQLContainerConfigurationFactory.java b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/framework/container/config/storage/dialect/PostgreSQLContainerConfigurationFactory.java similarity index 83% rename from test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/framework/container/config/postgresql/PostgreSQLContainerConfigurationFactory.java rename to test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/framework/container/config/storage/dialect/PostgreSQLContainerConfigurationFactory.java index 9b27c7350d2..f4631aa5520 100644 --- a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/framework/container/config/postgresql/PostgreSQLContainerConfigurationFactory.java +++ b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/framework/container/config/storage/dialect/PostgreSQLContainerConfigurationFactory.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shardingsphere.test.e2e.operation.transaction.framework.container.config.postgresql; +package org.apache.shardingsphere.test.e2e.operation.transaction.framework.container.config.storage.dialect; import lombok.AccessLevel; import lombok.NoArgsConstructor; @@ -37,6 +37,8 @@ import java.util.Map; @NoArgsConstructor(access = AccessLevel.PRIVATE) public final class PostgreSQLContainerConfigurationFactory { + private static final DatabaseType DATABASE_TYPE = TypedSPILoader.getService(DatabaseType.class, "PostgreSQL"); + /** * Create new instance of PostgreSQL container configuration. * @@ -45,8 +47,7 @@ public final class PostgreSQLContainerConfigurationFactory { */ public static StorageContainerConfiguration newInstance(final String scenario) { return new StorageContainerConfiguration(getCommand(), getContainerEnvironments(), getMountedResources(scenario), - DatabaseEnvironmentManager.getDatabaseTypes(scenario, TypedSPILoader.getService(DatabaseType.class, "PostgreSQL")), - DatabaseEnvironmentManager.getExpectedDatabaseTypes(scenario, TypedSPILoader.getService(DatabaseType.class, "PostgreSQL"))); + DatabaseEnvironmentManager.getDatabaseTypes(scenario, DATABASE_TYPE), DatabaseEnvironmentManager.getExpectedDatabaseTypes(scenario, DATABASE_TYPE)); } private static String getCommand() { @@ -62,10 +63,8 @@ public final class PostgreSQLContainerConfigurationFactory { private static Map<String, String> getMountedResources(final String scenario) { Map<String, String> result = new HashMap<>(3, 1F); - result.put(new ScenarioDataPath(scenario).getInitSQLResourcePath(Type.ACTUAL, TypedSPILoader.getService(DatabaseType.class, "PostgreSQL")) + "/01-actual-init.sql", - "/docker-entrypoint-initdb.d/01-actual-init.sql"); - result.put(new ScenarioDataPath(scenario).getInitSQLResourcePath(Type.EXPECTED, TypedSPILoader.getService(DatabaseType.class, "PostgreSQL")) + "/01-expected-init.sql", - "/docker-entrypoint-initdb.d/01-expected-init.sql"); + result.put(new ScenarioDataPath(scenario).getInitSQLResourcePath(Type.ACTUAL, DATABASE_TYPE) + "/01-actual-init.sql", "/docker-entrypoint-initdb.d/01-actual-init.sql"); + result.put(new ScenarioDataPath(scenario).getInitSQLResourcePath(Type.EXPECTED, DATABASE_TYPE) + "/01-expected-init.sql", "/docker-entrypoint-initdb.d/01-expected-init.sql"); result.put("/env/postgresql/postgresql.conf", OpenGaussContainer.OPENGAUSS_CONF_IN_CONTAINER); return result; }