You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by du...@apache.org on 2022/09/06 23:57:07 UTC

[shardingsphere] branch master updated: Refactor : extract and refactor the datasource creation in IT module (#20825)

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

duanzhengqiang 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 48e91f64eb6 Refactor : extract and refactor the datasource creation in IT module (#20825)
48e91f64eb6 is described below

commit 48e91f64eb6be03e038af384a6f56f16e853e8e9
Author: 孙念君 Nianjun Sun <su...@sphere-ex.com>
AuthorDate: Wed Sep 7 07:57:00 2022 +0800

    Refactor : extract and refactor the datasource creation in IT module (#20825)
    
    * Refactor : extract and refactor the datasource creation in IT module
    
    * Merge : merge the change from other PR.
---
 .../impl/ShardingSphereProxyClusterContainer.java  | 16 +++----------
 .../ShardingSphereProxyStandaloneContainer.java    | 16 +++----------
 .../atomic/storage/DockerStorageContainer.java     | 13 +++-------
 .../atomic/storage/EmbeddedStorageContainer.java   | 19 ++++-----------
 .../atomic/storage/impl/OpenGaussContainer.java    |  5 ++--
 .../container/atomic/util/DatabaseTypeUtil.java    | 28 +++++++++++-----------
 .../atomic/util/StorageContainerUtil.java          | 15 +++++++++++-
 .../data/pipeline/cases/base/BaseITCase.java       | 17 +++----------
 .../transaction/engine/base/BaseITCase.java        | 14 +++--------
 9 files changed, 50 insertions(+), 93 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/impl/ShardingSphereProxyClusterContainer.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/adapter/impl/ShardingSphereProxyClusterContainer.java
index d669455b864..340db81849d 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/adapter/impl/ShardingSphereProxyClusterContainer.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/adapter/impl/ShardingSphereProxyClusterContainer.java
@@ -17,12 +17,12 @@
 
 package org.apache.shardingsphere.test.integration.env.container.atomic.adapter.impl;
 
-import com.zaxxer.hikari.HikariDataSource;
 import org.apache.shardingsphere.infra.database.type.DatabaseType;
 import org.apache.shardingsphere.test.integration.env.container.atomic.DockerITContainer;
 import org.apache.shardingsphere.test.integration.env.container.atomic.adapter.AdapterContainer;
 import org.apache.shardingsphere.test.integration.env.container.atomic.adapter.config.AdaptorContainerConfiguration;
 import org.apache.shardingsphere.test.integration.env.container.atomic.constants.ProxyContainerConstants;
+import org.apache.shardingsphere.test.integration.env.container.atomic.util.StorageContainerUtil;
 import org.apache.shardingsphere.test.integration.env.container.wait.JdbcConnectionWaitStrategy;
 import org.apache.shardingsphere.test.integration.env.runtime.DataSourceEnvironment;
 import org.testcontainers.containers.BindMode;
@@ -79,22 +79,12 @@ public final class ShardingSphereProxyClusterContainer extends DockerITContainer
     public DataSource getTargetDataSource(final String serverLists) {
         DataSource dataSource = targetDataSourceProvider.get();
         if (Objects.isNull(dataSource)) {
-            targetDataSourceProvider.set(createProxyDataSource());
+            targetDataSourceProvider.set(StorageContainerUtil.generateDataSource(DataSourceEnvironment.getURL(databaseType, getHost(), getMappedPort(3307), config.getProxyDataSourceName()),
+                    ProxyContainerConstants.USERNAME, ProxyContainerConstants.PASSWORD));
         }
         return targetDataSourceProvider.get();
     }
     
-    private DataSource createProxyDataSource() {
-        HikariDataSource result = new HikariDataSource();
-        result.setDriverClassName(DataSourceEnvironment.getDriverClassName(databaseType));
-        result.setJdbcUrl(DataSourceEnvironment.getURL(databaseType, getHost(), getMappedPort(3307), config.getProxyDataSourceName()));
-        result.setUsername(ProxyContainerConstants.USERNAME);
-        result.setPassword(ProxyContainerConstants.PASSWORD);
-        result.setMaximumPoolSize(2);
-        result.setTransactionIsolation("TRANSACTION_READ_COMMITTED");
-        return result;
-    }
-    
     @Override
     public String getAbbreviation() {
         return ProxyContainerConstants.PROXY_CONTAINER_ABBREVIATION;
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/adapter/impl/ShardingSphereProxyStandaloneContainer.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/adapter/impl/ShardingSphereProxyStandaloneContainer.java
index a9474b79d7e..2fa5aa255f3 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/adapter/impl/ShardingSphereProxyStandaloneContainer.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/adapter/impl/ShardingSphereProxyStandaloneContainer.java
@@ -17,13 +17,13 @@
 
 package org.apache.shardingsphere.test.integration.env.container.atomic.adapter.impl;
 
-import com.zaxxer.hikari.HikariDataSource;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.shardingsphere.infra.database.type.DatabaseType;
 import org.apache.shardingsphere.test.integration.env.container.atomic.DockerITContainer;
 import org.apache.shardingsphere.test.integration.env.container.atomic.adapter.AdapterContainer;
 import org.apache.shardingsphere.test.integration.env.container.atomic.adapter.config.AdaptorContainerConfiguration;
 import org.apache.shardingsphere.test.integration.env.container.atomic.constants.ProxyContainerConstants;
+import org.apache.shardingsphere.test.integration.env.container.atomic.util.StorageContainerUtil;
 import org.apache.shardingsphere.test.integration.env.container.wait.JdbcConnectionWaitStrategy;
 import org.apache.shardingsphere.test.integration.env.runtime.DataSourceEnvironment;
 import org.testcontainers.containers.BindMode;
@@ -81,22 +81,12 @@ public final class ShardingSphereProxyStandaloneContainer extends DockerITContai
     public DataSource getTargetDataSource(final String serverLists) {
         DataSource dataSource = targetDataSourceProvider.get();
         if (Objects.isNull(dataSource)) {
-            targetDataSourceProvider.set(createProxyDataSource());
+            targetDataSourceProvider.set(StorageContainerUtil.generateDataSource(DataSourceEnvironment.getURL(databaseType, getHost(), getMappedPort(3307), config.getProxyDataSourceName()),
+                    ProxyContainerConstants.USERNAME, ProxyContainerConstants.PASSWORD));
         }
         return targetDataSourceProvider.get();
     }
     
-    private DataSource createProxyDataSource() {
-        HikariDataSource result = new HikariDataSource();
-        result.setDriverClassName(DataSourceEnvironment.getDriverClassName(databaseType));
-        result.setJdbcUrl(DataSourceEnvironment.getURL(databaseType, getHost(), getMappedPort(3307), config.getProxyDataSourceName()));
-        result.setUsername(ProxyContainerConstants.USERNAME);
-        result.setPassword(ProxyContainerConstants.PASSWORD);
-        result.setMaximumPoolSize(2);
-        result.setTransactionIsolation("TRANSACTION_READ_COMMITTED");
-        return result;
-    }
-    
     @Override
     public String getAbbreviation() {
         return ProxyContainerConstants.PROXY_CONTAINER_ABBREVIATION;
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 cfd7d5b2f76..587477fe52c 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
@@ -18,7 +18,6 @@
 package org.apache.shardingsphere.test.integration.env.container.atomic.storage;
 
 import com.google.common.base.Strings;
-import com.zaxxer.hikari.HikariDataSource;
 import lombok.AccessLevel;
 import lombok.Getter;
 import lombok.SneakyThrows;
@@ -27,6 +26,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.apache.shardingsphere.infra.database.type.DatabaseType;
 import org.apache.shardingsphere.test.integration.env.container.atomic.DockerITContainer;
 import org.apache.shardingsphere.test.integration.env.container.atomic.constants.StorageContainerConstants;
+import org.apache.shardingsphere.test.integration.env.container.atomic.util.StorageContainerUtil;
 import org.apache.shardingsphere.test.integration.env.container.wait.JdbcConnectionWaitStrategy;
 import org.apache.shardingsphere.test.integration.env.runtime.DataSourceEnvironment;
 import org.apache.shardingsphere.test.integration.env.runtime.scenario.database.DatabaseEnvironmentManager;
@@ -115,14 +115,7 @@ public abstract class DockerStorageContainer extends DockerITContainer implement
      * @return access data source
      */
     public DataSource createAccessDataSource(final String dataSourceName) {
-        HikariDataSource result = new HikariDataSource();
-        result.setDriverClassName(DataSourceEnvironment.getDriverClassName(databaseType));
-        result.setJdbcUrl(getJdbcUrl(dataSourceName));
-        result.setUsername(getUsername());
-        result.setPassword(getPassword());
-        result.setMaximumPoolSize(4);
-        result.setTransactionIsolation("TRANSACTION_READ_COMMITTED");
-        return result;
+        return StorageContainerUtil.generateDataSource(getJdbcUrl(dataSourceName), getUsername(), getPassword(), 4);
     }
     
     /**
@@ -132,7 +125,7 @@ public abstract class DockerStorageContainer extends DockerITContainer implement
      * @return JDBC URL
      */
     public String getJdbcUrl(final String dataSourceName) {
-        return DataSourceEnvironment.getURL(databaseType, getHost(), getMappedPort(getExposedPort()), dataSourceName);
+        return DataSourceEnvironment.getURL(databaseType, getHost(), getMappedPort(), dataSourceName);
     }
     
     protected abstract Optional<String> getDefaultDatabaseName();
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/storage/EmbeddedStorageContainer.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/storage/EmbeddedStorageContainer.java
index a66943d4ef3..ca59d43ea75 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/storage/EmbeddedStorageContainer.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/storage/EmbeddedStorageContainer.java
@@ -17,11 +17,11 @@
 
 package org.apache.shardingsphere.test.integration.env.container.atomic.storage;
 
-import com.zaxxer.hikari.HikariDataSource;
 import lombok.Getter;
 import lombok.SneakyThrows;
 import org.apache.shardingsphere.infra.database.type.DatabaseType;
 import org.apache.shardingsphere.test.integration.env.container.atomic.EmbeddedITContainer;
+import org.apache.shardingsphere.test.integration.env.container.atomic.util.StorageContainerUtil;
 import org.apache.shardingsphere.test.integration.env.runtime.DataSourceEnvironment;
 import org.apache.shardingsphere.test.integration.env.runtime.scenario.database.DatabaseEnvironmentManager;
 
@@ -57,7 +57,8 @@ public abstract class EmbeddedStorageContainer implements EmbeddedITContainer, S
     private Map<String, DataSource> createActualDataSourceMap() {
         Collection<String> databaseNames = DatabaseEnvironmentManager.getDatabaseNames(scenario);
         Map<String, DataSource> result = new LinkedHashMap<>(databaseNames.size(), 1);
-        databaseNames.forEach(each -> result.put(each, createDataSource(each)));
+        databaseNames.forEach(each -> result.put(each, StorageContainerUtil.generateDataSource(DataSourceEnvironment.getURL(databaseType, null, 0, scenario + each),
+                "root", "Root@123")));
         return result;
     }
     
@@ -65,18 +66,8 @@ public abstract class EmbeddedStorageContainer implements EmbeddedITContainer, S
     private Map<String, DataSource> createExpectedDataSourceMap() {
         Collection<String> databaseNames = DatabaseEnvironmentManager.getExpectedDatabaseNames(scenario);
         Map<String, DataSource> result = new LinkedHashMap<>(databaseNames.size(), 1);
-        databaseNames.forEach(each -> result.put(each, createDataSource(each)));
-        return result;
-    }
-    
-    private DataSource createDataSource(final String dataSourceName) {
-        HikariDataSource result = new HikariDataSource();
-        result.setDriverClassName(DataSourceEnvironment.getDriverClassName(databaseType));
-        result.setJdbcUrl(DataSourceEnvironment.getURL(databaseType, null, 0, scenario + dataSourceName));
-        result.setUsername("root");
-        result.setPassword("Root@123");
-        result.setMaximumPoolSize(4);
-        result.setTransactionIsolation("TRANSACTION_READ_COMMITTED");
+        databaseNames.forEach(each -> result.put(each, StorageContainerUtil.generateDataSource(DataSourceEnvironment.getURL(databaseType, null, 0, scenario + each),
+                "root", "Root@123")));
         return result;
     }
     
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 ad72020d496..8b8f553e2c7 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
@@ -55,7 +55,7 @@ public final class OpenGaussContainer extends DockerStorageContainer {
     
     @Override
     public int getMappedPort() {
-        return this.getMappedPort(StorageContainerConstants.OPENGAUSS_EXPOSED_PORT);
+        return getMappedPort(StorageContainerConstants.OPENGAUSS_EXPOSED_PORT);
     }
     
     @Override
@@ -65,7 +65,6 @@ public final class OpenGaussContainer extends DockerStorageContainer {
     
     @Override
     public String getJdbcUrl(final String dataSourceName) {
-        return DataSourceEnvironment.getURL(getDatabaseType(), getHost(),
-                getMappedPort(getExposedPort()), StringUtils.isNotEmpty(dataSourceName) ? dataSourceName : StorageContainerConstants.USERNAME);
+        return DataSourceEnvironment.getURL(getDatabaseType(), getHost(), getMappedPort(), StringUtils.isNotEmpty(dataSourceName) ? dataSourceName : StorageContainerConstants.USERNAME);
     }
 }
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/util/DatabaseTypeUtil.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/util/DatabaseTypeUtil.java
index 083a87be310..682a13f3ac5 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/util/DatabaseTypeUtil.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/util/DatabaseTypeUtil.java
@@ -38,20 +38,6 @@ public final class DatabaseTypeUtil {
         return databaseType instanceof MySQLDatabaseType;
     }
     
-    /**
-     * Get docker image major version.
-     *
-     * @param dockerImageName dockerImageName
-     * @return major version
-     */
-    public static String parseMajorVersion(final String dockerImageName) {
-        if (StringUtils.isBlank(dockerImageName)) {
-            return "";
-        }
-        String version = dockerImageName.split(":")[1];
-        return version.split("\\.")[0];
-    }
-    
     /**
      * Check PostgreSQL database type.
      *
@@ -71,4 +57,18 @@ public final class DatabaseTypeUtil {
     public static boolean isOpenGauss(final DatabaseType databaseType) {
         return databaseType instanceof OpenGaussDatabaseType;
     }
+    
+    /**
+     * Get docker image major version.
+     *
+     * @param dockerImageName dockerImageName
+     * @return major version
+     */
+    public static String parseMajorVersion(final String dockerImageName) {
+        if (StringUtils.isBlank(dockerImageName)) {
+            return "";
+        }
+        String version = dockerImageName.split(":")[1];
+        return version.split("\\.")[0];
+    }
 }
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/util/StorageContainerUtil.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/util/StorageContainerUtil.java
index ce79def9573..e86e494165b 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/util/StorageContainerUtil.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/util/StorageContainerUtil.java
@@ -41,13 +41,26 @@ public final class StorageContainerUtil {
      * @return data source
      */
     public static DataSource generateDataSource(final String jdbcUrl, final String username, final String password) {
+        return generateDataSource(jdbcUrl, username, password, 2);
+    }
+    
+    /**
+     * Generate datasource. 
+     *
+     * @param jdbcUrl JDBC URL for generating datasource
+     * @param username username
+     * @param password password
+     * @param maximumPoolSize maximum pool size
+     * @return data source
+     */
+    public static DataSource generateDataSource(final String jdbcUrl, final String username, final String password, final int maximumPoolSize) {
         DatabaseType databaseType = DatabaseTypeEngine.getDatabaseType(jdbcUrl);
         HikariDataSource result = new HikariDataSource();
         result.setDriverClassName(DataSourceEnvironment.getDriverClassName(databaseType));
         result.setJdbcUrl(jdbcUrl);
         result.setUsername(username);
         result.setPassword(password);
-        result.setMaximumPoolSize(2);
+        result.setMaximumPoolSize(maximumPoolSize);
         result.setTransactionIsolation("TRANSACTION_READ_COMMITTED");
         return result;
     }
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/base/BaseITCase.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/base/BaseITCase.java
index 9657400c34e..40cd2c1e3cc 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/base/BaseITCase.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/base/BaseITCase.java
@@ -17,7 +17,6 @@
 
 package org.apache.shardingsphere.integration.data.pipeline.cases.base;
 
-import com.zaxxer.hikari.HikariDataSource;
 import lombok.AccessLevel;
 import lombok.Getter;
 import lombok.Setter;
@@ -36,6 +35,7 @@ import org.apache.shardingsphere.integration.data.pipeline.framework.watcher.Sca
 import org.apache.shardingsphere.test.integration.env.container.atomic.constants.ProxyContainerConstants;
 import org.apache.shardingsphere.test.integration.env.container.atomic.storage.DockerStorageContainer;
 import org.apache.shardingsphere.test.integration.env.container.atomic.util.DatabaseTypeUtil;
+import org.apache.shardingsphere.test.integration.env.container.atomic.util.StorageContainerUtil;
 import org.apache.shardingsphere.test.integration.env.runtime.DataSourceEnvironment;
 import org.junit.Rule;
 import org.opengauss.util.PSQLException;
@@ -152,19 +152,8 @@ public abstract class BaseITCase {
         } catch (final SQLException ex) {
             throw new IllegalStateException(ex);
         }
-        sourceDataSource = getDataSource(getActualJdbcUrlTemplate(DS_0, false), username, password);
-        proxyDataSource = getDataSource(containerComposer.getProxyJdbcUrl(PROXY_DATABASE), ProxyContainerConstants.USERNAME, ProxyContainerConstants.PASSWORD);
-    }
-    
-    private DataSource getDataSource(final String jdbcUrl, final String username, final String password) {
-        HikariDataSource result = new HikariDataSource();
-        result.setDriverClassName(DataSourceEnvironment.getDriverClassName(getDatabaseType()));
-        result.setJdbcUrl(jdbcUrl);
-        result.setUsername(username);
-        result.setPassword(password);
-        result.setMaximumPoolSize(2);
-        result.setTransactionIsolation("TRANSACTION_READ_COMMITTED");
-        return result;
+        sourceDataSource = StorageContainerUtil.generateDataSource(getActualJdbcUrlTemplate(DS_0, false), username, password);
+        proxyDataSource = StorageContainerUtil.generateDataSource(containerComposer.getProxyJdbcUrl(PROXY_DATABASE), ProxyContainerConstants.USERNAME, ProxyContainerConstants.PASSWORD);
     }
     
     protected void addResource(final String distSQL) throws SQLException {
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/base/BaseITCase.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/base/BaseITCase.java
index 885232a7139..71f21f8a48c 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/base/BaseITCase.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/base/BaseITCase.java
@@ -17,7 +17,6 @@
 
 package org.apache.shardingsphere.integration.transaction.engine.base;
 
-import com.zaxxer.hikari.HikariDataSource;
 import lombok.AccessLevel;
 import lombok.Getter;
 import lombok.SneakyThrows;
@@ -43,6 +42,7 @@ import org.apache.shardingsphere.integration.transaction.framework.param.Transac
 import org.apache.shardingsphere.integration.transaction.util.TestCaseClassScanner;
 import org.apache.shardingsphere.test.integration.env.container.atomic.storage.DockerStorageContainer;
 import org.apache.shardingsphere.test.integration.env.container.atomic.util.DatabaseTypeUtil;
+import org.apache.shardingsphere.test.integration.env.container.atomic.util.StorageContainerUtil;
 import org.apache.shardingsphere.test.integration.env.runtime.DataSourceEnvironment;
 import org.apache.shardingsphere.transaction.core.TransactionType;
 
@@ -137,16 +137,8 @@ public abstract class BaseITCase {
     }
     
     private DataSource createDataSource(final DockerStorageContainer databaseContainer, final String dataSourceName) {
-        HikariDataSource result = new HikariDataSource();
-        result.setDriverClassName(DataSourceEnvironment.getDriverClassName(databaseType));
-        result.setJdbcUrl(DataSourceEnvironment.getURL(databaseType, databaseContainer.getHost(), databaseContainer.getMappedPort(databaseContainer.getExposedPort()), dataSourceName));
-        result.setUsername(databaseContainer.getUsername());
-        result.setPassword(databaseContainer.getPassword());
-        result.setMaximumPoolSize(50);
-        result.setIdleTimeout(60000);
-        result.setMaxLifetime(1800000);
-        result.setTransactionIsolation("TRANSACTION_READ_COMMITTED");
-        return result;
+        return StorageContainerUtil.generateDataSource(DataSourceEnvironment.getURL(databaseType, databaseContainer.getHost(), databaseContainer.getMappedPort(), dataSourceName),
+                databaseContainer.getUsername(), databaseContainer.getPassword(), 50);
     }
     
     protected boolean isProxyAdapter(final TransactionParameterized parameterized) {