This is an automated email from the ASF dual-hosted git repository.

zhonghongsheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new a51f86179cd Merge scaling IT and IT suite's StorageContainerFactory 
(#19497)
a51f86179cd is described below

commit a51f86179cd7425958cdd4d28adcda0b7c8025ae
Author: Liang Zhang <[email protected]>
AuthorDate: Sun Jul 24 10:58:41 2022 +0800

    Merge scaling IT and IT suite's StorageContainerFactory (#19497)
---
 .../atomic/storage/StorageContainerFactory.java    |  9 ++--
 .../atomic/storage/impl/MySQLContainer.java        |  9 ++--
 .../atomic/storage/impl/OpenGaussContainer.java    |  9 ++--
 .../atomic/storage/impl/PostgreSQLContainer.java   |  9 ++--
 .../cases/general/CreateTableSQLGeneratorIT.java   |  4 +-
 .../pipeline/factory/DatabaseContainerFactory.java | 53 ----------------------
 .../container/compose/DockerComposedContainer.java |  4 +-
 .../compose/mode/ClusterComposedContainer.java     |  3 +-
 .../compose/mode/StandaloneComposedContainer.java  |  3 +-
 9 files changed, 22 insertions(+), 81 deletions(-)

diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/storage/StorageContainerFactory.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/storage/StorageContainerFactory.java
index a78e3a856c7..a132967c3a1 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/storage/StorageContainerFactory.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/storage/StorageContainerFactory.java
@@ -35,17 +35,18 @@ public final class StorageContainerFactory {
      * Create new instance of storage container.
      * 
      * @param databaseType database type
+     * @param dockerImageName docker image name
      * @param scenario scenario
      * @return created instance
      */
-    public static StorageContainer newInstance(final DatabaseType 
databaseType, final String scenario) {
+    public static StorageContainer newInstance(final DatabaseType 
databaseType, final String dockerImageName, final String scenario) {
         switch (databaseType.getType()) {
             case "MySQL":
-                return new MySQLContainer(scenario);
+                return new MySQLContainer(dockerImageName, scenario);
             case "PostgreSQL":
-                return new PostgreSQLContainer(scenario);
+                return new PostgreSQLContainer(dockerImageName, scenario);
             case "openGauss":
-                return new OpenGaussContainer(scenario);
+                return new OpenGaussContainer(dockerImageName, scenario);
             case "H2":
                 return new H2Container(scenario);
             default:
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/storage/impl/MySQLContainer.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/storage/impl/MySQLContainer.java
index 971cb3262ea..e8c4d1dad93 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/storage/impl/MySQLContainer.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/storage/impl/MySQLContainer.java
@@ -17,6 +17,7 @@
 
 package 
org.apache.shardingsphere.test.integration.env.container.atomic.storage.impl;
 
+import com.google.common.base.Strings;
 import org.apache.shardingsphere.infra.database.type.DatabaseTypeFactory;
 import 
org.apache.shardingsphere.test.integration.env.container.atomic.storage.DockerStorageContainer;
 import org.testcontainers.containers.BindMode;
@@ -28,12 +29,8 @@ import java.util.Optional;
  */
 public final class MySQLContainer extends DockerStorageContainer {
     
-    public MySQLContainer(final String scenario) {
-        super(DatabaseTypeFactory.getInstance("MySQL"), 
"mysql/mysql-server:5.7", scenario);
-    }
-    
-    public MySQLContainer(final String scenario, final String dockerImageName) 
{
-        super(DatabaseTypeFactory.getInstance("MySQL"), dockerImageName, 
scenario);
+    public MySQLContainer(final String dockerImageName, final String scenario) 
{
+        super(DatabaseTypeFactory.getInstance("MySQL"), 
Strings.isNullOrEmpty(dockerImageName) ? "mysql/mysql-server:5.7" : 
dockerImageName, scenario);
     }
     
     @Override
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/storage/impl/OpenGaussContainer.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/storage/impl/OpenGaussContainer.java
index 1acfff3ccfe..1bf94cd85bb 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/storage/impl/OpenGaussContainer.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/storage/impl/OpenGaussContainer.java
@@ -17,6 +17,7 @@
 
 package 
org.apache.shardingsphere.test.integration.env.container.atomic.storage.impl;
 
+import com.google.common.base.Strings;
 import org.apache.shardingsphere.infra.database.type.DatabaseTypeFactory;
 import 
org.apache.shardingsphere.test.integration.env.container.atomic.storage.DockerStorageContainer;
 import org.testcontainers.containers.BindMode;
@@ -28,12 +29,8 @@ import java.util.Optional;
  */
 public final class OpenGaussContainer extends DockerStorageContainer {
     
-    public OpenGaussContainer(final String scenario) {
-        super(DatabaseTypeFactory.getInstance("openGauss"), 
"enmotech/opengauss:3.0.0", scenario);
-    }
-    
-    public OpenGaussContainer(final String scenario, final String 
dockerImageName) {
-        super(DatabaseTypeFactory.getInstance("openGauss"), dockerImageName, 
scenario);
+    public OpenGaussContainer(final String dockerImageName, final String 
scenario) {
+        super(DatabaseTypeFactory.getInstance("openGauss"), 
Strings.isNullOrEmpty(dockerImageName) ? "enmotech/opengauss:3.0.0" : 
dockerImageName, scenario);
     }
     
     @Override
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/storage/impl/PostgreSQLContainer.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/storage/impl/PostgreSQLContainer.java
index 78906235e5b..226331d90eb 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/storage/impl/PostgreSQLContainer.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/storage/impl/PostgreSQLContainer.java
@@ -17,6 +17,7 @@
 
 package 
org.apache.shardingsphere.test.integration.env.container.atomic.storage.impl;
 
+import com.google.common.base.Strings;
 import org.apache.shardingsphere.infra.database.type.DatabaseTypeFactory;
 import 
org.apache.shardingsphere.test.integration.env.container.atomic.storage.DockerStorageContainer;
 import org.testcontainers.containers.BindMode;
@@ -28,12 +29,8 @@ import java.util.Optional;
  */
 public final class PostgreSQLContainer extends DockerStorageContainer {
     
-    public PostgreSQLContainer(final String scenario) {
-        super(DatabaseTypeFactory.getInstance("PostgreSQL"), 
"postgres:12-alpine", scenario);
-    }
-    
-    public PostgreSQLContainer(final String scenario, final String 
dockerImageName) {
-        super(DatabaseTypeFactory.getInstance("PostgreSQL"), dockerImageName, 
scenario);
+    public PostgreSQLContainer(final String dockerImageName, final String 
scenario) {
+        super(DatabaseTypeFactory.getInstance("PostgreSQL"), 
Strings.isNullOrEmpty(dockerImageName) ? "postgres:12-alpine" : 
dockerImageName, scenario);
     }
     
     @Override
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/general/CreateTableSQLGeneratorIT.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/general/CreateTableSQLGeneratorIT.java
index 46ad046e916..39bbbb6897c 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/general/CreateTableSQLGeneratorIT.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/general/CreateTableSQLGeneratorIT.java
@@ -28,9 +28,9 @@ import 
org.apache.shardingsphere.integration.data.pipeline.cases.entity.CreateTa
 import 
org.apache.shardingsphere.integration.data.pipeline.cases.entity.CreateTableSQLGeneratorOutputEntity;
 import 
org.apache.shardingsphere.integration.data.pipeline.env.IntegrationTestEnvironment;
 import 
org.apache.shardingsphere.integration.data.pipeline.env.enums.ScalingITEnvTypeEnum;
-import 
org.apache.shardingsphere.integration.data.pipeline.factory.DatabaseContainerFactory;
 import 
org.apache.shardingsphere.integration.data.pipeline.framework.param.ScalingParameterized;
 import 
org.apache.shardingsphere.test.integration.env.container.atomic.storage.DockerStorageContainer;
+import 
org.apache.shardingsphere.test.integration.env.container.atomic.storage.StorageContainerFactory;
 import 
org.apache.shardingsphere.test.integration.env.runtime.DataSourceEnvironment;
 import org.junit.After;
 import org.junit.Test;
@@ -81,7 +81,7 @@ public final class CreateTableSQLGeneratorIT {
         this.parameterized = parameterized;
         rootEntity = JAXB.unmarshal(
                 
Objects.requireNonNull(CreateTableSQLGeneratorIT.class.getClassLoader().getResource(parameterized.getScenario())),
 CreateTableSQLGeneratorAssertionsRootEntity.class);
-        storageContainer = 
DatabaseContainerFactory.newInstance(parameterized.getDatabaseType(), 
parameterized.getDockerImageName());
+        storageContainer = (DockerStorageContainer) 
StorageContainerFactory.newInstance(parameterized.getDatabaseType(), 
parameterized.getDockerImageName(), "");
         storageContainer.start();
     }
     
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/factory/DatabaseContainerFactory.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/factory/DatabaseContainerFactory.java
deleted file mode 100644
index e405f139c77..00000000000
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/factory/DatabaseContainerFactory.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.integration.data.pipeline.factory;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import 
org.apache.shardingsphere.test.integration.env.container.atomic.storage.DockerStorageContainer;
-import 
org.apache.shardingsphere.test.integration.env.container.atomic.storage.impl.MySQLContainer;
-import 
org.apache.shardingsphere.test.integration.env.container.atomic.storage.impl.OpenGaussContainer;
-import 
org.apache.shardingsphere.test.integration.env.container.atomic.storage.impl.PostgreSQLContainer;
-
-/**
- * Storage container factory.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class DatabaseContainerFactory {
-    
-    /**
-     * Create new instance of storage container.
-     *
-     * @param databaseType database type
-     * @param dockerImageName database image name
-     * @return created instance
-     */
-    public static DockerStorageContainer newInstance(final DatabaseType 
databaseType, final String dockerImageName) {
-        switch (databaseType.getType()) {
-            case "MySQL":
-                return new MySQLContainer("", dockerImageName);
-            case "PostgreSQL":
-                return new PostgreSQLContainer("", dockerImageName);
-            case "openGauss":
-                return new OpenGaussContainer("", dockerImageName);
-            default:
-                throw new RuntimeException(String.format("Database [%s] is 
unknown.", databaseType.getType()));
-        }
-    }
-}
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/framework/container/compose/DockerComposedContainer.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/framework/container/compose/DockerComposedContainer.java
index 34fea654c0d..1c617a8e185 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/framework/container/compose/DockerComposedContainer.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/framework/container/compose/DockerComposedContainer.java
@@ -19,11 +19,11 @@ package 
org.apache.shardingsphere.integration.data.pipeline.framework.container.
 
 import lombok.Getter;
 import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import 
org.apache.shardingsphere.integration.data.pipeline.factory.DatabaseContainerFactory;
 import 
org.apache.shardingsphere.integration.data.pipeline.framework.container.proxy.ShardingSphereProxyDockerContainer;
 import 
org.apache.shardingsphere.test.integration.env.container.atomic.governance.GovernanceContainer;
 import 
org.apache.shardingsphere.test.integration.env.container.atomic.governance.impl.ZookeeperContainer;
 import 
org.apache.shardingsphere.test.integration.env.container.atomic.storage.DockerStorageContainer;
+import 
org.apache.shardingsphere.test.integration.env.container.atomic.storage.StorageContainerFactory;
 import 
org.apache.shardingsphere.test.integration.env.runtime.DataSourceEnvironment;
 
 /**
@@ -41,7 +41,7 @@ public final class DockerComposedContainer extends 
BaseComposedContainer {
     public DockerComposedContainer(final DatabaseType databaseType, final 
String dockerImageName) {
         this.databaseType = databaseType;
         GovernanceContainer governanceContainer = 
getContainers().registerContainer(new ZookeeperContainer());
-        storageContainer = 
getContainers().registerContainer(DatabaseContainerFactory.newInstance(databaseType,
 dockerImageName));
+        storageContainer = 
getContainers().registerContainer((DockerStorageContainer) 
StorageContainerFactory.newInstance(databaseType, dockerImageName, ""));
         ShardingSphereProxyDockerContainer proxyContainer = new 
ShardingSphereProxyDockerContainer(databaseType);
         proxyContainer.dependsOn(governanceContainer, storageContainer);
         ShardingSphereProxyDockerContainer anotherProxyContainer = new 
ShardingSphereProxyDockerContainer(databaseType);
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/container/compose/mode/ClusterComposedContainer.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/container/compose/mode/ClusterComposedContainer.java
index c21e48197c5..81bee1a9ad6 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/container/compose/mode/ClusterComposedContainer.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/container/compose/mode/ClusterComposedContainer.java
@@ -49,7 +49,8 @@ public final class ClusterComposedContainer implements 
ComposedContainer {
         containers = new ITContainers(scenario);
         // TODO support other types of governance
         governanceContainer = 
containers.registerContainer(GovernanceContainerFactory.newInstance("ZooKeeper"));
-        storageContainer = 
containers.registerContainer(StorageContainerFactory.newInstance(parameterizedArray.getDatabaseType(),
 scenario));
+        // TODO add more version of databases
+        storageContainer = 
containers.registerContainer(StorageContainerFactory.newInstance(parameterizedArray.getDatabaseType(),
 "", scenario));
         AdapterContainer adapterContainer = 
AdapterContainerFactory.newInstance(
                 parameterizedArray.getMode(), parameterizedArray.getAdapter(), 
parameterizedArray.getDatabaseType(), storageContainer, scenario);
         if (adapterContainer instanceof DockerITContainer) {
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/container/compose/mode/StandaloneComposedContainer.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/container/compose/mode/StandaloneComposedContainer.java
index 340013f10da..c379f6dcdcd 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/container/compose/mode/StandaloneComposedContainer.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/container/compose/mode/StandaloneComposedContainer.java
@@ -43,7 +43,8 @@ public final class StandaloneComposedContainer implements 
ComposedContainer {
     public StandaloneComposedContainer(final ParameterizedArray 
parameterizedArray) {
         String scenario = parameterizedArray.getScenario();
         containers = new ITContainers(scenario);
-        storageContainer = 
containers.registerContainer(StorageContainerFactory.newInstance(parameterizedArray.getDatabaseType(),
 scenario));
+        // TODO add more version of databases
+        storageContainer = 
containers.registerContainer(StorageContainerFactory.newInstance(parameterizedArray.getDatabaseType(),
 "", scenario));
         adapterContainer = containers.registerContainer(
                 
AdapterContainerFactory.newInstance(parameterizedArray.getMode(), 
parameterizedArray.getAdapter(), parameterizedArray.getDatabaseType(), 
storageContainer, scenario));
         if (adapterContainer instanceof DockerITContainer) {

Reply via email to