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

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


The following commit(s) were added to refs/heads/master by this push:
     new 7c17a390814 Refactor : refactor the adaptor container in transaction 
IT with the one in ENV (#20248)
7c17a390814 is described below

commit 7c17a3908140d136e490fd1e861282e96603790d
Author: 孙念君 Nianjun Sun <[email protected]>
AuthorDate: Wed Aug 17 22:32:51 2022 +0800

    Refactor : refactor the adaptor container in transaction IT with the one in 
ENV (#20248)
    
    * Refactor : remove the useless storage container from transaction(#19957)
    
    * Refactor : use proxy cluster container from env module
    
    * Fix : fix a line too long issue
    
    * Fix : fix the datasource name for pg
    
    * Refactor : refactor the setCommand usage
    
    * Refactor : refactor the container command usage
    
    * Refactor : refactor the default database name for og and pg
    
    * Format : format a condition operation
---
 .../atomic/adapter/AdapterContainerFactory.java    |  3 +-
 .../atomic/storage/DockerStorageContainer.java     |  6 +-
 .../config/StorageContainerConfiguration.java      |  2 +-
 .../impl/h2/H2ContainerConfigurationFactory.java   |  2 +-
 .../mysql/MySQLContainerConfigurationFactory.java  |  8 +--
 .../OpenGaussContainerConfigurationFactory.java    |  6 +-
 .../PostgreSQLContainerConfigurationFactory.java   |  8 +--
 .../atomic/storage/impl/MySQLContainer.java        |  2 +-
 .../atomic/storage/impl/OpenGaussContainer.java    |  2 +-
 .../atomic/storage/impl/PostgreSQLContainer.java   |  2 +-
 .../factory/DatabaseContainerFactory.java          | 53 --------------
 .../container/compose/DockerComposedContainer.java | 15 ++--
 .../mysql/MySQLContainerConfigurationFactory.java  |  9 +--
 .../OpenGaussContainerConfigurationFactory.java    |  9 +--
 .../PostgreSQLContainerConfigurationFactory.java   |  8 +--
 ...ProxyClusterContainerConfigurationFactory.java} | 35 ++++------
 .../container/database/DatabaseContainer.java      | 72 -------------------
 .../container/database/MySQLContainer.java         | 80 ---------------------
 .../container/database/OpenGaussContainer.java     | 81 ----------------------
 .../container/database/PostgreSQLContainer.java    | 80 ---------------------
 20 files changed, 51 insertions(+), 432 deletions(-)

diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/adapter/AdapterContainerFactory.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/adapter/AdapterContainerFactory.java
index eeb4085593f..efab98a7438 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/adapter/AdapterContainerFactory.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/adapter/AdapterContainerFactory.java
@@ -47,7 +47,8 @@ public final class AdapterContainerFactory {
                                                final StorageContainer 
storageContainer, final String scenario, final AdaptorContainerConfiguration 
containerConfig) {
         switch (adapter) {
             case "proxy":
-                return "Cluster".equalsIgnoreCase(mode) ? new 
ShardingSphereProxyClusterContainer(databaseType, scenario, storageContainer, 
containerConfig)
+                return "Cluster".equalsIgnoreCase(mode)
+                        ? new 
ShardingSphereProxyClusterContainer(databaseType, scenario, storageContainer, 
containerConfig)
                         : new 
ShardingSphereProxyStandaloneContainer(databaseType, scenario);
             case "jdbc":
                 return new ShardingSphereJDBCContainer(storageContainer, 
scenario);
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/storage/DockerStorageContainer.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/storage/DockerStorageContainer.java
index aa76d1ec8da..f237ab0a356 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/storage/DockerStorageContainer.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/storage/DockerStorageContainer.java
@@ -79,10 +79,8 @@ public abstract class DockerStorageContainer extends 
DockerITContainer implement
                         : DataSourceEnvironment.getURL(databaseType, 
"localhost", getFirstMappedPort()), getUsername(), getUnifiedPassword())));
     }
     
-    protected final void setCommands(final String[] commands) {
-        for (String each : commands) {
-            setCommand(each);
-        }
+    protected final void setCommands(final String command) {
+        setCommand(command);
     }
     
     protected final void addEnvs(final Map<String, String> envs) {
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/storage/config/StorageContainerConfiguration.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/storage/config/StorageContainerConfiguration.java
index 5639657abcb..787bc3829ca 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/storage/config/StorageContainerConfiguration.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/storage/config/StorageContainerConfiguration.java
@@ -29,7 +29,7 @@ import java.util.Map;
 @Getter
 public class StorageContainerConfiguration {
     
-    private final String[] commands;
+    private final String containerCommand;
     
     private final Map<String, String> containerEnvironments;
     
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/storage/config/impl/h2/H2ContainerConfigurationFactory.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/storage/config/impl/h2/H2ContainerConfigurationFactory.java
index 5787edc75df..b45183e982d 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/storage/config/impl/h2/H2ContainerConfigurationFactory.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/storage/config/impl/h2/H2ContainerConfigurationFactory.java
@@ -35,6 +35,6 @@ public final class H2ContainerConfigurationFactory {
      * @return created instance
      */
     public static StorageContainerConfiguration newInstance() {
-        return new StorageContainerConfiguration(new String[0], 
Collections.emptyMap(), Collections.emptyMap());
+        return new StorageContainerConfiguration("", Collections.emptyMap(), 
Collections.emptyMap());
     }
 }
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/storage/config/impl/mysql/MySQLContainerConfigurationFactory.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/storage/config/impl/mysql/MySQLContainerConfigurationFactory.java
index 15de2c0a062..f7629edc874 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/storage/config/impl/mysql/MySQLContainerConfigurationFactory.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/storage/config/impl/mysql/MySQLContainerConfigurationFactory.java
@@ -38,13 +38,11 @@ public final class MySQLContainerConfigurationFactory {
      * @return created instance
      */
     public static StorageContainerConfiguration newInstance() {
-        return new StorageContainerConfiguration(getCommands(), 
getContainerEnvironments(), getMountedResources());
+        return new StorageContainerConfiguration(getCommand(), 
getContainerEnvironments(), getMountedResources());
     }
     
-    private static String[] getCommands() {
-        String[] result = new String[1];
-        result[0] = "--server-id=" + MySQLContainerUtil.generateServerId();
-        return result;
+    private static String getCommand() {
+        return "--server-id=" + MySQLContainerUtil.generateServerId();
     }
     
     private static Map<String, String> getContainerEnvironments() {
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/storage/config/impl/opengauss/OpenGaussContainerConfigurationFactory.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/storage/config/impl/opengauss/OpenGaussContainerConfigurationFactory.java
index 5659ad313a8..148bbb5323a 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/storage/config/impl/opengauss/OpenGaussContainerConfigurationFactory.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/storage/config/impl/opengauss/OpenGaussContainerConfigurationFactory.java
@@ -37,11 +37,11 @@ public final class OpenGaussContainerConfigurationFactory {
      * @return created instance
      */
     public static StorageContainerConfiguration newInstance() {
-        return new StorageContainerConfiguration(getCommands(), 
getContainerEnvironments(), getMountedResources());
+        return new StorageContainerConfiguration(getCommand(), 
getContainerEnvironments(), getMountedResources());
     }
     
-    private static String[] getCommands() {
-        return new String[0];
+    private static String getCommand() {
+        return "";
     }
     
     private static Map<String, String> getContainerEnvironments() {
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/storage/config/impl/postgresql/PostgreSQLContainerConfigurationFactory.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/storage/config/impl/postgresql/PostgreSQLContainerConfigurationFactory.java
index d3825132989..a171bef5201 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/storage/config/impl/postgresql/PostgreSQLContainerConfigurationFactory.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/storage/config/impl/postgresql/PostgreSQLContainerConfigurationFactory.java
@@ -36,13 +36,11 @@ public final class PostgreSQLContainerConfigurationFactory {
      * @return created instance
      */
     public static StorageContainerConfiguration newInstance() {
-        return new StorageContainerConfiguration(getCommands(), 
getContainerEnvironments(), getMountedResources());
+        return new StorageContainerConfiguration(getCommand(), 
getContainerEnvironments(), getMountedResources());
     }
     
-    private static String[] getCommands() {
-        String[] result = new String[1];
-        result[0] = "-c config_file=/etc/postgresql/postgresql.conf";
-        return result;
+    private static String getCommand() {
+        return "-c config_file=/etc/postgresql/postgresql.conf";
     }
     
     private static Map<String, String> getContainerEnvironments() {
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 a6ab669af19..36617eb7b31 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
@@ -38,7 +38,7 @@ public final class MySQLContainer extends 
DockerStorageContainer {
     
     @Override
     protected void configure() {
-        setCommands(storageContainerConfiguration.getCommands());
+        setCommands(storageContainerConfiguration.getContainerCommand());
         addEnvs(storageContainerConfiguration.getContainerEnvironments());
         mapResources(storageContainerConfiguration.getMountedResources());
         super.configure();
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 19c6ef3c3c6..caba1478c69 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
@@ -40,7 +40,7 @@ public final class OpenGaussContainer extends 
DockerStorageContainer {
     
     @Override
     protected void configure() {
-        setCommands(storageContainerConfiguration.getCommands());
+        setCommands(storageContainerConfiguration.getContainerCommand());
         addEnvs(storageContainerConfiguration.getContainerEnvironments());
         mapResources(storageContainerConfiguration.getMountedResources());
         withPrivilegedMode(true);
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 634f0941990..a2c503d2e04 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
@@ -38,7 +38,7 @@ public final class PostgreSQLContainer extends 
DockerStorageContainer {
     
     @Override
     protected void configure() {
-        setCommands(storageContainerConfiguration.getCommands());
+        setCommands(storageContainerConfiguration.getContainerCommand());
         addEnvs(storageContainerConfiguration.getContainerEnvironments());
         mapResources(storageContainerConfiguration.getMountedResources());
         super.configure();
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/factory/DatabaseContainerFactory.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/factory/DatabaseContainerFactory.java
deleted file mode 100644
index 668492bea47..00000000000
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/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.transaction.factory;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import 
org.apache.shardingsphere.integration.transaction.framework.container.database.DatabaseContainer;
-import 
org.apache.shardingsphere.integration.transaction.framework.container.database.MySQLContainer;
-import 
org.apache.shardingsphere.integration.transaction.framework.container.database.OpenGaussContainer;
-import 
org.apache.shardingsphere.integration.transaction.framework.container.database.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 ver
-     * @return created instance
-     */
-    public static DatabaseContainer 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-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/container/compose/DockerComposedContainer.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/container/compose/DockerComposedContainer.java
index ca98d809ad7..45ae77c1df0 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/container/compose/DockerComposedContainer.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/container/compose/DockerComposedContainer.java
@@ -23,9 +23,11 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.shardingsphere.infra.database.type.DatabaseType;
 import 
org.apache.shardingsphere.integration.transaction.engine.constants.TransactionTestConstants;
 import 
org.apache.shardingsphere.integration.transaction.framework.container.config.StorageContainerConfigurationFactory;
+import 
org.apache.shardingsphere.integration.transaction.framework.container.config.proxy.TransactionProxyClusterContainerConfigurationFactory;
 import 
org.apache.shardingsphere.integration.transaction.framework.container.jdbc.ShardingSphereJDBCContainer;
-import 
org.apache.shardingsphere.integration.transaction.framework.container.proxy.ShardingSphereProxyDockerContainer;
 import 
org.apache.shardingsphere.integration.transaction.framework.param.TransactionParameterized;
+import 
org.apache.shardingsphere.test.integration.env.container.atomic.adapter.AdapterContainerFactory;
+import 
org.apache.shardingsphere.test.integration.env.container.atomic.adapter.impl.ShardingSphereProxyClusterContainer;
 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;
@@ -45,7 +47,7 @@ public final class DockerComposedContainer extends 
BaseComposedContainer {
     
     private final GovernanceContainer governanceContainer;
     
-    private final ShardingSphereProxyDockerContainer proxyContainer;
+    private final ShardingSphereProxyClusterContainer proxyContainer;
     
     private final ShardingSphereJDBCContainer jdbcContainer;
     
@@ -57,12 +59,13 @@ public final class DockerComposedContainer extends 
BaseComposedContainer {
         storageContainer = 
getContainers().registerContainer((DockerStorageContainer) 
StorageContainerFactory.newInstance(databaseType, 
parameterized.getDockerImageName(), "",
                 
StorageContainerConfigurationFactory.newInstance(databaseType)));
         if 
(TransactionTestConstants.PROXY.equalsIgnoreCase(parameterized.getAdapter())) {
-            this.jdbcContainer = null;
-            ShardingSphereProxyDockerContainer proxyContainer = new 
ShardingSphereProxyDockerContainer(this.databaseType);
+            jdbcContainer = null;
+            proxyContainer = (ShardingSphereProxyClusterContainer) 
AdapterContainerFactory.newInstance("Cluster", "proxy", databaseType, 
storageContainer, "",
+                    
TransactionProxyClusterContainerConfigurationFactory.newInstance(databaseType));
             proxyContainer.dependsOn(governanceContainer, storageContainer);
-            this.proxyContainer = 
getContainers().registerContainer(proxyContainer);
+            getContainers().registerContainer(proxyContainer);
         } else {
-            this.proxyContainer = null;
+            proxyContainer = null;
             ShardingSphereJDBCContainer jdbcContainer = new 
ShardingSphereJDBCContainer(storageContainer,
                     
Objects.requireNonNull(ShardingSphereJDBCContainer.class.getClassLoader().getResource(getShardingSphereConfigResource(parameterized))).getFile());
             this.jdbcContainer = 
getContainers().registerContainer(jdbcContainer);
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/container/config/mysql/MySQLContainerConfigurationFactory.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/container/config/mysql/MySQLContainerConfigurationFactory.java
index 67dcbfd0be6..e0057a6903b 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/container/config/mysql/MySQLContainerConfigurationFactory.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/container/config/mysql/MySQLContainerConfigurationFactory.java
@@ -37,14 +37,11 @@ public final class MySQLContainerConfigurationFactory {
      * @return created instance
      */
     public static StorageContainerConfiguration newInstance() {
-        return new StorageContainerConfiguration(getCommands(), 
getContainerEnvironments(), getMountedResources());
+        return new StorageContainerConfiguration(getCommand(), 
getContainerEnvironments(), getMountedResources());
     }
     
-    private static String[] getCommands() {
-        String[] result = new String[2];
-        result[0] = "--sql_mode=";
-        result[1] = "--default-authentication-plugin=mysql_native_password";
-        return result;
+    private static String getCommand() {
+        return "--sql_mode= 
--default-authentication-plugin=mysql_native_password";
     }
     
     private static Map<String, String> getContainerEnvironments() {
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/container/config/opengauss/OpenGaussContainerConfigurationFactory.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/container/config/opengauss/OpenGaussContainerConfigurationFactory.java
index 2706ddbdaa1..c13c6484d95 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/container/config/opengauss/OpenGaussContainerConfigurationFactory.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/container/config/opengauss/OpenGaussContainerConfigurationFactory.java
@@ -36,14 +36,11 @@ public final class OpenGaussContainerConfigurationFactory {
      * @return created instance
      */
     public static StorageContainerConfiguration newInstance() {
-        return new StorageContainerConfiguration(getCommands(), 
getContainerEnvironments(), getMountedResources());
+        return new StorageContainerConfiguration(getCommand(), 
getContainerEnvironments(), getMountedResources());
     }
     
-    private static String[] getCommands() {
-        String[] result = new String[2];
-        result[0] = "--max_connections=600";
-        result[1] = "--max_prepared_transactions=600";
-        return result;
+    private static String getCommand() {
+        return "--max_connections=600 --max_prepared_transactions=600";
     }
     
     private static Map<String, String> getContainerEnvironments() {
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/container/config/postgresql/PostgreSQLContainerConfigurationFactory.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/container/config/postgresql/PostgreSQLContainerConfigurationFactory.java
index 4fb827fbee0..bfbe5fba910 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/container/config/postgresql/PostgreSQLContainerConfigurationFactory.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/container/config/postgresql/PostgreSQLContainerConfigurationFactory.java
@@ -37,13 +37,11 @@ public final class PostgreSQLContainerConfigurationFactory {
      * @return created instance
      */
     public static StorageContainerConfiguration newInstance() {
-        return new StorageContainerConfiguration(getCommands(), 
getContainerEnvironments(), getMountedResources());
+        return new StorageContainerConfiguration(getCommand(), 
getContainerEnvironments(), getMountedResources());
     }
     
-    private static String[] getCommands() {
-        String[] result = new String[1];
-        result[0] = "--max_connections=600 --max_prepared_transactions=600 
--wal_level=logical";
-        return result;
+    private static String getCommand() {
+        return "--max_connections=600 --max_prepared_transactions=600 
--wal_level=logical";
     }
     
     private static Map<String, String> getContainerEnvironments() {
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/storage/config/impl/mysql/MySQLContainerConfigurationFactory.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/container/config/proxy/TransactionProxyClusterContainerConfigurationFactory.java
similarity index 50%
copy from 
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/storage/config/impl/mysql/MySQLContainerConfigurationFactory.java
copy to 
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/container/config/proxy/TransactionProxyClusterContainerConfigurationFactory.java
index 15de2c0a062..6a752ef8cef 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/storage/config/impl/mysql/MySQLContainerConfigurationFactory.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/container/config/proxy/TransactionProxyClusterContainerConfigurationFactory.java
@@ -15,46 +15,41 @@
  * limitations under the License.
  */
 
-package 
org.apache.shardingsphere.test.integration.env.container.atomic.storage.config.impl.mysql;
+package 
org.apache.shardingsphere.integration.transaction.framework.container.config.proxy;
 
 import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
-import 
org.apache.shardingsphere.test.integration.env.container.atomic.storage.config.StorageContainerConfiguration;
-import 
org.apache.shardingsphere.test.integration.env.container.atomic.util.MySQLContainerUtil;
+import org.apache.shardingsphere.infra.database.type.DatabaseType;
+import 
org.apache.shardingsphere.test.integration.env.container.atomic.adapter.config.AdaptorContainerConfiguration;
+import 
org.apache.shardingsphere.test.integration.env.container.atomic.util.DatabaseTypeUtil;
 
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
 /**
- * MySQL container configuration factory.
+ * Transaction proxy cluster container configuration factory.
  */
 @NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class MySQLContainerConfigurationFactory {
+public final class TransactionProxyClusterContainerConfigurationFactory {
     
     /**
-     * Create new instance of MySQL container configuration.
+     * Create instance of adaptor container configuration.
      * 
+     * @param databaseType database type
      * @return created instance
      */
-    public static StorageContainerConfiguration newInstance() {
-        return new StorageContainerConfiguration(getCommands(), 
getContainerEnvironments(), getMountedResources());
+    public static AdaptorContainerConfiguration newInstance(final DatabaseType 
databaseType) {
+        return new 
AdaptorContainerConfiguration(getProxyDatasourceName(databaseType), 
getMountedResource(databaseType));
     }
     
-    private static String[] getCommands() {
-        String[] result = new String[1];
-        result[0] = "--server-id=" + MySQLContainerUtil.generateServerId();
-        return result;
+    private static String getProxyDatasourceName(final DatabaseType 
databaseType) {
+        return (DatabaseTypeUtil.isPostgreSQL(databaseType) || 
DatabaseTypeUtil.isOpenGauss(databaseType)) ? "postgres" : "";
     }
     
-    private static Map<String, String> getContainerEnvironments() {
+    private static Map<String, String> getMountedResource(final DatabaseType 
databaseType) {
         Map<String, String> result = new HashMap<>(2, 1);
-        result.put("LANG", "C.UTF-8");
-        result.put("MYSQL_RANDOM_ROOT_PASSWORD", "yes");
+        result.put(String.format("/env/%s/server.yaml", 
databaseType.getType().toLowerCase()), 
"/opt/shardingsphere-proxy/conf/server.yaml");
+        result.put("/logback-test.xml", 
"/opt/shardingsphere-proxy/conf/logback-test.xml");
         return result;
     }
-    
-    private static Map<String, String> getMountedResources() {
-        return Collections.singletonMap("/env/mysql/my.cnf", 
"/etc/mysql/my.cnf");
-    }
 }
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/container/database/DatabaseContainer.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/container/database/DatabaseContainer.java
deleted file mode 100644
index d01b8a84e8f..00000000000
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/container/database/DatabaseContainer.java
+++ /dev/null
@@ -1,72 +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.transaction.framework.container.database;
-
-import lombok.Getter;
-import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import 
org.apache.shardingsphere.test.integration.env.container.atomic.DockerITContainer;
-
-import javax.sql.DataSource;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-/**
- * Docker storage container.
- */
-@Getter
-public abstract class DatabaseContainer extends DockerITContainer {
-    
-    private final DatabaseType databaseType;
-    
-    private final Map<String, DataSource> actualDataSourceMap;
-    
-    public DatabaseContainer(final DatabaseType databaseType, final String 
dockerImageName) {
-        super(databaseType.getType().toLowerCase(), dockerImageName);
-        this.databaseType = databaseType;
-        actualDataSourceMap = new LinkedHashMap<>();
-    }
-    
-    /**
-     * Get jdbc url.
-     *
-     * @param databaseName database name
-     * @return jdbc url
-     */
-    public abstract String getJdbcUrl(String databaseName);
-    
-    /**
-     * Get database username.
-     *
-     * @return database username
-     */
-    public abstract String getUsername();
-    
-    /**
-     * Get database password.
-     *
-     * @return database password
-     */
-    public abstract String getPassword();
-    
-    /**
-     * Get database port.
-     *
-     * @return database port
-     */
-    public abstract int getPort();
-}
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/container/database/MySQLContainer.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/container/database/MySQLContainer.java
deleted file mode 100644
index 67afcafec25..00000000000
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/container/database/MySQLContainer.java
+++ /dev/null
@@ -1,80 +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.transaction.framework.container.database;
-
-import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
-import 
org.apache.shardingsphere.test.integration.env.container.wait.JDBCConnectionWaitStrategy;
-import 
org.apache.shardingsphere.test.integration.env.runtime.DataSourceEnvironment;
-import org.testcontainers.containers.BindMode;
-
-import java.sql.DriverManager;
-
-/**
- * MySQL container for Transaction IT.
- */
-public final class MySQLContainer extends DatabaseContainer {
-    
-    private static final DatabaseType DATABASE_TYPE = new MySQLDatabaseType();
-    
-    private final String username = "root";
-    
-    private final String password = "root";
-    
-    private final int port = 3306;
-    
-    public MySQLContainer(final String dockerImageName) {
-        super(DATABASE_TYPE, dockerImageName);
-    }
-    
-    @Override
-    protected void configure() {
-        withCommand("--sql_mode=", 
"--default-authentication-plugin=mysql_native_password");
-        addEnv("LANG", "C.UTF-8");
-        addEnv("MYSQL_ROOT_PASSWORD", password);
-        addEnv("MYSQL_ROOT_HOST", "%");
-        withClasspathResourceMapping("/env/mysql/my.cnf", "/etc/mysql/my.cnf", 
BindMode.READ_ONLY);
-        withExposedPorts(getPort());
-        setWaitStrategy(new JDBCConnectionWaitStrategy(() -> 
DriverManager.getConnection(DataSourceEnvironment.getURL(DATABASE_TYPE, 
"localhost", getFirstMappedPort()), username, password)));
-    }
-    
-    @Override
-    public String getJdbcUrl(final String databaseName) {
-        return DataSourceEnvironment.getURL(DATABASE_TYPE, getHost(), 
getFirstMappedPort(), databaseName);
-    }
-    
-    @Override
-    public String getUsername() {
-        return username;
-    }
-    
-    @Override
-    public String getPassword() {
-        return password;
-    }
-    
-    @Override
-    public int getPort() {
-        return port;
-    }
-    
-    @Override
-    public String getAbbreviation() {
-        return "mysql";
-    }
-}
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/container/database/OpenGaussContainer.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/container/database/OpenGaussContainer.java
deleted file mode 100644
index 9c7d82a6b79..00000000000
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/container/database/OpenGaussContainer.java
+++ /dev/null
@@ -1,81 +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.transaction.framework.container.database;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import 
org.apache.shardingsphere.infra.database.type.dialect.OpenGaussDatabaseType;
-import 
org.apache.shardingsphere.test.integration.env.container.wait.JDBCConnectionWaitStrategy;
-import 
org.apache.shardingsphere.test.integration.env.runtime.DataSourceEnvironment;
-import org.testcontainers.containers.BindMode;
-
-import java.sql.DriverManager;
-
-/**
- * OpenGauss container for Transaction IT.
- */
-public final class OpenGaussContainer extends DatabaseContainer {
-    
-    private static final DatabaseType DATABASE_TYPE = new 
OpenGaussDatabaseType();
-    
-    private final String username = "gaussdb";
-    
-    private final String password = "Root@123";
-    
-    private final int port = 5432;
-    
-    public OpenGaussContainer(final String dockerImageName) {
-        super(DATABASE_TYPE, dockerImageName);
-    }
-    
-    @Override
-    protected void configure() {
-        withCommand("--max_connections=600", 
"--max_prepared_transactions=600");
-        addEnv("GS_PASSWORD", password);
-        withClasspathResourceMapping("/env/postgresql/postgresql.conf", 
"/usr/local/opengauss/share/postgresql/postgresql.conf.sample", 
BindMode.READ_ONLY);
-        withPrivilegedMode(true);
-        withExposedPorts(port);
-        setWaitStrategy(new JDBCConnectionWaitStrategy(() -> 
DriverManager.getConnection(DataSourceEnvironment.getURL(DATABASE_TYPE, 
"localhost", getFirstMappedPort(), "postgres"),
-                username, password)));
-    }
-    
-    @Override
-    public String getJdbcUrl(final String databaseName) {
-        return DataSourceEnvironment.getURL(DATABASE_TYPE, getHost(), 
getFirstMappedPort(), StringUtils.isBlank(databaseName) ? "postgres" : 
databaseName);
-    }
-    
-    @Override
-    public String getUsername() {
-        return username;
-    }
-    
-    @Override
-    public String getPassword() {
-        return password;
-    }
-    
-    @Override
-    public int getPort() {
-        return port;
-    }
-    
-    @Override
-    public String getAbbreviation() {
-        return "opengauss";
-    }
-}
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/container/database/PostgreSQLContainer.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/container/database/PostgreSQLContainer.java
deleted file mode 100644
index ed822b676aa..00000000000
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/container/database/PostgreSQLContainer.java
+++ /dev/null
@@ -1,80 +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.transaction.framework.container.database;
-
-import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import 
org.apache.shardingsphere.infra.database.type.dialect.PostgreSQLDatabaseType;
-import 
org.apache.shardingsphere.test.integration.env.container.wait.JDBCConnectionWaitStrategy;
-import 
org.apache.shardingsphere.test.integration.env.runtime.DataSourceEnvironment;
-import org.testcontainers.containers.BindMode;
-
-import java.sql.DriverManager;
-
-/**
- * PostgreSQL container for Transaction IT.
- */
-public final class PostgreSQLContainer extends DatabaseContainer {
-    
-    private static final DatabaseType DATABASE_TYPE = new 
PostgreSQLDatabaseType();
-    
-    private final String username = "root";
-    
-    private final String password = "root";
-    
-    private final int port = 5432;
-    
-    public PostgreSQLContainer(final String dockerImageName) {
-        super(DATABASE_TYPE, dockerImageName);
-    }
-    
-    @Override
-    protected void configure() {
-        withCommand("--max_connections=600 --max_prepared_transactions=600 
--wal_level=logical");
-        addEnv("POSTGRES_USER", username);
-        addEnv("POSTGRES_PASSWORD", password);
-        withClasspathResourceMapping("/env/postgresql/postgresql.conf", 
"/etc/postgresql/postgresql.conf", BindMode.READ_ONLY);
-        withExposedPorts(port);
-        setWaitStrategy(new JDBCConnectionWaitStrategy(() -> 
DriverManager.getConnection(DataSourceEnvironment.getURL(DATABASE_TYPE, 
"localhost", getFirstMappedPort(), "postgres"),
-                username, password)));
-    }
-    
-    @Override
-    public String getJdbcUrl(final String databaseName) {
-        return DataSourceEnvironment.getURL(DATABASE_TYPE, getHost(), 
getFirstMappedPort(), databaseName);
-    }
-    
-    @Override
-    public String getUsername() {
-        return username;
-    }
-    
-    @Override
-    public String getPassword() {
-        return password;
-    }
-    
-    @Override
-    public int getPort() {
-        return port;
-    }
-    
-    @Override
-    public String getAbbreviation() {
-        return "postgresql";
-    }
-}

Reply via email to