diff --git a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/ITContainers.java b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/ITContainers.java index 3a1a8796581a9..f855704173090 100644 --- a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/ITContainers.java +++ b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/ITContainers.java @@ -63,6 +63,18 @@ public ITContainers(final String scenario) { * @return registered container */ public T registerContainer(final T container) { + return registerContainer(container, getNetworkAlias(container)); + } + + /** + * Register container. + * + * @param container container to be registered + * @param networkAlias network alias + * @param type of container + * @return registered container + */ + public T registerContainer(final T container, final String networkAlias) { if (container instanceof ComboITContainer) { ((ComboITContainer) container).getContainers().forEach(this::registerContainer); } else if (container instanceof EmbeddedITContainer) { @@ -70,7 +82,6 @@ public T registerContainer(final T container) { } else { DockerITContainer dockerContainer = (DockerITContainer) container; dockerContainer.setNetwork(network); - String networkAlias = getNetworkAlias(container); dockerContainer.setNetworkAliases(Collections.singletonList(networkAlias)); String loggerName = String.join(":", scenario, dockerContainer.getName()); dockerContainer.withLogConsumer(new Slf4jLogConsumer(LoggerFactory.getLogger(loggerName), false)); diff --git a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/DockerStorageContainer.java b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/DockerStorageContainer.java index 8feed7f48b2ab..39016794855c9 100644 --- a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/DockerStorageContainer.java +++ b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/DockerStorageContainer.java @@ -48,13 +48,14 @@ public abstract class DockerStorageContainer extends DockerITContainer implement private final DatabaseType databaseType; - private final Map actualDataSourceMap = new LinkedHashMap<>(); + private final Collection databases; - private final Map expectedDataSourceMap = new LinkedHashMap<>(); + private final Map dataSourceMap = new LinkedHashMap<>(); - protected DockerStorageContainer(final DatabaseType databaseType, final String containerImage) { + protected DockerStorageContainer(final DatabaseType databaseType, final String containerImage, final Collection databases) { super(databaseType.getType().toLowerCase(), containerImage); this.databaseType = databaseType; + this.databases = databases; } @Override @@ -85,14 +86,9 @@ protected final void mapResources(final Map resources) { @Override protected void postStart() { - actualDataSourceMap.putAll(createAccessDataSource(getDatabaseNames())); - expectedDataSourceMap.putAll(createAccessDataSource(getExpectedDatabaseNames())); + dataSourceMap.putAll(createAccessDataSource(databases)); } - protected abstract Collection getDatabaseNames(); - - protected abstract Collection getExpectedDatabaseNames(); - /** * Create access data source. * diff --git a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/EmbeddedStorageContainer.java b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/EmbeddedStorageContainer.java index cea74cddf95d6..faf862642014e 100644 --- a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/EmbeddedStorageContainer.java +++ b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/EmbeddedStorageContainer.java @@ -22,14 +22,11 @@ import org.apache.shardingsphere.test.e2e.env.container.atomic.EmbeddedITContainer; import org.apache.shardingsphere.test.e2e.env.container.atomic.util.StorageContainerUtils; import org.apache.shardingsphere.test.e2e.env.runtime.DataSourceEnvironment; -import org.apache.shardingsphere.test.e2e.env.runtime.scenario.database.DatabaseEnvironmentManager; import javax.sql.DataSource; import java.util.Collection; import java.util.LinkedHashMap; import java.util.Map; -import java.util.Map.Entry; -import java.util.stream.Collectors; /** * Embedded storage container. @@ -41,31 +38,20 @@ public abstract class EmbeddedStorageContainer implements EmbeddedITContainer, S private final String scenario; - private final Map actualDataSourceMap; + private final Collection databases; - private final Map expectedDataSourceMap; + private final Map dataSourceMap; - protected EmbeddedStorageContainer(final DatabaseType databaseType, final String scenario) { + protected EmbeddedStorageContainer(final DatabaseType databaseType, final String scenario, final Collection databases) { this.databaseType = databaseType; this.scenario = scenario; - actualDataSourceMap = createActualDataSourceMap(); - expectedDataSourceMap = createExpectedDataSourceMap(); + this.databases = databases; + dataSourceMap = createDataSourceMap(); } - private Map createActualDataSourceMap() { - Collection databaseNames = DatabaseEnvironmentManager.getDatabaseTypes(scenario, databaseType).entrySet().stream() - .filter(entry -> entry.getValue().getClass().isAssignableFrom(databaseType.getClass())).map(Entry::getKey).collect(Collectors.toList()); - Map result = new LinkedHashMap<>(databaseNames.size(), 1F); - databaseNames.forEach(each -> result.put(each, StorageContainerUtils.generateDataSource(DataSourceEnvironment.getURL(databaseType, null, 0, scenario + each), - "root", "Root@123"))); - return result; - } - - private Map createExpectedDataSourceMap() { - Collection databaseNames = DatabaseEnvironmentManager.getExpectedDatabaseTypes(scenario, databaseType).entrySet().stream() - .filter(entry -> entry.getValue().getClass().isAssignableFrom(databaseType.getClass())).map(Entry::getKey).collect(Collectors.toList()); - Map result = new LinkedHashMap<>(databaseNames.size(), 1F); - databaseNames.forEach(each -> result.put(each, StorageContainerUtils.generateDataSource(DataSourceEnvironment.getURL(databaseType, null, 0, scenario + each), + private Map createDataSourceMap() { + Map result = new LinkedHashMap<>(databases.size(), 1F); + databases.forEach(each -> result.put(each, StorageContainerUtils.generateDataSource(DataSourceEnvironment.getURL(databaseType, null, 0, scenario + each), "root", "Root@123"))); return result; } diff --git a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/StorageContainer.java b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/StorageContainer.java index e24d1af57e1c8..02562b7dcfb0e 100644 --- a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/StorageContainer.java +++ b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/StorageContainer.java @@ -32,12 +32,5 @@ public interface StorageContainer extends ITContainer { * * @return actual data source map */ - Map getActualDataSourceMap(); - - /** - * Get expected data source map. - * - * @return expected data source map - */ - Map getExpectedDataSourceMap(); + Map getDataSourceMap(); } diff --git a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/StorageContainerFactory.java b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/StorageContainerFactory.java index bd4f7f30f939e..acf2b5687277a 100644 --- a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/StorageContainerFactory.java +++ b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/StorageContainerFactory.java @@ -27,6 +27,9 @@ import org.apache.shardingsphere.test.e2e.env.container.atomic.storage.impl.OpenGaussContainer; import org.apache.shardingsphere.test.e2e.env.container.atomic.storage.impl.PostgreSQLContainer; +import java.util.Collection; +import java.util.Collections; + /** * Storage container factory. */ @@ -42,19 +45,33 @@ public final class StorageContainerFactory { * @return created instance * @throws RuntimeException runtime exception */ + public static StorageContainer newInstance(final DatabaseType databaseType, final String storageContainerImage, final StorageContainerConfiguration storageContainerConfig) { + return newInstance(databaseType, storageContainerImage, storageContainerConfig, Collections.emptyList()); + } + + /** + * Create new instance of storage container. + * + * @param databaseType database type + * @param storageContainerImage storage container image + * @param storageContainerConfig storage container configuration + * @param databases databases + * @return created instance + * @throws RuntimeException runtime exception + */ public static StorageContainer newInstance(final DatabaseType databaseType, final String storageContainerImage, - final StorageContainerConfiguration storageContainerConfig) { + final StorageContainerConfiguration storageContainerConfig, final Collection databases) { switch (databaseType.getType()) { case "MySQL": - return new MySQLContainer(storageContainerImage, storageContainerConfig); + return new MySQLContainer(storageContainerImage, storageContainerConfig, databases); case "PostgreSQL": - return new PostgreSQLContainer(storageContainerImage, storageContainerConfig); + return new PostgreSQLContainer(storageContainerImage, storageContainerConfig, databases); case "openGauss": - return new OpenGaussContainer(storageContainerImage, storageContainerConfig); + return new OpenGaussContainer(storageContainerImage, storageContainerConfig, databases); case "H2": - return new H2Container(storageContainerConfig); + return new H2Container(storageContainerConfig, databases); case "MariaDB": - return new MariaDBContainer(storageContainerImage, storageContainerConfig); + return new MariaDBContainer(storageContainerImage, storageContainerConfig, databases); default: throw new RuntimeException(String.format("Database `%s` is unknown.", databaseType.getType())); } diff --git a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/config/StorageContainerConfiguration.java b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/config/StorageContainerConfiguration.java index 436476ef9ace1..ee6ed1eb40bea 100644 --- a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/config/StorageContainerConfiguration.java +++ b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/config/StorageContainerConfiguration.java @@ -19,7 +19,6 @@ import lombok.Getter; import lombok.RequiredArgsConstructor; -import org.apache.shardingsphere.infra.database.core.type.DatabaseType; import java.util.Map; @@ -38,14 +37,7 @@ public class StorageContainerConfiguration { private final Map mountedResources; - private final Map databaseTypes; - - private final Map expectedDatabaseTypes; - - public StorageContainerConfiguration(final String containerCommand, final Map containerEnvironments, final Map mountedResources, - final Map databaseTypes, final Map expectedDatabaseTypes) { - this.databaseTypes = databaseTypes; - this.expectedDatabaseTypes = expectedDatabaseTypes; + public StorageContainerConfiguration(final String containerCommand, final Map containerEnvironments, final Map mountedResources) { scenario = null; this.containerCommand = containerCommand; this.containerEnvironments = containerEnvironments; diff --git a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/config/impl/StorageContainerConfigurationFactory.java b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/config/impl/StorageContainerConfigurationFactory.java index b519277e98676..ee264db807b9f 100644 --- a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/config/impl/StorageContainerConfigurationFactory.java +++ b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/config/impl/StorageContainerConfigurationFactory.java @@ -26,6 +26,7 @@ import org.apache.shardingsphere.test.e2e.env.container.atomic.storage.config.impl.mysql.MySQLContainerConfigurationFactory; import org.apache.shardingsphere.test.e2e.env.container.atomic.storage.config.impl.opengauss.OpenGaussContainerConfigurationFactory; import org.apache.shardingsphere.test.e2e.env.container.atomic.storage.config.impl.postgresql.PostgreSQLContainerConfigurationFactory; +import org.apache.shardingsphere.test.e2e.env.runtime.scenario.path.ScenarioDataPath.Type; /** * Storage container configuration factory. @@ -38,19 +39,20 @@ public final class StorageContainerConfigurationFactory { * * @param databaseType database type * @param scenario scenario + * @param type type * @return created instance * @throws RuntimeException runtime exception */ - public static StorageContainerConfiguration newInstance(final DatabaseType databaseType, final String scenario) { + public static StorageContainerConfiguration newInstance(final DatabaseType databaseType, final String scenario, final Type type) { switch (databaseType.getType()) { case "MySQL": - return MySQLContainerConfigurationFactory.newInstance(scenario); + return MySQLContainerConfigurationFactory.newInstance(scenario, type); case "PostgreSQL": - return PostgreSQLContainerConfigurationFactory.newInstance(scenario); + return PostgreSQLContainerConfigurationFactory.newInstance(scenario, type); case "openGauss": - return OpenGaussContainerConfigurationFactory.newInstance(scenario); + return OpenGaussContainerConfigurationFactory.newInstance(scenario, type); case "H2": - return H2ContainerConfigurationFactory.newInstance(scenario); + return H2ContainerConfigurationFactory.newInstance(scenario, type); default: throw new RuntimeException(String.format("Database `%s` is unknown.", databaseType.getType())); } diff --git a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/config/impl/h2/H2ContainerConfigurationFactory.java b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/config/impl/h2/H2ContainerConfigurationFactory.java index 275129dfa10f0..40ffe5156fab5 100644 --- a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/config/impl/h2/H2ContainerConfigurationFactory.java +++ b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/config/impl/h2/H2ContainerConfigurationFactory.java @@ -22,7 +22,6 @@ import org.apache.shardingsphere.infra.database.core.type.DatabaseType; import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader; import org.apache.shardingsphere.test.e2e.env.container.atomic.storage.config.StorageContainerConfiguration; -import org.apache.shardingsphere.test.e2e.env.runtime.scenario.database.DatabaseEnvironmentManager; import org.apache.shardingsphere.test.e2e.env.runtime.scenario.path.ScenarioDataPath; import org.apache.shardingsphere.test.e2e.env.runtime.scenario.path.ScenarioDataPath.Type; @@ -44,23 +43,25 @@ public final class H2ContainerConfigurationFactory { public static StorageContainerConfiguration newInstance() { Map mountedResources = new HashMap<>(1, 1F); mountedResources.put("/env/mysql/01-initdb.sql", "/docker-entrypoint-initdb.d/01-initdb.sql"); - return new StorageContainerConfiguration("", Collections.emptyMap(), mountedResources, Collections.emptyMap(), Collections.emptyMap()); + return new StorageContainerConfiguration("", Collections.emptyMap(), mountedResources); } /** * Create new instance of h2 container configuration. * * @param scenario scenario + * @param type type * @return created instance */ - public static StorageContainerConfiguration newInstance(final String scenario) { - Map mountedResources = new HashMap<>(2, 1F); - mountedResources.put(new ScenarioDataPath(scenario).getInitSQLResourcePath(Type.ACTUAL, TypedSPILoader.getService(DatabaseType.class, "H2")) + "/01-actual-init.sql", - "/docker-entrypoint-initdb.d/01-actual-init.sql"); - mountedResources.put(new ScenarioDataPath(scenario).getInitSQLResourcePath(Type.EXPECTED, TypedSPILoader.getService(DatabaseType.class, "H2")) + "/01-expected-init.sql", - "/docker-entrypoint-initdb.d/01-expected-init.sql"); - return new StorageContainerConfiguration(scenario, "", Collections.emptyMap(), mountedResources, - DatabaseEnvironmentManager.getDatabaseTypes(scenario, TypedSPILoader.getService(DatabaseType.class, "H2")), - DatabaseEnvironmentManager.getExpectedDatabaseTypes(scenario, TypedSPILoader.getService(DatabaseType.class, "H2"))); + public static StorageContainerConfiguration newInstance(final String scenario, final Type type) { + Map mountedResources = new HashMap<>(1, 1F); + if (Type.ACTUAL == type) { + mountedResources.put(new ScenarioDataPath(scenario).getInitSQLResourcePath(Type.ACTUAL, TypedSPILoader.getService(DatabaseType.class, "H2")) + "/01-actual-init.sql", + "/docker-entrypoint-initdb.d/01-actual-init.sql"); + } else { + mountedResources.put(new ScenarioDataPath(scenario).getInitSQLResourcePath(Type.EXPECTED, TypedSPILoader.getService(DatabaseType.class, "H2")) + "/01-expected-init.sql", + "/docker-entrypoint-initdb.d/01-expected-init.sql"); + } + return new StorageContainerConfiguration(scenario, "", Collections.emptyMap(), mountedResources); } } diff --git a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/config/impl/mariadb/MariaDBContainerConfigurationFactory.java b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/config/impl/mariadb/MariaDBContainerConfigurationFactory.java index acffb8d42e7f6..e2b34bf7be137 100644 --- a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/config/impl/mariadb/MariaDBContainerConfigurationFactory.java +++ b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/config/impl/mariadb/MariaDBContainerConfigurationFactory.java @@ -23,7 +23,6 @@ import org.apache.shardingsphere.test.e2e.env.container.atomic.storage.impl.MariaDBContainer; import org.apache.shardingsphere.test.e2e.env.container.atomic.util.ContainerUtils; -import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -39,7 +38,7 @@ public final class MariaDBContainerConfigurationFactory { * @return created instance */ public static StorageContainerConfiguration newInstance() { - return new StorageContainerConfiguration(getCommand(), getContainerEnvironments(), getMountedResources(), Collections.emptyMap(), Collections.emptyMap()); + return new StorageContainerConfiguration(getCommand(), getContainerEnvironments(), getMountedResources()); } private static String getCommand() { diff --git a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/config/impl/mysql/MySQLContainerConfigurationFactory.java b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/config/impl/mysql/MySQLContainerConfigurationFactory.java index 04d8ba046a036..05ef0389a00a3 100644 --- a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/config/impl/mysql/MySQLContainerConfigurationFactory.java +++ b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/config/impl/mysql/MySQLContainerConfigurationFactory.java @@ -24,12 +24,10 @@ import org.apache.shardingsphere.test.e2e.env.container.atomic.storage.config.StorageContainerConfiguration; import org.apache.shardingsphere.test.e2e.env.container.atomic.storage.impl.MySQLContainer; import org.apache.shardingsphere.test.e2e.env.container.atomic.util.ContainerUtils; -import org.apache.shardingsphere.test.e2e.env.runtime.scenario.database.DatabaseEnvironmentManager; import org.apache.shardingsphere.test.e2e.env.runtime.scenario.path.ScenarioDataPath; import org.apache.shardingsphere.test.e2e.env.runtime.scenario.path.ScenarioDataPath.Type; import java.net.URL; -import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -43,12 +41,11 @@ public final class MySQLContainerConfigurationFactory { * Create new instance of MySQL container configuration. * * @param scenario scenario + * @param type type * @return created instance */ - 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"))); + public static StorageContainerConfiguration newInstance(final String scenario, final Type type) { + return new StorageContainerConfiguration(getCommand(), getContainerEnvironments(), getMountedResources(scenario, type)); } /** @@ -58,7 +55,7 @@ public static StorageContainerConfiguration newInstance(final String scenario) { * @return created instance */ public static StorageContainerConfiguration newInstance(final int majorVersion) { - return new StorageContainerConfiguration(getCommand(), getContainerEnvironments(), getMountedResources(majorVersion), Collections.emptyMap(), Collections.emptyMap()); + return new StorageContainerConfiguration(getCommand(), getContainerEnvironments(), getMountedResources(majorVersion)); } /** @@ -67,7 +64,7 @@ public static StorageContainerConfiguration newInstance(final int majorVersion) * @return created instance */ public static StorageContainerConfiguration newInstance() { - return new StorageContainerConfiguration(getCommand(), getContainerEnvironments(), getMountedResources(), Collections.emptyMap(), Collections.emptyMap()); + return new StorageContainerConfiguration(getCommand(), getContainerEnvironments(), getMountedResources()); } private static String getCommand() { @@ -101,12 +98,15 @@ private static Map getMountedResources(final int majorVersion) { return result; } - private static Map getMountedResources(final String scenario) { - Map 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"); + private static Map getMountedResources(final String scenario, final Type type) { + Map result = new HashMap<>(2, 1F); + if (Type.ACTUAL == type) { + 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"); + } else { + 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("/env/mysql/my.cnf", MySQLContainer.MYSQL_CONF_IN_CONTAINER); return result; } diff --git a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/config/impl/opengauss/OpenGaussContainerConfigurationFactory.java b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/config/impl/opengauss/OpenGaussContainerConfigurationFactory.java index 65ddbddbbd004..8d440a05f656f 100644 --- a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/config/impl/opengauss/OpenGaussContainerConfigurationFactory.java +++ b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/config/impl/opengauss/OpenGaussContainerConfigurationFactory.java @@ -24,7 +24,6 @@ import org.apache.shardingsphere.test.e2e.env.container.atomic.constants.StorageContainerConstants; import org.apache.shardingsphere.test.e2e.env.container.atomic.storage.config.StorageContainerConfiguration; import org.apache.shardingsphere.test.e2e.env.container.atomic.storage.impl.OpenGaussContainer; -import org.apache.shardingsphere.test.e2e.env.runtime.scenario.database.DatabaseEnvironmentManager; import org.apache.shardingsphere.test.e2e.env.runtime.scenario.path.ScenarioDataPath; import org.apache.shardingsphere.test.e2e.env.runtime.scenario.path.ScenarioDataPath.Type; @@ -44,19 +43,18 @@ public final class OpenGaussContainerConfigurationFactory { * @return created instance */ public static StorageContainerConfiguration newInstance() { - return new StorageContainerConfiguration(getCommand(), getContainerEnvironments(), getMountedResources(), Collections.emptyMap(), Collections.emptyMap()); + return new StorageContainerConfiguration(getCommand(), getContainerEnvironments(), getMountedResources()); } /** * Create new instance of openGauss container configuration. * * @param scenario scenario + * @param type type * @return created instance */ - 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"))); + public static StorageContainerConfiguration newInstance(final String scenario, final Type type) { + return new StorageContainerConfiguration(getCommand(), getContainerEnvironments(), getMountedResources(scenario, type)); } private static String getCommand() { @@ -75,12 +73,15 @@ private static Map getMountedResources() { return result; } - private static Map getMountedResources(final String scenario) { - Map result = new HashMap<>(4, 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"); + private static Map getMountedResources(final String scenario, final Type type) { + Map result = new HashMap<>(3, 1F); + if (Type.ACTUAL == type) { + 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"); + } else { + 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("/env/postgresql/postgresql.conf", OpenGaussContainer.OPENGAUSS_CONF_IN_CONTAINER); result.put("/env/opengauss/pg_hba.conf", OpenGaussContainer.OPENGAUSS_HBA_IN_CONF_CONTAINER); return result; diff --git a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/config/impl/postgresql/PostgreSQLContainerConfigurationFactory.java b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/config/impl/postgresql/PostgreSQLContainerConfigurationFactory.java index 786a130e2900e..a80ddf5117056 100644 --- a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/config/impl/postgresql/PostgreSQLContainerConfigurationFactory.java +++ b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/config/impl/postgresql/PostgreSQLContainerConfigurationFactory.java @@ -24,7 +24,6 @@ import org.apache.shardingsphere.test.e2e.env.container.atomic.constants.StorageContainerConstants; import org.apache.shardingsphere.test.e2e.env.container.atomic.storage.config.StorageContainerConfiguration; import org.apache.shardingsphere.test.e2e.env.container.atomic.storage.impl.PostgreSQLContainer; -import org.apache.shardingsphere.test.e2e.env.runtime.scenario.database.DatabaseEnvironmentManager; import org.apache.shardingsphere.test.e2e.env.runtime.scenario.path.ScenarioDataPath; import org.apache.shardingsphere.test.e2e.env.runtime.scenario.path.ScenarioDataPath.Type; @@ -44,19 +43,18 @@ public final class PostgreSQLContainerConfigurationFactory { * @return created instance */ public static StorageContainerConfiguration newInstance() { - return new StorageContainerConfiguration(getCommand(), getContainerEnvironments(), getMountedResources(), Collections.emptyMap(), Collections.emptyMap()); + return new StorageContainerConfiguration(getCommand(), getContainerEnvironments(), getMountedResources()); } /** * Create new instance of PostgreSQL container configuration. * * @param scenario scenario + * @param type type * @return created instance */ - 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"))); + public static StorageContainerConfiguration newInstance(final String scenario, final Type type) { + return new StorageContainerConfiguration(getCommand(), getContainerEnvironments(), getMountedResources(scenario, type)); } private static String getCommand() { @@ -74,12 +72,15 @@ private static Map getMountedResources() { return result; } - private static Map getMountedResources(final String scenario) { - Map 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"); + private static Map getMountedResources(final String scenario, final Type type) { + Map result = new HashMap<>(2, 1F); + if (Type.ACTUAL == type) { + 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"); + } else { + 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("/env/postgresql/postgresql.conf", PostgreSQLContainer.POSTGRESQL_CONF_IN_CONTAINER); return result; } diff --git a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/impl/H2Container.java b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/impl/H2Container.java index 9282f4fe141a7..ad1baacf82b7d 100644 --- a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/impl/H2Container.java +++ b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/impl/H2Container.java @@ -22,8 +22,6 @@ import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader; import org.apache.shardingsphere.test.e2e.env.container.atomic.storage.EmbeddedStorageContainer; import org.apache.shardingsphere.test.e2e.env.container.atomic.storage.config.StorageContainerConfiguration; -import org.apache.shardingsphere.test.e2e.env.runtime.scenario.path.ScenarioDataPath; -import org.apache.shardingsphere.test.e2e.env.runtime.scenario.path.ScenarioDataPath.Type; import org.h2.tools.RunScript; import javax.sql.DataSource; @@ -31,44 +29,31 @@ import java.io.IOException; import java.sql.Connection; import java.sql.SQLException; +import java.util.Collection; import java.util.Map.Entry; -import java.util.Optional; /** * H2 container. */ public final class H2Container extends EmbeddedStorageContainer { - private final ScenarioDataPath scenarioDataPath; + private final StorageContainerConfiguration storageContainerConfig; - public H2Container(final StorageContainerConfiguration storageContainerConfig) { - super(TypedSPILoader.getService(DatabaseType.class, "H2"), storageContainerConfig.getScenario()); - scenarioDataPath = new ScenarioDataPath(storageContainerConfig.getScenario()); + public H2Container(final StorageContainerConfiguration storageContainerConfig, final Collection databases) { + super(TypedSPILoader.getService(DatabaseType.class, "H2"), storageContainerConfig.getScenario(), databases); + this.storageContainerConfig = storageContainerConfig; } @Override @SneakyThrows({IOException.class, SQLException.class}) public void start() { - fillActualDataSet(); - fillExpectedDataSet(); - } - - private void fillActualDataSet() throws SQLException, IOException { - for (Entry entry : getActualDataSourceMap().entrySet()) { - executeInitSQL(entry.getValue(), scenarioDataPath.getInitSQLFile(Type.ACTUAL, getDatabaseType())); - Optional dbInitSQLFile = scenarioDataPath.findActualDatabaseInitSQLFile(entry.getKey(), getDatabaseType()); - if (dbInitSQLFile.isPresent()) { - executeInitSQL(entry.getValue(), dbInitSQLFile.get()); + for (Entry entry : getDataSourceMap().entrySet()) { + for (String each : storageContainerConfig.getMountedResources().keySet()) { + executeInitSQL(entry.getValue(), each); } } } - private void fillExpectedDataSet() throws SQLException, IOException { - for (Entry entry : getExpectedDataSourceMap().entrySet()) { - executeInitSQL(entry.getValue(), scenarioDataPath.getInitSQLFile(Type.EXPECTED, getDatabaseType())); - } - } - private void executeInitSQL(final DataSource dataSource, final String initSQLFile) throws SQLException, IOException { try ( Connection connection = dataSource.getConnection(); diff --git a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/impl/MariaDBContainer.java b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/impl/MariaDBContainer.java index eb2af4a2017af..a89aa697e8873 100644 --- a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/impl/MariaDBContainer.java +++ b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/impl/MariaDBContainer.java @@ -19,15 +19,12 @@ import com.google.common.base.Strings; import org.apache.shardingsphere.infra.database.core.type.DatabaseType; -import org.apache.shardingsphere.infra.database.mysql.type.MySQLDatabaseType; import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader; import org.apache.shardingsphere.test.e2e.env.container.atomic.storage.DockerStorageContainer; import org.apache.shardingsphere.test.e2e.env.container.atomic.storage.config.StorageContainerConfiguration; import java.util.Collection; -import java.util.Map.Entry; import java.util.Optional; -import java.util.stream.Collectors; /** * MariaDB container. @@ -40,8 +37,8 @@ public final class MariaDBContainer extends DockerStorageContainer { private final StorageContainerConfiguration storageContainerConfig; - public MariaDBContainer(final String containerImage, final StorageContainerConfiguration storageContainerConfig) { - super(TypedSPILoader.getService(DatabaseType.class, "MariaDB"), Strings.isNullOrEmpty(containerImage) ? "mariadb:11" : containerImage); + public MariaDBContainer(final String containerImage, final StorageContainerConfiguration storageContainerConfig, final Collection databases) { + super(TypedSPILoader.getService(DatabaseType.class, "MariaDB"), Strings.isNullOrEmpty(containerImage) ? "mariadb:11" : containerImage, databases); this.storageContainerConfig = storageContainerConfig; } @@ -53,18 +50,6 @@ protected void configure() { super.configure(); } - @Override - protected Collection getDatabaseNames() { - return storageContainerConfig.getDatabaseTypes().entrySet().stream() - .filter(entry -> entry.getValue() instanceof MySQLDatabaseType).map(Entry::getKey).collect(Collectors.toList()); - } - - @Override - protected Collection getExpectedDatabaseNames() { - return storageContainerConfig.getExpectedDatabaseTypes().entrySet().stream() - .filter(entry -> entry.getValue() instanceof MySQLDatabaseType).map(Entry::getKey).collect(Collectors.toList()); - } - @Override public int getExposedPort() { return EXPOSED_PORT; diff --git a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/impl/MySQLContainer.java b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/impl/MySQLContainer.java index 55613568514d9..1db2f5b27a359 100644 --- a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/impl/MySQLContainer.java +++ b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/impl/MySQLContainer.java @@ -19,15 +19,12 @@ import com.google.common.base.Strings; import org.apache.shardingsphere.infra.database.core.type.DatabaseType; -import org.apache.shardingsphere.infra.database.mysql.type.MySQLDatabaseType; import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader; import org.apache.shardingsphere.test.e2e.env.container.atomic.storage.DockerStorageContainer; import org.apache.shardingsphere.test.e2e.env.container.atomic.storage.config.StorageContainerConfiguration; import java.util.Collection; -import java.util.Map.Entry; import java.util.Optional; -import java.util.stream.Collectors; /** * MySQL container. @@ -40,8 +37,8 @@ public final class MySQLContainer extends DockerStorageContainer { private final StorageContainerConfiguration storageContainerConfig; - public MySQLContainer(final String containerImage, final StorageContainerConfiguration storageContainerConfig) { - super(TypedSPILoader.getService(DatabaseType.class, "MySQL"), Strings.isNullOrEmpty(containerImage) ? "mysql:8.2.0" : containerImage); + public MySQLContainer(final String containerImage, final StorageContainerConfiguration storageContainerConfig, final Collection databases) { + super(TypedSPILoader.getService(DatabaseType.class, "MySQL"), Strings.isNullOrEmpty(containerImage) ? "mysql:8.2.0" : containerImage, databases); this.storageContainerConfig = storageContainerConfig; } @@ -53,18 +50,6 @@ protected void configure() { super.configure(); } - @Override - protected Collection getDatabaseNames() { - return storageContainerConfig.getDatabaseTypes().entrySet().stream() - .filter(entry -> entry.getValue() instanceof MySQLDatabaseType).map(Entry::getKey).collect(Collectors.toList()); - } - - @Override - protected Collection getExpectedDatabaseNames() { - return storageContainerConfig.getExpectedDatabaseTypes().entrySet().stream() - .filter(entry -> entry.getValue() instanceof MySQLDatabaseType).map(Entry::getKey).collect(Collectors.toList()); - } - @Override public int getExposedPort() { return MYSQL_EXPOSED_PORT; diff --git a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/impl/OpenGaussContainer.java b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/impl/OpenGaussContainer.java index 3f732fc684808..a4cdcfd444242 100644 --- a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/impl/OpenGaussContainer.java +++ b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/impl/OpenGaussContainer.java @@ -19,7 +19,6 @@ import com.google.common.base.Strings; import org.apache.shardingsphere.infra.database.core.type.DatabaseType; -import org.apache.shardingsphere.infra.database.opengauss.type.OpenGaussDatabaseType; import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader; import org.apache.shardingsphere.test.e2e.env.container.atomic.constants.StorageContainerConstants; import org.apache.shardingsphere.test.e2e.env.container.atomic.storage.DockerStorageContainer; @@ -29,9 +28,7 @@ import java.time.Duration; import java.time.temporal.ChronoUnit; import java.util.Collection; -import java.util.Map; import java.util.Optional; -import java.util.stream.Collectors; /** * OpenGauss container. @@ -46,8 +43,8 @@ public final class OpenGaussContainer extends DockerStorageContainer { private final StorageContainerConfiguration storageContainerConfig; - public OpenGaussContainer(final String containerImage, final StorageContainerConfiguration storageContainerConfig) { - super(TypedSPILoader.getService(DatabaseType.class, "openGauss"), Strings.isNullOrEmpty(containerImage) ? "opengauss/opengauss:3.1.0" : containerImage); + public OpenGaussContainer(final String containerImage, final StorageContainerConfiguration storageContainerConfig, final Collection databases) { + super(TypedSPILoader.getService(DatabaseType.class, "openGauss"), Strings.isNullOrEmpty(containerImage) ? "opengauss/opengauss:3.1.0" : containerImage, databases); this.storageContainerConfig = storageContainerConfig; } @@ -61,18 +58,6 @@ protected void configure() { withStartupTimeout(Duration.of(120L, ChronoUnit.SECONDS)); } - @Override - protected Collection getDatabaseNames() { - return storageContainerConfig.getDatabaseTypes().entrySet().stream() - .filter(entry -> entry.getValue() instanceof OpenGaussDatabaseType).map(Map.Entry::getKey).collect(Collectors.toList()); - } - - @Override - protected Collection getExpectedDatabaseNames() { - return storageContainerConfig.getExpectedDatabaseTypes().entrySet().stream() - .filter(entry -> entry.getValue() instanceof OpenGaussDatabaseType).map(Map.Entry::getKey).collect(Collectors.toList()); - } - @Override public int getExposedPort() { return OPENGAUSS_EXPOSED_PORT; diff --git a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/impl/PostgreSQLContainer.java b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/impl/PostgreSQLContainer.java index 67e97673edcf9..a61fbebfba039 100644 --- a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/impl/PostgreSQLContainer.java +++ b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/impl/PostgreSQLContainer.java @@ -19,15 +19,12 @@ import com.google.common.base.Strings; import org.apache.shardingsphere.infra.database.core.type.DatabaseType; -import org.apache.shardingsphere.infra.database.postgresql.type.PostgreSQLDatabaseType; import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader; import org.apache.shardingsphere.test.e2e.env.container.atomic.storage.DockerStorageContainer; import org.apache.shardingsphere.test.e2e.env.container.atomic.storage.config.StorageContainerConfiguration; import java.util.Collection; -import java.util.Map; import java.util.Optional; -import java.util.stream.Collectors; /** * PostgreSQL container. @@ -40,8 +37,8 @@ public final class PostgreSQLContainer extends DockerStorageContainer { private final StorageContainerConfiguration storageContainerConfig; - public PostgreSQLContainer(final String containerImage, final StorageContainerConfiguration storageContainerConfig) { - super(TypedSPILoader.getService(DatabaseType.class, "PostgreSQL"), Strings.isNullOrEmpty(containerImage) ? "postgres:12-alpine" : containerImage); + public PostgreSQLContainer(final String containerImage, final StorageContainerConfiguration storageContainerConfig, final Collection databases) { + super(TypedSPILoader.getService(DatabaseType.class, "PostgreSQL"), Strings.isNullOrEmpty(containerImage) ? "postgres:12-alpine" : containerImage, databases); this.storageContainerConfig = storageContainerConfig; } @@ -53,18 +50,6 @@ protected void configure() { super.configure(); } - @Override - protected Collection getDatabaseNames() { - return storageContainerConfig.getDatabaseTypes().entrySet().stream() - .filter(entry -> entry.getValue() instanceof PostgreSQLDatabaseType).map(Map.Entry::getKey).collect(Collectors.toList()); - } - - @Override - protected Collection getExpectedDatabaseNames() { - return storageContainerConfig.getExpectedDatabaseTypes().entrySet().stream() - .filter(entry -> entry.getValue() instanceof PostgreSQLDatabaseType).map(Map.Entry::getKey).collect(Collectors.toList()); - } - @Override public int getExposedPort() { return POSTGRESQL_EXPOSED_PORT; diff --git a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/runtime/scenario/database/DatabaseEnvironmentManager.java b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/runtime/scenario/database/DatabaseEnvironmentManager.java index 01ad7f8d8b56f..56b14d0efc05f 100644 --- a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/runtime/scenario/database/DatabaseEnvironmentManager.java +++ b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/runtime/scenario/database/DatabaseEnvironmentManager.java @@ -49,7 +49,7 @@ public final class DatabaseEnvironmentManager { * @return database types */ public static Map getDatabaseTypes(final String scenario, final DatabaseType defaultDatabaseType) { - Collection datasourceNames = unmarshal(new ScenarioDataPath(scenario).getDatabasesFile(Type.ACTUAL)).getDatabases(); + Collection datasourceNames = getDatabases(scenario, Type.ACTUAL); return crateDatabaseTypes(datasourceNames, defaultDatabaseType); } @@ -71,7 +71,18 @@ private static Map crateDatabaseTypes(final Collection getExpectedDatabaseTypes(final String scenario, final DatabaseType defaultDatabaseType) { - return crateDatabaseTypes(unmarshal(new ScenarioDataPath(scenario).getDatabasesFile(Type.EXPECTED)).getDatabases(), defaultDatabaseType); + return crateDatabaseTypes(getDatabases(scenario, Type.EXPECTED), defaultDatabaseType); + } + + /** + * Get databases. + * + * @param scenario scenario + * @param type type + * @return databases + */ + public static Collection getDatabases(final String scenario, final Type type) { + return unmarshal(new ScenarioDataPath(scenario).getDatabasesFile(type)).getDatabases(); } @SneakyThrows({IOException.class, JAXBException.class}) diff --git a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/runtime/scenario/path/ScenarioDataPath.java b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/runtime/scenario/path/ScenarioDataPath.java index ac098a896a8bd..f36f032f3a204 100644 --- a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/runtime/scenario/path/ScenarioDataPath.java +++ b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/runtime/scenario/path/ScenarioDataPath.java @@ -72,21 +72,6 @@ private String getFile(final Type type, final String fileName) { return url.getFile(); } - /** - * Get init SQL file. - * - * @param type data type - * @param databaseType database type - * @return expected init SQL file - */ - public String getInitSQLFile(final Type type, final DatabaseType databaseType) { - String initSQLFileName = String.join("-", "01", type.name().toLowerCase(), BASIC_INIT_SQL_FILE); - String initSQLResourceFile = String.join("/", getInitSQLResourcePath(type, databaseType), initSQLFileName); - URL url = Thread.currentThread().getContextClassLoader().getResource(initSQLResourceFile); - assertNotNull(url, String.format("File `%s` must exist.", initSQLResourceFile)); - return url.getFile(); - } - /** * Find actual init SQL file by database name. * diff --git a/test/e2e/operation/showprocesslist/src/test/java/org/apache/shardingsphere/test/e2e/showprocesslist/container/composer/ClusterShowProcessListContainerComposer.java b/test/e2e/operation/showprocesslist/src/test/java/org/apache/shardingsphere/test/e2e/showprocesslist/container/composer/ClusterShowProcessListContainerComposer.java index c3c50dc264973..8a1dc64af0899 100644 --- a/test/e2e/operation/showprocesslist/src/test/java/org/apache/shardingsphere/test/e2e/showprocesslist/container/composer/ClusterShowProcessListContainerComposer.java +++ b/test/e2e/operation/showprocesslist/src/test/java/org/apache/shardingsphere/test/e2e/showprocesslist/container/composer/ClusterShowProcessListContainerComposer.java @@ -56,7 +56,7 @@ public ClusterShowProcessListContainerComposer(final ShowProcessListTestParamete containers = new ITContainers(testParam.getScenario()); governanceContainer = isClusterMode(testParam.getRunMode()) ? containers.registerContainer(GovernanceContainerFactory.newInstance("ZooKeeper")) : null; StorageContainer storageContainer = containers.registerContainer(StorageContainerFactory.newInstance(testParam.getDatabaseType(), "", - StorageContainerConfigurationFactory.newInstance(testParam.getDatabaseType(), testParam.getScenario()))); + StorageContainerConfigurationFactory.newInstance(testParam.getDatabaseType()))); AdaptorContainerConfiguration containerConfig = new AdaptorContainerConfiguration(testParam.getScenario(), new LinkedList<>(), getMountedResources(testParam.getScenario(), testParam.getDatabaseType(), testParam.getRunMode(), testParam.getGovernanceCenter()), AdapterContainerUtils.getAdapterContainerImage(), ""); diff --git a/test/e2e/operation/showprocesslist/src/test/resources/env/scenario/cluster_jdbc_proxy/data/actual/init-sql/mysql/01-actual-init.sql b/test/e2e/operation/showprocesslist/src/test/resources/env/mysql/01-initdb.sql similarity index 87% rename from test/e2e/operation/showprocesslist/src/test/resources/env/scenario/cluster_jdbc_proxy/data/actual/init-sql/mysql/01-actual-init.sql rename to test/e2e/operation/showprocesslist/src/test/resources/env/mysql/01-initdb.sql index 09f76e3f6d1c0..a3637fb84be41 100644 --- a/test/e2e/operation/showprocesslist/src/test/resources/env/scenario/cluster_jdbc_proxy/data/actual/init-sql/mysql/01-actual-init.sql +++ b/test/e2e/operation/showprocesslist/src/test/resources/env/mysql/01-initdb.sql @@ -15,8 +15,12 @@ -- limitations under the License. -- -SET character_set_database='utf8'; -SET character_set_server='utf8'; +SET +character_set_database='utf8'; +SET +character_set_server='utf8'; -DROP DATABASE IF EXISTS db; -CREATE DATABASE db; +DROP +DATABASE IF EXISTS db; +CREATE +DATABASE db; diff --git a/test/e2e/operation/showprocesslist/src/test/resources/env/scenario/cluster_jdbc_proxy/data/actual/databases.xml b/test/e2e/operation/showprocesslist/src/test/resources/env/scenario/cluster_jdbc_proxy/data/actual/databases.xml deleted file mode 100644 index 321ce10618a83..0000000000000 --- a/test/e2e/operation/showprocesslist/src/test/resources/env/scenario/cluster_jdbc_proxy/data/actual/databases.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - db - diff --git a/test/e2e/operation/showprocesslist/src/test/resources/env/scenario/cluster_jdbc_proxy/data/actual/dataset.xml b/test/e2e/operation/showprocesslist/src/test/resources/env/scenario/cluster_jdbc_proxy/data/actual/dataset.xml deleted file mode 100644 index 840ad09871f83..0000000000000 --- a/test/e2e/operation/showprocesslist/src/test/resources/env/scenario/cluster_jdbc_proxy/data/actual/dataset.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - diff --git a/test/e2e/operation/showprocesslist/src/test/resources/env/scenario/cluster_jdbc_proxy/data/actual/init-sql/h2/01-actual-init.sql b/test/e2e/operation/showprocesslist/src/test/resources/env/scenario/cluster_jdbc_proxy/data/actual/init-sql/h2/01-actual-init.sql deleted file mode 100644 index e3b8a181beaf7..0000000000000 --- a/test/e2e/operation/showprocesslist/src/test/resources/env/scenario/cluster_jdbc_proxy/data/actual/init-sql/h2/01-actual-init.sql +++ /dev/null @@ -1,16 +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. --- diff --git a/test/e2e/operation/showprocesslist/src/test/resources/env/scenario/cluster_jdbc_proxy/data/expected/databases.xml b/test/e2e/operation/showprocesslist/src/test/resources/env/scenario/cluster_jdbc_proxy/data/expected/databases.xml deleted file mode 100644 index 7d313fee9d079..0000000000000 --- a/test/e2e/operation/showprocesslist/src/test/resources/env/scenario/cluster_jdbc_proxy/data/expected/databases.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - dataset - diff --git a/test/e2e/operation/showprocesslist/src/test/resources/env/scenario/cluster_jdbc_proxy/data/expected/dataset.xml b/test/e2e/operation/showprocesslist/src/test/resources/env/scenario/cluster_jdbc_proxy/data/expected/dataset.xml deleted file mode 100644 index 840ad09871f83..0000000000000 --- a/test/e2e/operation/showprocesslist/src/test/resources/env/scenario/cluster_jdbc_proxy/data/expected/dataset.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - diff --git a/test/e2e/operation/showprocesslist/src/test/resources/env/scenario/cluster_jdbc_proxy/data/expected/init-sql/h2/01-expected-init.sql b/test/e2e/operation/showprocesslist/src/test/resources/env/scenario/cluster_jdbc_proxy/data/expected/init-sql/h2/01-expected-init.sql deleted file mode 100644 index e3b8a181beaf7..0000000000000 --- a/test/e2e/operation/showprocesslist/src/test/resources/env/scenario/cluster_jdbc_proxy/data/expected/init-sql/h2/01-expected-init.sql +++ /dev/null @@ -1,16 +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. --- diff --git a/test/e2e/operation/showprocesslist/src/test/resources/env/scenario/cluster_jdbc_proxy/data/expected/init-sql/mysql/01-expected-init.sql b/test/e2e/operation/showprocesslist/src/test/resources/env/scenario/cluster_jdbc_proxy/data/expected/init-sql/mysql/01-expected-init.sql deleted file mode 100644 index fd9b8a59246f9..0000000000000 --- a/test/e2e/operation/showprocesslist/src/test/resources/env/scenario/cluster_jdbc_proxy/data/expected/init-sql/mysql/01-expected-init.sql +++ /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. --- - -SET character_set_database='utf8'; -SET character_set_server='utf8'; - - -DROP DATABASE IF EXISTS dataset; -CREATE DATABASE dataset; diff --git a/test/e2e/operation/showprocesslist/src/test/resources/env/scenario/cluster_jdbc_proxy/rules.yaml b/test/e2e/operation/showprocesslist/src/test/resources/env/scenario/cluster_jdbc_proxy/jdbc/conf/mysql/database-cluster-jdbc-proxy.yaml similarity index 69% rename from test/e2e/operation/showprocesslist/src/test/resources/env/scenario/cluster_jdbc_proxy/rules.yaml rename to test/e2e/operation/showprocesslist/src/test/resources/env/scenario/cluster_jdbc_proxy/jdbc/conf/mysql/database-cluster-jdbc-proxy.yaml index c0d9a236b7169..b7d0bf1c0c449 100644 --- a/test/e2e/operation/showprocesslist/src/test/resources/env/scenario/cluster_jdbc_proxy/rules.yaml +++ b/test/e2e/operation/showprocesslist/src/test/resources/env/scenario/cluster_jdbc_proxy/jdbc/conf/mysql/database-cluster-jdbc-proxy.yaml @@ -15,4 +15,15 @@ # limitations under the License. # -rules: +databaseName: cluster_jdbc_proxy + +dataSources: + db: + url: jdbc:mysql://mysql.cluster_jdbc_proxy.host:3306/db?useSSL=false&characterEncoding=utf-8 + username: test_user + password: Test@123 + connectionTimeoutMilliseconds: 30000 + idleTimeoutMilliseconds: 60000 + maxLifetimeMilliseconds: 1800000 + maxPoolSize: 50 + minPoolSize: 50 diff --git a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/framework/container/compose/DockerContainerComposer.java b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/framework/container/compose/DockerContainerComposer.java index 09e2871d44f69..70ec275d0f0af 100644 --- a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/framework/container/compose/DockerContainerComposer.java +++ b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/framework/container/compose/DockerContainerComposer.java @@ -29,6 +29,8 @@ import org.apache.shardingsphere.test.e2e.env.container.atomic.governance.impl.ZookeeperContainer; import org.apache.shardingsphere.test.e2e.env.container.atomic.storage.DockerStorageContainer; import org.apache.shardingsphere.test.e2e.env.container.atomic.storage.StorageContainerFactory; +import org.apache.shardingsphere.test.e2e.env.runtime.scenario.database.DatabaseEnvironmentManager; +import org.apache.shardingsphere.test.e2e.env.runtime.scenario.path.ScenarioDataPath.Type; import org.apache.shardingsphere.test.e2e.transaction.framework.container.config.StorageContainerConfigurationFactory; import org.apache.shardingsphere.test.e2e.transaction.framework.container.config.proxy.ProxyClusterContainerConfigurationFactory; import org.apache.shardingsphere.test.e2e.transaction.framework.container.jdbc.ShardingSphereJDBCContainer; @@ -59,7 +61,7 @@ public DockerContainerComposer(final TransactionTestParameter testParam) { databaseType = testParam.getDatabaseType(); governanceContainer = getContainers().registerContainer(new ZookeeperContainer()); storageContainer = getContainers().registerContainer((DockerStorageContainer) StorageContainerFactory.newInstance(databaseType, testParam.getStorageContainerImage(), - StorageContainerConfigurationFactory.newInstance(databaseType, testParam.getScenario()))); + StorageContainerConfigurationFactory.newInstance(databaseType, testParam.getScenario()), DatabaseEnvironmentManager.getDatabases(testParam.getScenario(), Type.ACTUAL))); if (AdapterType.PROXY.getValue().equalsIgnoreCase(testParam.getAdapter())) { jdbcContainer = null; proxyContainer = (ShardingSphereProxyClusterContainer) AdapterContainerFactory.newInstance(AdapterMode.CLUSTER, AdapterType.PROXY, diff --git a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/framework/container/config/StorageContainerConfigurationFactory.java b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/framework/container/config/StorageContainerConfigurationFactory.java index 4b4647ba106ed..99eae3eeb979f 100644 --- a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/framework/container/config/StorageContainerConfigurationFactory.java +++ b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/framework/container/config/StorageContainerConfigurationFactory.java @@ -21,7 +21,7 @@ import lombok.NoArgsConstructor; import org.apache.shardingsphere.infra.database.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.impl.h2.H2ContainerConfigurationFactory; +import org.apache.shardingsphere.test.e2e.transaction.framework.container.config.h2.H2ContainerConfigurationFactory; import org.apache.shardingsphere.test.e2e.transaction.framework.container.config.mysql.MySQLContainerConfigurationFactory; import org.apache.shardingsphere.test.e2e.transaction.framework.container.config.opengauss.OpenGaussContainerConfigurationFactory; import org.apache.shardingsphere.test.e2e.transaction.framework.container.config.postgresql.PostgreSQLContainerConfigurationFactory; diff --git a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/framework/container/config/h2/H2ContainerConfigurationFactory.java b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/framework/container/config/h2/H2ContainerConfigurationFactory.java new file mode 100644 index 0000000000000..8cfe4521ac91a --- /dev/null +++ b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/framework/container/config/h2/H2ContainerConfigurationFactory.java @@ -0,0 +1,52 @@ +/* + * 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.transaction.framework.container.config.h2; + +import lombok.AccessLevel; +import lombok.NoArgsConstructor; +import org.apache.shardingsphere.infra.database.core.type.DatabaseType; +import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader; +import org.apache.shardingsphere.test.e2e.env.container.atomic.storage.config.StorageContainerConfiguration; +import org.apache.shardingsphere.test.e2e.env.runtime.scenario.path.ScenarioDataPath; +import org.apache.shardingsphere.test.e2e.env.runtime.scenario.path.ScenarioDataPath.Type; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +/** + * H2 container configuration factory. + */ +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public final class H2ContainerConfigurationFactory { + + /** + * Create new instance of h2 container configuration. + * + * @param scenario scenario + * @return created instance + */ + public static StorageContainerConfiguration newInstance(final String scenario) { + Map mountedResources = new HashMap<>(2, 1F); + mountedResources.put(new ScenarioDataPath(scenario).getInitSQLResourcePath(Type.ACTUAL, TypedSPILoader.getService(DatabaseType.class, "H2")) + "/01-actual-init.sql", + "/docker-entrypoint-initdb.d/01-actual-init.sql"); + mountedResources.put(new ScenarioDataPath(scenario).getInitSQLResourcePath(Type.EXPECTED, TypedSPILoader.getService(DatabaseType.class, "H2")) + "/01-expected-init.sql", + "/docker-entrypoint-initdb.d/01-expected-init.sql"); + return new StorageContainerConfiguration(scenario, "", Collections.emptyMap(), mountedResources); + } +} diff --git a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/framework/container/config/mysql/MySQLContainerConfigurationFactory.java b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/framework/container/config/mysql/MySQLContainerConfigurationFactory.java index aca46ec0f7c63..9c5c3759dd579 100644 --- a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/framework/container/config/mysql/MySQLContainerConfigurationFactory.java +++ b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/framework/container/config/mysql/MySQLContainerConfigurationFactory.java @@ -23,7 +23,6 @@ import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader; import org.apache.shardingsphere.test.e2e.env.container.atomic.storage.config.StorageContainerConfiguration; import org.apache.shardingsphere.test.e2e.env.container.atomic.storage.impl.MySQLContainer; -import org.apache.shardingsphere.test.e2e.env.runtime.scenario.database.DatabaseEnvironmentManager; import org.apache.shardingsphere.test.e2e.env.runtime.scenario.path.ScenarioDataPath; import org.apache.shardingsphere.test.e2e.env.runtime.scenario.path.ScenarioDataPath.Type; @@ -43,9 +42,7 @@ public final class MySQLContainerConfigurationFactory { * @return created instance */ 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"))); + return new StorageContainerConfiguration(getCommand(), getContainerEnvironments(), getMountedResources(scenario)); } private static String getCommand() { diff --git a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/framework/container/config/opengauss/OpenGaussContainerConfigurationFactory.java b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/framework/container/config/opengauss/OpenGaussContainerConfigurationFactory.java index 025ca750575d4..075f8572843cc 100644 --- a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/framework/container/config/opengauss/OpenGaussContainerConfigurationFactory.java +++ b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/framework/container/config/opengauss/OpenGaussContainerConfigurationFactory.java @@ -24,7 +24,6 @@ import org.apache.shardingsphere.test.e2e.env.container.atomic.constants.StorageContainerConstants; import org.apache.shardingsphere.test.e2e.env.container.atomic.storage.config.StorageContainerConfiguration; import org.apache.shardingsphere.test.e2e.env.container.atomic.storage.impl.OpenGaussContainer; -import org.apache.shardingsphere.test.e2e.env.runtime.scenario.database.DatabaseEnvironmentManager; import org.apache.shardingsphere.test.e2e.env.runtime.scenario.path.ScenarioDataPath; import org.apache.shardingsphere.test.e2e.env.runtime.scenario.path.ScenarioDataPath.Type; @@ -45,9 +44,7 @@ public final class OpenGaussContainerConfigurationFactory { * @return created instance */ 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"))); + return new StorageContainerConfiguration(getCommand(), getContainerEnvironments(), getMountedResources(scenario)); } private static String getCommand() { diff --git a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/framework/container/config/postgresql/PostgreSQLContainerConfigurationFactory.java b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/framework/container/config/postgresql/PostgreSQLContainerConfigurationFactory.java index bd3e922c6b672..24594720dc376 100644 --- a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/framework/container/config/postgresql/PostgreSQLContainerConfigurationFactory.java +++ b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/framework/container/config/postgresql/PostgreSQLContainerConfigurationFactory.java @@ -24,7 +24,6 @@ import org.apache.shardingsphere.test.e2e.env.container.atomic.constants.StorageContainerConstants; import org.apache.shardingsphere.test.e2e.env.container.atomic.storage.config.StorageContainerConfiguration; import org.apache.shardingsphere.test.e2e.env.container.atomic.storage.impl.OpenGaussContainer; -import org.apache.shardingsphere.test.e2e.env.runtime.scenario.database.DatabaseEnvironmentManager; import org.apache.shardingsphere.test.e2e.env.runtime.scenario.path.ScenarioDataPath; import org.apache.shardingsphere.test.e2e.env.runtime.scenario.path.ScenarioDataPath.Type; @@ -44,9 +43,7 @@ public final class PostgreSQLContainerConfigurationFactory { * @return created instance */ 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"))); + return new StorageContainerConfiguration(getCommand(), getContainerEnvironments(), getMountedResources(scenario)); } private static String getCommand() { diff --git a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/framework/container/jdbc/ShardingSphereJDBCContainer.java b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/framework/container/jdbc/ShardingSphereJDBCContainer.java index 80d8dd4af3e83..93a0018afa695 100644 --- a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/framework/container/jdbc/ShardingSphereJDBCContainer.java +++ b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/framework/container/jdbc/ShardingSphereJDBCContainer.java @@ -59,7 +59,7 @@ public DataSource getTargetDataSource() { if (null == dataSource) { try { targetDataSourceProvider.set( - YamlShardingSphereDataSourceFactory.createDataSource(databaseContainer.getActualDataSourceMap(), new File(ruleConfigPath))); + YamlShardingSphereDataSourceFactory.createDataSource(databaseContainer.getDataSourceMap(), new File(ruleConfigPath))); } catch (final SQLException | IOException ex) { throw new RuntimeException(ex); } diff --git a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/container/compose/ContainerComposerRegistry.java b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/container/compose/ContainerComposerRegistry.java index fa9098e5c4e3a..2a27559a97d3f 100644 --- a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/container/compose/ContainerComposerRegistry.java +++ b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/container/compose/ContainerComposerRegistry.java @@ -18,14 +18,25 @@ package org.apache.shardingsphere.test.e2e.container.compose; import com.google.common.base.Preconditions; +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; import lombok.SneakyThrows; +import org.apache.commons.math3.util.Pair; +import org.apache.shardingsphere.driver.yaml.YamlJDBCConfiguration; import org.apache.shardingsphere.infra.database.core.type.DatabaseType; +import org.apache.shardingsphere.infra.database.core.type.DatabaseTypeFactory; +import org.apache.shardingsphere.infra.url.core.ShardingSphereURL; +import org.apache.shardingsphere.infra.url.core.ShardingSphereURLLoadEngine; +import org.apache.shardingsphere.infra.util.yaml.YamlEngine; import org.apache.shardingsphere.test.e2e.container.compose.mode.ClusterContainerComposer; import org.apache.shardingsphere.test.e2e.container.compose.mode.StandaloneContainerComposer; -import org.apache.shardingsphere.test.e2e.env.container.atomic.enums.AdapterType; import org.apache.shardingsphere.test.e2e.env.container.atomic.enums.AdapterMode; +import org.apache.shardingsphere.test.e2e.env.container.atomic.enums.AdapterType; +import org.apache.shardingsphere.test.e2e.env.runtime.scenario.path.ScenarioCommonPath; import javax.sql.DataSource; +import java.io.IOException; +import java.util.Collection; import java.util.HashMap; import java.util.Map; @@ -68,7 +79,20 @@ private boolean isClusterMode(final AdapterMode adapterMode, final AdapterType a } private ContainerComposer createContainerComposer(final boolean clusterMode, final String scenario, final DatabaseType databaseType, final AdapterMode adapterMode, final AdapterType adapterType) { - return clusterMode ? new ClusterContainerComposer(scenario, databaseType, adapterMode, adapterType) : new StandaloneContainerComposer(scenario, databaseType, adapterMode, adapterType); + Map> storageDatabaseTypeMap = getStorageDatabaseTypeMap(getYamlConfig(scenario, databaseType)); + return clusterMode ? new ClusterContainerComposer(scenario, databaseType, adapterMode, adapterType, storageDatabaseTypeMap) + : new StandaloneContainerComposer(scenario, databaseType, adapterMode, adapterType, storageDatabaseTypeMap); + } + + private static Map> getStorageDatabaseTypeMap(final YamlJDBCConfiguration rootConfig) { + return rootConfig.getDataSources().entrySet().stream().map(entry -> new Pair<>(entry.getKey(), DatabaseTypeFactory.get((String) entry.getValue().get("url")))) + .collect(HashMultimap::create, (map, pair) -> map.put(pair.getSecond(), pair.getFirst()), Multimap::putAll).asMap(); + } + + @SneakyThrows(IOException.class) + private YamlJDBCConfiguration getYamlConfig(final String scenario, final DatabaseType databaseType) { + ShardingSphereURLLoadEngine urlLoadEngine = new ShardingSphereURLLoadEngine(ShardingSphereURL.parse("absolutepath:" + new ScenarioCommonPath(scenario).getRuleConfigurationFile(databaseType))); + return YamlEngine.unmarshal(urlLoadEngine.loadContent(), YamlJDBCConfiguration.class); } @Override diff --git a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/container/compose/mode/ClusterContainerComposer.java b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/container/compose/mode/ClusterContainerComposer.java index 5d1565ab0334a..00e091ad2058f 100644 --- a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/container/compose/mode/ClusterContainerComposer.java +++ b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/container/compose/mode/ClusterContainerComposer.java @@ -33,8 +33,13 @@ import org.apache.shardingsphere.test.e2e.env.container.atomic.storage.StorageContainerFactory; import org.apache.shardingsphere.test.e2e.env.container.atomic.storage.config.impl.StorageContainerConfigurationFactory; import org.apache.shardingsphere.test.e2e.env.container.atomic.util.AdapterContainerUtils; +import org.apache.shardingsphere.test.e2e.env.runtime.scenario.database.DatabaseEnvironmentManager; +import org.apache.shardingsphere.test.e2e.env.runtime.scenario.path.ScenarioDataPath.Type; import javax.sql.DataSource; +import java.util.Collection; +import java.util.Collections; +import java.util.LinkedList; import java.util.Map; /** @@ -46,21 +51,30 @@ public final class ClusterContainerComposer implements ContainerComposer { private final GovernanceContainer governanceContainer; - private final StorageContainer storageContainer; + private final Collection actualStorageContainer = new LinkedList<>(); + + private final StorageContainer expectStorageContainer; private final AdapterContainer adapterContainer; - public ClusterContainerComposer(final String scenario, final DatabaseType databaseType, final AdapterMode adapterMode, final AdapterType adapterType) { + public ClusterContainerComposer(final String scenario, final DatabaseType databaseType, final AdapterMode adapterMode, final AdapterType adapterType, + final Map> storageDatabaseTypeMap) { containers = new ITContainers(scenario); // TODO support other types of governance governanceContainer = containers.registerContainer(GovernanceContainerFactory.newInstance("ZooKeeper")); // TODO add more version of databases - storageContainer = containers.registerContainer(StorageContainerFactory.newInstance(databaseType, "", - StorageContainerConfigurationFactory.newInstance(databaseType, scenario))); + for (Map.Entry> entry : storageDatabaseTypeMap.entrySet()) { + actualStorageContainer.add(containers.registerContainer(StorageContainerFactory.newInstance(entry.getKey(), "", + StorageContainerConfigurationFactory.newInstance(entry.getKey(), scenario, Type.ACTUAL), entry.getValue()))); + } + expectStorageContainer = containers.registerContainer(StorageContainerFactory.newInstance(databaseType, "", + StorageContainerConfigurationFactory.newInstance(databaseType, scenario, Type.EXPECTED), DatabaseEnvironmentManager.getDatabases(scenario, Type.EXPECTED)), + String.join(".", databaseType.getType(), scenario, "expected.host")); AdaptorContainerConfiguration containerConfig = ProxyClusterContainerConfigurationFactory.newInstance(scenario, databaseType, AdapterContainerUtils.getAdapterContainerImage()); AdapterContainer adapterContainer = AdapterContainerFactory.newInstance(adapterMode, adapterType, databaseType, scenario, containerConfig); if (adapterContainer instanceof DockerITContainer) { - ((DockerITContainer) adapterContainer).dependsOn(governanceContainer, storageContainer); + actualStorageContainer.forEach(actualStorage -> ((DockerITContainer) adapterContainer).dependsOn(governanceContainer, actualStorage)); + ((DockerITContainer) adapterContainer).dependsOn(governanceContainer, expectStorageContainer); } this.adapterContainer = containers.registerContainer(adapterContainer); } @@ -77,12 +91,15 @@ public DataSource getTargetDataSource() { @Override public Map getActualDataSourceMap() { - return storageContainer.getActualDataSourceMap(); + return actualStorageContainer.stream().map(StorageContainer::getDataSourceMap).reduce((a, b) -> { + a.putAll(b); + return a; + }).orElse(Collections.emptyMap()); } @Override public Map getExpectedDataSourceMap() { - return storageContainer.getExpectedDataSourceMap(); + return expectStorageContainer.getDataSourceMap(); } @Override diff --git a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/container/compose/mode/StandaloneContainerComposer.java b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/container/compose/mode/StandaloneContainerComposer.java index c8dc96a2bdc7c..17535c8e60cae 100644 --- a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/container/compose/mode/StandaloneContainerComposer.java +++ b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/container/compose/mode/StandaloneContainerComposer.java @@ -29,8 +29,13 @@ import org.apache.shardingsphere.test.e2e.env.container.atomic.storage.StorageContainer; import org.apache.shardingsphere.test.e2e.env.container.atomic.storage.StorageContainerFactory; import org.apache.shardingsphere.test.e2e.env.container.atomic.storage.config.impl.StorageContainerConfigurationFactory; +import org.apache.shardingsphere.test.e2e.env.runtime.scenario.database.DatabaseEnvironmentManager; +import org.apache.shardingsphere.test.e2e.env.runtime.scenario.path.ScenarioDataPath.Type; import javax.sql.DataSource; +import java.util.Collection; +import java.util.Collections; +import java.util.LinkedList; import java.util.Map; /** @@ -40,18 +45,27 @@ public final class StandaloneContainerComposer implements ContainerComposer { private final ITContainers containers; - private final StorageContainer storageContainer; + private final Collection actualStorageContainer = new LinkedList<>(); + + private final StorageContainer expectStorageContainer; private final AdapterContainer adapterContainer; - public StandaloneContainerComposer(final String scenario, final DatabaseType databaseType, final AdapterMode adapterMode, final AdapterType adapterType) { + public StandaloneContainerComposer(final String scenario, final DatabaseType databaseType, final AdapterMode adapterMode, final AdapterType adapterType, + final Map> storageDatabaseTypeMap) { containers = new ITContainers(scenario); // TODO add more version of databases - storageContainer = containers.registerContainer(StorageContainerFactory.newInstance(databaseType, "", StorageContainerConfigurationFactory.newInstance(databaseType, scenario))); + for (Map.Entry> entry : storageDatabaseTypeMap.entrySet()) { + actualStorageContainer.add(containers.registerContainer(StorageContainerFactory.newInstance(entry.getKey(), "", + StorageContainerConfigurationFactory.newInstance(entry.getKey(), scenario, Type.ACTUAL), entry.getValue()))); + } + expectStorageContainer = containers.registerContainer(StorageContainerFactory.newInstance(databaseType, "", + StorageContainerConfigurationFactory.newInstance(databaseType, scenario, Type.EXPECTED), DatabaseEnvironmentManager.getDatabases(scenario, Type.EXPECTED)), + String.join(".", databaseType.getType(), scenario, "expected.host")); adapterContainer = containers.registerContainer(AdapterContainerFactory.newInstance(adapterMode, adapterType, databaseType, scenario, ProxyStandaloneContainerConfigurationFactory.newInstance(scenario, databaseType))); if (adapterContainer instanceof DockerITContainer) { - ((DockerITContainer) adapterContainer).dependsOn(storageContainer); + ((DockerITContainer) adapterContainer).dependsOn(actualStorageContainer); } } @@ -67,12 +81,15 @@ public DataSource getTargetDataSource() { @Override public Map getActualDataSourceMap() { - return storageContainer.getActualDataSourceMap(); + return actualStorageContainer.stream().map(StorageContainer::getDataSourceMap).reduce((a, b) -> { + a.putAll(b); + return a; + }).orElse(Collections.emptyMap()); } @Override public Map getExpectedDataSourceMap() { - return storageContainer.getExpectedDataSourceMap(); + return expectStorageContainer.getDataSourceMap(); } @Override diff --git a/test/e2e/sql/src/test/resources/env/scenario/db/jdbc/conf/mysql/rules.yaml b/test/e2e/sql/src/test/resources/env/scenario/db/jdbc/conf/mysql/rules.yaml index 726ee9d0f0019..54945c24ac758 100644 --- a/test/e2e/sql/src/test/resources/env/scenario/db/jdbc/conf/mysql/rules.yaml +++ b/test/e2e/sql/src/test/resources/env/scenario/db/jdbc/conf/mysql/rules.yaml @@ -18,7 +18,7 @@ databaseName: db dataSources: - ds_0: + db_0: url: jdbc:mysql://mysql.db.host:3306/db_0?useSSL=false&characterEncoding=utf-8 dataSourceClassName: com.zaxxer.hikari.HikariDataSource username: test_user @@ -28,7 +28,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_1: + db_1: url: jdbc:mysql://mysql.db.host:3306/db_1?useSSL=false&characterEncoding=utf-8 dataSourceClassName: com.zaxxer.hikari.HikariDataSource username: test_user @@ -38,7 +38,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_2: + db_2: url: jdbc:mysql://mysql.db.host:3306/db_2?useSSL=false&characterEncoding=utf-8 dataSourceClassName: com.zaxxer.hikari.HikariDataSource username: test_user @@ -48,7 +48,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_3: + db_3: url: jdbc:mysql://mysql.db.host:3306/db_3?useSSL=false&characterEncoding=utf-8 dataSourceClassName: com.zaxxer.hikari.HikariDataSource username: test_user @@ -58,7 +58,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_4: + db_4: url: jdbc:mysql://mysql.db.host:3306/db_4?useSSL=false&characterEncoding=utf-8 dataSourceClassName: com.zaxxer.hikari.HikariDataSource username: test_user @@ -68,7 +68,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_5: + db_5: url: jdbc:mysql://mysql.db.host:3306/db_5?useSSL=false&characterEncoding=utf-8 dataSourceClassName: com.zaxxer.hikari.HikariDataSource username: test_user @@ -78,7 +78,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_6: + db_6: url: jdbc:mysql://mysql.db.host:3306/db_6?useSSL=false&characterEncoding=utf-8 dataSourceClassName: com.zaxxer.hikari.HikariDataSource username: test_user @@ -88,7 +88,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_7: + db_7: url: jdbc:mysql://mysql.db.host:3306/db_7?useSSL=false&characterEncoding=utf-8 dataSourceClassName: com.zaxxer.hikari.HikariDataSource username: test_user @@ -98,7 +98,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_8: + db_8: url: jdbc:mysql://mysql.db.host:3306/db_8?useSSL=false&characterEncoding=utf-8 dataSourceClassName: com.zaxxer.hikari.HikariDataSource username: test_user @@ -108,7 +108,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_9: + db_9: url: jdbc:mysql://mysql.db.host:3306/db_9?useSSL=false&characterEncoding=utf-8 dataSourceClassName: com.zaxxer.hikari.HikariDataSource username: test_user @@ -126,13 +126,13 @@ rules: - !SHARDING tables: t_order: - actualDataNodes: ds_${0..9}.t_order + actualDataNodes: db_${0..9}.t_order databaseStrategy: standard: shardingColumn: user_id shardingAlgorithmName: it_standard_fixture t_order_item: - actualDataNodes: ds_${0..9}.t_order_item + actualDataNodes: db_${0..9}.t_order_item databaseStrategy: standard: shardingColumn: user_id @@ -145,7 +145,7 @@ rules: - auditor_constant allowHintDisable: true t_order_details: - actualDataNodes: ds_${0..9}.t_order_details + actualDataNodes: db_${0..9}.t_order_details databaseStrategy: standard: shardingColumn: user_id diff --git a/test/e2e/sql/src/test/resources/env/scenario/db/jdbc/conf/opengauss/rules.yaml b/test/e2e/sql/src/test/resources/env/scenario/db/jdbc/conf/opengauss/rules.yaml index 1a7db8cf74fd2..7803c52d091fa 100644 --- a/test/e2e/sql/src/test/resources/env/scenario/db/jdbc/conf/opengauss/rules.yaml +++ b/test/e2e/sql/src/test/resources/env/scenario/db/jdbc/conf/opengauss/rules.yaml @@ -18,7 +18,7 @@ databaseName: db dataSources: - ds_0: + db_0: url: jdbc:opengauss://opengauss.db.host:5432/db_0 dataSourceClassName: com.zaxxer.hikari.HikariDataSource username: test_user @@ -28,7 +28,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_1: + db_1: url: jdbc:opengauss://opengauss.db.host:5432/db_1 dataSourceClassName: com.zaxxer.hikari.HikariDataSource username: test_user @@ -38,7 +38,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_2: + db_2: url: jdbc:opengauss://opengauss.db.host:5432/db_2 dataSourceClassName: com.zaxxer.hikari.HikariDataSource username: test_user @@ -48,7 +48,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_3: + db_3: url: jdbc:opengauss://opengauss.db.host:5432/db_3 dataSourceClassName: com.zaxxer.hikari.HikariDataSource username: test_user @@ -58,7 +58,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_4: + db_4: url: jdbc:opengauss://opengauss.db.host:5432/db_4 dataSourceClassName: com.zaxxer.hikari.HikariDataSource username: test_user @@ -68,7 +68,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_5: + db_5: url: jdbc:opengauss://opengauss.db.host:5432/db_5 dataSourceClassName: com.zaxxer.hikari.HikariDataSource username: test_user @@ -78,7 +78,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_6: + db_6: url: jdbc:opengauss://opengauss.db.host:5432/db_6 dataSourceClassName: com.zaxxer.hikari.HikariDataSource username: test_user @@ -88,7 +88,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_7: + db_7: url: jdbc:opengauss://opengauss.db.host:5432/db_7 dataSourceClassName: com.zaxxer.hikari.HikariDataSource username: test_user @@ -98,7 +98,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_8: + db_8: url: jdbc:opengauss://opengauss.db.host:5432/db_8 dataSourceClassName: com.zaxxer.hikari.HikariDataSource username: test_user @@ -108,7 +108,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_9: + db_9: url: jdbc:opengauss://opengauss.db.host:5432/db_9 dataSourceClassName: com.zaxxer.hikari.HikariDataSource username: test_user @@ -126,13 +126,13 @@ rules: - !SHARDING tables: t_order: - actualDataNodes: ds_${0..9}.t_order + actualDataNodes: db_${0..9}.t_order databaseStrategy: standard: shardingColumn: user_id shardingAlgorithmName: it_standard_fixture t_order_item: - actualDataNodes: ds_${0..9}.t_order_item + actualDataNodes: db_${0..9}.t_order_item databaseStrategy: standard: shardingColumn: user_id @@ -145,7 +145,7 @@ rules: - auditor_constant allowHintDisable: true t_order_details: - actualDataNodes: ds_${0..9}.t_order_details + actualDataNodes: db_${0..9}.t_order_details databaseStrategy: standard: shardingColumn: user_id diff --git a/test/e2e/sql/src/test/resources/env/scenario/db/jdbc/conf/postgresql/rules.yaml b/test/e2e/sql/src/test/resources/env/scenario/db/jdbc/conf/postgresql/rules.yaml index 0d4cd56986c15..0568e71c585a1 100644 --- a/test/e2e/sql/src/test/resources/env/scenario/db/jdbc/conf/postgresql/rules.yaml +++ b/test/e2e/sql/src/test/resources/env/scenario/db/jdbc/conf/postgresql/rules.yaml @@ -18,7 +18,7 @@ databaseName: db dataSources: - ds_0: + db_0: url: jdbc:postgresql://postgresql.db.host:5432/db_0 dataSourceClassName: com.zaxxer.hikari.HikariDataSource username: test_user @@ -28,7 +28,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_1: + db_1: url: jdbc:postgresql://postgresql.db.host:5432/db_1 dataSourceClassName: com.zaxxer.hikari.HikariDataSource username: test_user @@ -38,7 +38,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_2: + db_2: url: jdbc:postgresql://postgresql.db.host:5432/db_2 dataSourceClassName: com.zaxxer.hikari.HikariDataSource username: test_user @@ -48,7 +48,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_3: + db_3: url: jdbc:postgresql://postgresql.db.host:5432/db_3 dataSourceClassName: com.zaxxer.hikari.HikariDataSource username: test_user @@ -58,7 +58,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_4: + db_4: url: jdbc:postgresql://postgresql.db.host:5432/db_4 dataSourceClassName: com.zaxxer.hikari.HikariDataSource username: test_user @@ -68,7 +68,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_5: + db_5: url: jdbc:postgresql://postgresql.db.host:5432/db_5 dataSourceClassName: com.zaxxer.hikari.HikariDataSource username: test_user @@ -78,7 +78,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_6: + db_6: url: jdbc:postgresql://postgresql.db.host:5432/db_6 dataSourceClassName: com.zaxxer.hikari.HikariDataSource username: test_user @@ -88,7 +88,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_7: + db_7: url: jdbc:postgresql://postgresql.db.host:5432/db_7 dataSourceClassName: com.zaxxer.hikari.HikariDataSource username: test_user @@ -98,7 +98,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_8: + db_8: url: jdbc:postgresql://postgresql.db.host:5432/db_8 dataSourceClassName: com.zaxxer.hikari.HikariDataSource username: test_user @@ -108,7 +108,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_9: + db_9: url: jdbc:postgresql://postgresql.db.host:5432/db_9 dataSourceClassName: com.zaxxer.hikari.HikariDataSource username: test_user @@ -126,13 +126,13 @@ rules: - !SHARDING tables: t_order: - actualDataNodes: ds_${0..9}.t_order + actualDataNodes: db_${0..9}.t_order databaseStrategy: standard: shardingColumn: user_id shardingAlgorithmName: it_standard_fixture t_order_item: - actualDataNodes: ds_${0..9}.t_order_item + actualDataNodes: db_${0..9}.t_order_item databaseStrategy: standard: shardingColumn: user_id @@ -145,7 +145,7 @@ rules: - auditor_constant allowHintDisable: true t_order_details: - actualDataNodes: ds_${0..9}.t_order_details + actualDataNodes: db_${0..9}.t_order_details databaseStrategy: standard: shardingColumn: user_id diff --git a/test/e2e/sql/src/test/resources/env/scenario/db/proxy/conf/mysql/database-db.yaml b/test/e2e/sql/src/test/resources/env/scenario/db/proxy/conf/mysql/database-db.yaml index 168704b0dbf22..d978538b3d564 100644 --- a/test/e2e/sql/src/test/resources/env/scenario/db/proxy/conf/mysql/database-db.yaml +++ b/test/e2e/sql/src/test/resources/env/scenario/db/proxy/conf/mysql/database-db.yaml @@ -18,7 +18,7 @@ databaseName: db dataSources: - ds_0: + db_0: url: jdbc:mysql://mysql.db.host:3306/db_0?useSSL=false&characterEncoding=utf-8 username: test_user password: Test@123 @@ -27,7 +27,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_1: + db_1: url: jdbc:mysql://mysql.db.host:3306/db_1?useSSL=false&characterEncoding=utf-8 username: test_user password: Test@123 @@ -36,7 +36,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_2: + db_2: url: jdbc:mysql://mysql.db.host:3306/db_2?useSSL=false&characterEncoding=utf-8 username: test_user password: Test@123 @@ -45,7 +45,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_3: + db_3: url: jdbc:mysql://mysql.db.host:3306/db_3?useSSL=false&characterEncoding=utf-8 username: test_user password: Test@123 @@ -54,7 +54,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_4: + db_4: url: jdbc:mysql://mysql.db.host:3306/db_4?useSSL=false&characterEncoding=utf-8 username: test_user password: Test@123 @@ -63,7 +63,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_5: + db_5: url: jdbc:mysql://mysql.db.host:3306/db_5?useSSL=false&characterEncoding=utf-8 username: test_user password: Test@123 @@ -72,7 +72,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_6: + db_6: url: jdbc:mysql://mysql.db.host:3306/db_6?useSSL=false&characterEncoding=utf-8 username: test_user password: Test@123 @@ -81,7 +81,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_7: + db_7: url: jdbc:mysql://mysql.db.host:3306/db_7?useSSL=false&characterEncoding=utf-8 username: test_user password: Test@123 @@ -90,7 +90,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_8: + db_8: url: jdbc:mysql://mysql.db.host:3306/db_8?useSSL=false&characterEncoding=utf-8 username: test_user password: Test@123 @@ -99,7 +99,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_9: + db_9: url: jdbc:mysql://mysql.db.host:3306/db_9?useSSL=false&characterEncoding=utf-8 username: test_user password: Test@123 @@ -116,13 +116,13 @@ rules: - !SHARDING tables: t_order: - actualDataNodes: ds_${0..9}.t_order + actualDataNodes: db_${0..9}.t_order databaseStrategy: standard: shardingColumn: user_id shardingAlgorithmName: it_standard_fixture t_order_item: - actualDataNodes: ds_${0..9}.t_order_item + actualDataNodes: db_${0..9}.t_order_item databaseStrategy: standard: shardingColumn: user_id @@ -135,7 +135,7 @@ rules: - auditor_constant allowHintDisable: true t_order_details: - actualDataNodes: ds_${0..9}.t_order_details + actualDataNodes: db_${0..9}.t_order_details databaseStrategy: standard: shardingColumn: user_id diff --git a/test/e2e/sql/src/test/resources/env/scenario/db/proxy/conf/opengauss/database-db.yaml b/test/e2e/sql/src/test/resources/env/scenario/db/proxy/conf/opengauss/database-db.yaml index 804ee23c6a7aa..58cdf8c780e45 100644 --- a/test/e2e/sql/src/test/resources/env/scenario/db/proxy/conf/opengauss/database-db.yaml +++ b/test/e2e/sql/src/test/resources/env/scenario/db/proxy/conf/opengauss/database-db.yaml @@ -18,7 +18,7 @@ databaseName: db dataSources: - ds_0: + db_0: url: jdbc:opengauss://opengauss.db.host:5432/db_0 username: test_user password: Test@123 @@ -27,7 +27,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_1: + db_1: url: jdbc:opengauss://opengauss.db.host:5432/db_1 username: test_user password: Test@123 @@ -36,7 +36,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_2: + db_2: url: jdbc:opengauss://opengauss.db.host:5432/db_2 username: test_user password: Test@123 @@ -45,7 +45,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_3: + db_3: url: jdbc:opengauss://opengauss.db.host:5432/db_3 username: test_user password: Test@123 @@ -54,7 +54,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_4: + db_4: url: jdbc:opengauss://opengauss.db.host:5432/db_4 username: test_user password: Test@123 @@ -63,7 +63,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_5: + db_5: url: jdbc:opengauss://opengauss.db.host:5432/db_5 username: test_user password: Test@123 @@ -72,7 +72,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_6: + db_6: url: jdbc:opengauss://opengauss.db.host:5432/db_6 username: test_user password: Test@123 @@ -81,7 +81,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_7: + db_7: url: jdbc:opengauss://opengauss.db.host:5432/db_7 username: test_user password: Test@123 @@ -90,7 +90,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_8: + db_8: url: jdbc:opengauss://opengauss.db.host:5432/db_8 username: test_user password: Test@123 @@ -99,7 +99,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_9: + db_9: url: jdbc:opengauss://opengauss.db.host:5432/db_9 username: test_user password: Test@123 @@ -116,13 +116,13 @@ rules: - !SHARDING tables: t_order: - actualDataNodes: ds_${0..9}.t_order + actualDataNodes: db_${0..9}.t_order databaseStrategy: standard: shardingColumn: user_id shardingAlgorithmName: it_standard_fixture t_order_item: - actualDataNodes: ds_${0..9}.t_order_item + actualDataNodes: db_${0..9}.t_order_item databaseStrategy: standard: shardingColumn: user_id @@ -135,7 +135,7 @@ rules: - auditor_constant allowHintDisable: true t_order_details: - actualDataNodes: ds_${0..9}.t_order_details + actualDataNodes: db_${0..9}.t_order_details databaseStrategy: standard: shardingColumn: user_id diff --git a/test/e2e/sql/src/test/resources/env/scenario/db/proxy/conf/postgresql/database-db.yaml b/test/e2e/sql/src/test/resources/env/scenario/db/proxy/conf/postgresql/database-db.yaml index 3e6c4fa3f2055..d0b75bd117b2a 100644 --- a/test/e2e/sql/src/test/resources/env/scenario/db/proxy/conf/postgresql/database-db.yaml +++ b/test/e2e/sql/src/test/resources/env/scenario/db/proxy/conf/postgresql/database-db.yaml @@ -18,7 +18,7 @@ databaseName: db dataSources: - ds_0: + db_0: url: jdbc:postgresql://postgresql.db.host:5432/db_0 username: test_user password: Test@123 @@ -27,7 +27,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_1: + db_1: url: jdbc:postgresql://postgresql.db.host:5432/db_1 username: test_user password: Test@123 @@ -36,7 +36,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_2: + db_2: url: jdbc:postgresql://postgresql.db.host:5432/db_2 username: test_user password: Test@123 @@ -45,7 +45,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_3: + db_3: url: jdbc:postgresql://postgresql.db.host:5432/db_3 username: test_user password: Test@123 @@ -54,7 +54,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_4: + db_4: url: jdbc:postgresql://postgresql.db.host:5432/db_4 username: test_user password: Test@123 @@ -63,7 +63,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_5: + db_5: url: jdbc:postgresql://postgresql.db.host:5432/db_5 username: test_user password: Test@123 @@ -72,7 +72,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_6: + db_6: url: jdbc:postgresql://postgresql.db.host:5432/db_6 username: test_user password: Test@123 @@ -81,7 +81,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_7: + db_7: url: jdbc:postgresql://postgresql.db.host:5432/db_7 username: test_user password: Test@123 @@ -90,7 +90,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_8: + db_8: url: jdbc:postgresql://postgresql.db.host:5432/db_8 username: test_user password: Test@123 @@ -99,7 +99,7 @@ dataSources: maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 2 - ds_9: + db_9: url: jdbc:postgresql://postgresql.db.host:5432/db_9 username: test_user password: Test@123 @@ -116,13 +116,13 @@ rules: - !SHARDING tables: t_order: - actualDataNodes: ds_${0..9}.t_order + actualDataNodes: db_${0..9}.t_order databaseStrategy: standard: shardingColumn: user_id shardingAlgorithmName: it_standard_fixture t_order_item: - actualDataNodes: ds_${0..9}.t_order_item + actualDataNodes: db_${0..9}.t_order_item databaseStrategy: standard: shardingColumn: user_id @@ -135,7 +135,7 @@ rules: - auditor_constant allowHintDisable: true t_order_details: - actualDataNodes: ds_${0..9}.t_order_details + actualDataNodes: db_${0..9}.t_order_details databaseStrategy: standard: shardingColumn: user_id diff --git a/test/e2e/sql/src/test/resources/env/scenario/mask/jdbc/conf/opengauss/rules.yaml b/test/e2e/sql/src/test/resources/env/scenario/mask/jdbc/conf/opengauss/rules.yaml index a508160a23cfb..709a13d8eeabc 100644 --- a/test/e2e/sql/src/test/resources/env/scenario/mask/jdbc/conf/opengauss/rules.yaml +++ b/test/e2e/sql/src/test/resources/env/scenario/mask/jdbc/conf/opengauss/rules.yaml @@ -18,7 +18,7 @@ databaseName: mask dataSources: - encrypt: + mask: url: jdbc:opengauss://opengauss.mask.host:5432/mask dataSourceClassName: com.zaxxer.hikari.HikariDataSource username: test_user diff --git a/test/e2e/sql/src/test/resources/env/scenario/mask/jdbc/conf/postgresql/rules.yaml b/test/e2e/sql/src/test/resources/env/scenario/mask/jdbc/conf/postgresql/rules.yaml index b079e6f1ef183..fc0f618858234 100644 --- a/test/e2e/sql/src/test/resources/env/scenario/mask/jdbc/conf/postgresql/rules.yaml +++ b/test/e2e/sql/src/test/resources/env/scenario/mask/jdbc/conf/postgresql/rules.yaml @@ -18,7 +18,7 @@ databaseName: mask dataSources: - encrypt: + mask: url: jdbc:postgresql://postgresql.mask.host:5432/mask dataSourceClassName: com.zaxxer.hikari.HikariDataSource username: test_user diff --git a/test/e2e/sql/src/test/resources/env/scenario/mask/proxy/conf/opengauss/database-mask.yaml b/test/e2e/sql/src/test/resources/env/scenario/mask/proxy/conf/opengauss/database-mask.yaml index 8b6ce8a098d0a..01bb0dbf34246 100644 --- a/test/e2e/sql/src/test/resources/env/scenario/mask/proxy/conf/opengauss/database-mask.yaml +++ b/test/e2e/sql/src/test/resources/env/scenario/mask/proxy/conf/opengauss/database-mask.yaml @@ -18,7 +18,7 @@ databaseName: mask dataSources: - encrypt: + mask: url: jdbc:opengauss://opengauss.mask.host:5432/mask username: test_user password: Test@123 diff --git a/test/e2e/sql/src/test/resources/env/scenario/mask/proxy/conf/postgresql/database-mask.yaml b/test/e2e/sql/src/test/resources/env/scenario/mask/proxy/conf/postgresql/database-mask.yaml index 01359c9c21ae8..d0a66469d6a08 100644 --- a/test/e2e/sql/src/test/resources/env/scenario/mask/proxy/conf/postgresql/database-mask.yaml +++ b/test/e2e/sql/src/test/resources/env/scenario/mask/proxy/conf/postgresql/database-mask.yaml @@ -18,7 +18,7 @@ databaseName: mask dataSources: - encrypt: + mask: url: jdbc:postgresql://postgresql.mask.host:5432/mask username: test_user password: Test@123