This is an automated email from the ASF dual-hosted git repository.
panjuan 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 7d0c633de85 Refactor : refactor the env module for further cluster
container refactor. (#20790)
7d0c633de85 is described below
commit 7d0c633de85dd3323153a1795ac16e38be5140a8
Author: 孙念君 Nianjun Sun <[email protected]>
AuthorDate: Mon Sep 5 15:19:10 2022 +0800
Refactor : refactor the env module for further cluster container refactor.
(#20790)
* Add : add new util to generate random port for storage container
* Refactor : refactor the util to get available port for storage container
* Refactor : add mapped port for further refactor
---
.../queryable/ConvertYamlConfigurationHandler.java | 2 +-
.../ConvertYamlConfigurationHandlerTest.java | 14 ++++-----
.../constants/StorageContainerConstants.java | 6 ++++
.../atomic/storage/DockerStorageContainer.java | 33 +++++++++++++---------
.../atomic/storage/impl/MySQLContainer.java | 10 +++++--
.../atomic/storage/impl/OpenGaussContainer.java | 12 ++++++--
.../atomic/storage/impl/PostgreSQLContainer.java | 10 +++++--
.../test/integration/ha/cases/base/BaseITCase.java | 2 +-
.../data/pipeline/cases/base/BaseITCase.java | 4 +--
.../pipeline/env/IntegrationTestEnvironment.java | 7 +++--
.../transaction/engine/base/BaseITCase.java | 8 +++---
.../env/IntegrationTestEnvironment.java | 6 ++--
12 files changed, 73 insertions(+), 41 deletions(-)
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationHandler.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationHandler.java
index 2ad70f4fa71..26c1bf17519 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationHandler.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationHandler.java
@@ -564,7 +564,7 @@ public final class ConvertYamlConfigurationHandler extends
QueryableRALBackendHa
}
return result.toString();
}
-
+
private String getQueryWithCipher(final Boolean queryWithCipherColumn,
final YamlRuleConfiguration ruleConfig) {
StringBuilder result = new StringBuilder();
if (null != queryWithCipherColumn) {
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationHandlerTest.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationHandlerTest.java
index 042158d996b..630fc3daaeb 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationHandlerTest.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationHandlerTest.java
@@ -53,7 +53,7 @@ public final class ConvertYamlConfigurationHandlerTest
extends ProxyContextResto
private final String readWriteSplittingFilePath =
"/conf/convert/config-readwrite-splitting.yaml";
private final String databaseDiscoveryFilePath =
"/conf/convert/config-database-discovery.yaml";
-
+
private final String encryptFilePath = "/conf/convert/config-encrypt.yaml";
private final String resourceExpectedFilePath =
"/expected/convert-add-resource.yaml";
@@ -63,7 +63,7 @@ public final class ConvertYamlConfigurationHandlerTest
extends ProxyContextResto
private final String readWriteSplittingExpectedFilePath =
"/expected/convert-readwrite-splitting.yaml";
private final String databaseDiscoveryExpectedFilePath =
"/expected/convert-database-discovery.yaml";
-
+
private final String encryptExpectedFilePath =
"/expected/convert-create-encrypt.yaml";
private final String resource = "resource";
@@ -71,11 +71,11 @@ public final class ConvertYamlConfigurationHandlerTest
extends ProxyContextResto
private final String sharding = "sharding";
private final String readWriteSplitting = "readWriteSplitting";
-
+
private final String databaseDiscovery = "databaseDiscovery";
-
+
private final String encrypt = "encrypt";
-
+
private final Map<String, String> featureMap = new HashMap<>(5, 1);
@Before
@@ -112,12 +112,12 @@ public final class ConvertYamlConfigurationHandlerTest
extends ProxyContextResto
public void assertExecuteWithCreateDatabaseDiscovery() throws SQLException
{
assertExecute(databaseDiscovery, databaseDiscoveryExpectedFilePath);
}
-
+
@Test
public void assertExecuteWithCreateEncrypt() throws SQLException {
assertExecute(encrypt, encryptExpectedFilePath);
}
-
+
public void assertExecute(final String type, final String
expectedFilePath) throws SQLException {
ConvertYamlConfigurationHandler handler = new
ConvertYamlConfigurationHandler();
handler.init(new
ConvertYamlConfigurationStatement(Objects.requireNonNull(ConvertYamlConfigurationHandlerTest.class.getResource(featureMap.get(type))).getPath()),
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/constants/StorageContainerConstants.java
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/constants/StorageContainerConstants.java
index 1fc59949727..3d49a445c85 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/constants/StorageContainerConstants.java
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/constants/StorageContainerConstants.java
@@ -26,6 +26,12 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class StorageContainerConstants {
+ public static final int MYSQL_EXPOSED_PORT = 3306;
+
+ public static final int POSTGRESQL_EXPOSED_PORT = 5432;
+
+ public static final int OPENGAUSS_EXPOSED_PORT = 5432;
+
public static final String USERNAME = "test_user";
public static final String PASSWORD = "Test@123";
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 ded554f7450..a2e1348d7a4 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
@@ -76,11 +76,11 @@ public abstract class DockerStorageContainer extends
DockerITContainer implement
withClasspathResourceMapping(new
ScenarioDataPath(scenario).getInitSQLResourcePath(Type.ACTUAL, databaseType),
"/docker-entrypoint-initdb.d/", BindMode.READ_ONLY);
withClasspathResourceMapping(new
ScenarioDataPath(scenario).getInitSQLResourcePath(Type.EXPECTED, databaseType),
"/docker-entrypoint-initdb.d/", BindMode.READ_ONLY);
}
- withExposedPorts(getPort());
+ withExposedPorts(getExposedPort());
setWaitStrategy(new JdbcConnectionWaitStrategy(
() ->
DriverManager.getConnection(getDefaultDatabaseName().isPresent()
? DataSourceEnvironment.getURL(databaseType,
"localhost", getFirstMappedPort(), getDefaultDatabaseName().get())
- : DataSourceEnvironment.getURL(databaseType,
"localhost", getFirstMappedPort()), getUsername(), getUnifiedPassword())));
+ : DataSourceEnvironment.getURL(databaseType,
"localhost", getFirstMappedPort()), getUsername(), getPassword())));
}
protected final void setCommands(final String command) {
@@ -119,7 +119,7 @@ public abstract class DockerStorageContainer extends
DockerITContainer implement
result.setDriverClassName(DataSourceEnvironment.getDriverClassName(databaseType));
result.setJdbcUrl(getJdbcUrl(dataSourceName));
result.setUsername(getUsername());
- result.setPassword(getUnifiedPassword());
+ result.setPassword(getPassword());
result.setMaximumPoolSize(4);
result.setTransactionIsolation("TRANSACTION_READ_COMMITTED");
return result;
@@ -132,9 +132,11 @@ public abstract class DockerStorageContainer extends
DockerITContainer implement
* @return JDBC URL
*/
public String getJdbcUrl(final String dataSourceName) {
- return DataSourceEnvironment.getURL(databaseType, getHost(),
getMappedPort(getPort()), dataSourceName);
+ return DataSourceEnvironment.getURL(databaseType, getHost(),
getMappedPort(getExposedPort()), dataSourceName);
}
+ protected abstract Optional<String> getDefaultDatabaseName();
+
/**
* Get username.
*
@@ -144,23 +146,28 @@ public abstract class DockerStorageContainer extends
DockerITContainer implement
return StorageContainerConstants.USERNAME;
}
- /**
- * Get database port.
- *
- * @return database port
- */
- public abstract int getPort();
-
/**
* Get unified database access password.
*
* @return unified database access password
*/
- public final String getUnifiedPassword() {
+ public final String getPassword() {
return StorageContainerConstants.PASSWORD;
}
- protected abstract Optional<String> getDefaultDatabaseName();
+ /**
+ * Get database container exposed port.
+ *
+ * @return exposed database container port
+ */
+ public abstract int getExposedPort();
+
+ /**
+ * Get database container mapped port.
+ *
+ * @return mapped database container port
+ */
+ protected abstract int getMappedPort();
@Override
public final String getAbbreviation() {
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 36617eb7b31..f5bdc16b32f 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
@@ -19,6 +19,7 @@ package
org.apache.shardingsphere.test.integration.env.container.atomic.storage.
import com.google.common.base.Strings;
import org.apache.shardingsphere.infra.database.type.DatabaseTypeFactory;
+import
org.apache.shardingsphere.test.integration.env.container.atomic.constants.StorageContainerConstants;
import
org.apache.shardingsphere.test.integration.env.container.atomic.storage.DockerStorageContainer;
import
org.apache.shardingsphere.test.integration.env.container.atomic.storage.config.StorageContainerConfiguration;
@@ -45,8 +46,13 @@ public final class MySQLContainer extends
DockerStorageContainer {
}
@Override
- public int getPort() {
- return 3306;
+ public int getExposedPort() {
+ return StorageContainerConstants.MYSQL_EXPOSED_PORT;
+ }
+
+ @Override
+ public int getMappedPort() {
+ return getMappedPort(StorageContainerConstants.MYSQL_EXPOSED_PORT);
}
@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 3901eb01c2a..ad72020d496 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
@@ -49,8 +49,13 @@ public final class OpenGaussContainer extends
DockerStorageContainer {
}
@Override
- public int getPort() {
- return 5432;
+ public int getExposedPort() {
+ return StorageContainerConstants.OPENGAUSS_EXPOSED_PORT;
+ }
+
+ @Override
+ public int getMappedPort() {
+ return
this.getMappedPort(StorageContainerConstants.OPENGAUSS_EXPOSED_PORT);
}
@Override
@@ -60,6 +65,7 @@ public final class OpenGaussContainer extends
DockerStorageContainer {
@Override
public String getJdbcUrl(final String dataSourceName) {
- return DataSourceEnvironment.getURL(getDatabaseType(), getHost(),
getMappedPort(getPort()), StringUtils.isNotEmpty(dataSourceName) ?
dataSourceName : StorageContainerConstants.USERNAME);
+ return DataSourceEnvironment.getURL(getDatabaseType(), getHost(),
+ getMappedPort(getExposedPort()),
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/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 a2c503d2e04..2ee23cdd4f1 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
@@ -19,6 +19,7 @@ package
org.apache.shardingsphere.test.integration.env.container.atomic.storage.
import com.google.common.base.Strings;
import org.apache.shardingsphere.infra.database.type.DatabaseTypeFactory;
+import
org.apache.shardingsphere.test.integration.env.container.atomic.constants.StorageContainerConstants;
import
org.apache.shardingsphere.test.integration.env.container.atomic.storage.DockerStorageContainer;
import
org.apache.shardingsphere.test.integration.env.container.atomic.storage.config.StorageContainerConfiguration;
@@ -45,8 +46,13 @@ public final class PostgreSQLContainer extends
DockerStorageContainer {
}
@Override
- public int getPort() {
- return 5432;
+ public int getExposedPort() {
+ return StorageContainerConstants.POSTGRESQL_EXPOSED_PORT;
+ }
+
+ @Override
+ public int getMappedPort() {
+ return
getMappedPort(StorageContainerConstants.POSTGRESQL_EXPOSED_PORT);
}
@Override
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-ha/src/test/java/org/apache/shardingsphere/test/integration/ha/cases/base/BaseITCase.java
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-ha/src/test/java/org/apache/shardingsphere/test/integration/ha/cases/base/BaseITCase.java
index 20a2cce64ef..1d3e85abd7d 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-ha/src/test/java/org/apache/shardingsphere/test/integration/ha/cases/base/BaseITCase.java
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-ha/src/test/java/org/apache/shardingsphere/test/integration/ha/cases/base/BaseITCase.java
@@ -77,7 +77,7 @@ public abstract class BaseITCase {
private void initStorageDataSources() {
List<DockerStorageContainer> storageContainers =
((DockerContainerComposer) containerComposer).getStorageContainers();
this.storageDataSources = storageContainers.stream()
- .map(storageContainer ->
DataSourceEnvironment.getURL(getDatabaseType(),
storageContainer.getNetworkAliases().get(0), storageContainer.getPort(),
DEFAULT_SCHEMA))
+ .map(storageContainer ->
DataSourceEnvironment.getURL(getDatabaseType(),
storageContainer.getNetworkAliases().get(0), storageContainer.getExposedPort(),
DEFAULT_SCHEMA))
.map(jdbcUrl -> getDataSource(jdbcUrl,
StorageContainerConstants.USERNAME, StorageContainerConstants.PASSWORD))
.collect(Collectors.toList());
}
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 634fa89de25..cded9b3f17f 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
@@ -115,7 +115,7 @@ public abstract class BaseITCase {
if (ENV.getItEnvType() == ITEnvTypeEnum.DOCKER) {
DockerStorageContainer storageContainer =
((DockerComposedContainer) composedContainer).getStorageContainer();
username = storageContainer.getUsername();
- password = storageContainer.getUnifiedPassword();
+ password = storageContainer.getPassword();
} else {
username = ENV.getActualDataSourceUsername(databaseType);
password = ENV.getActualDataSourcePassword(databaseType);
@@ -175,7 +175,7 @@ public abstract class BaseITCase {
if (ITEnvTypeEnum.DOCKER == ENV.getItEnvType()) {
DockerStorageContainer storageContainer =
((DockerComposedContainer) composedContainer).getStorageContainer();
if (isInContainer) {
- return DataSourceEnvironment.getURL(getDatabaseType(),
getDatabaseType().getType().toLowerCase() + ".host",
storageContainer.getPort(), databaseName);
+ return DataSourceEnvironment.getURL(getDatabaseType(),
getDatabaseType().getType().toLowerCase() + ".host",
storageContainer.getExposedPort(), databaseName);
} else {
return DataSourceEnvironment.getURL(getDatabaseType(),
storageContainer.getHost(), storageContainer.getFirstMappedPort(),
databaseName);
}
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/env/IntegrationTestEnvironment.java
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/env/IntegrationTestEnvironment.java
index 508df8f0b03..e5c5aad54e6 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/env/IntegrationTestEnvironment.java
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/env/IntegrationTestEnvironment.java
@@ -23,6 +23,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
import
org.apache.shardingsphere.integration.data.pipeline.env.enums.ITEnvTypeEnum;
+import
org.apache.shardingsphere.test.integration.env.container.atomic.constants.StorageContainerConstants;
import java.io.IOException;
import java.io.InputStream;
@@ -96,11 +97,11 @@ public final class IntegrationTestEnvironment {
public int getActualDataSourceDefaultPort(final DatabaseType databaseType)
{
switch (databaseType.getType()) {
case "MySQL":
- return
Integer.parseInt(props.getOrDefault("scaling.it.native.mysql.port",
3306).toString());
+ return
Integer.parseInt(props.getOrDefault("scaling.it.native.mysql.port",
StorageContainerConstants.MYSQL_EXPOSED_PORT).toString());
case "PostgreSQL":
- return
Integer.parseInt(props.getOrDefault("scaling.it.native.postgresql.port",
5432).toString());
+ return
Integer.parseInt(props.getOrDefault("scaling.it.native.postgresql.port",
StorageContainerConstants.POSTGRESQL_EXPOSED_PORT).toString());
case "openGauss":
- return
Integer.parseInt(props.getOrDefault("scaling.it.native.opengauss.port",
5432).toString());
+ return
Integer.parseInt(props.getOrDefault("scaling.it.native.opengauss.port",
StorageContainerConstants.OPENGAUSS_EXPOSED_PORT).toString());
default:
throw new IllegalArgumentException("Unsupported database type:
" + databaseType.getType());
}
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 019edebf521..df68e9654b4 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
@@ -139,9 +139,9 @@ 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.getPort()), dataSourceName));
+ result.setJdbcUrl(DataSourceEnvironment.getURL(databaseType,
databaseContainer.getHost(),
databaseContainer.getMappedPort(databaseContainer.getExposedPort()),
dataSourceName));
result.setUsername(databaseContainer.getUsername());
- result.setPassword(databaseContainer.getUnifiedPassword());
+ result.setPassword(databaseContainer.getPassword());
result.setMaximumPoolSize(50);
result.setIdleTimeout(60000);
result.setMaxLifetime(1800000);
@@ -321,7 +321,7 @@ public abstract class BaseITCase {
if (ENV.getItEnvType() == TransactionITEnvTypeEnum.DOCKER) {
DockerComposedContainer dockerComposedContainer =
(DockerComposedContainer) composedContainer;
DockerStorageContainer databaseContainer =
dockerComposedContainer.getStorageContainer();
- jdbcInfo = new JdbcInfoEntity(databaseContainer.getUsername(),
databaseContainer.getUnifiedPassword(), databaseContainer.getPort());
+ jdbcInfo = new JdbcInfoEntity(databaseContainer.getUsername(),
databaseContainer.getPassword(), databaseContainer.getExposedPort());
} else {
jdbcInfo = ENV.getActualDatabaseJdbcInfo(getDatabaseType());
}
@@ -471,7 +471,7 @@ public abstract class BaseITCase {
private String getActualJdbcUrlTemplate(final String databaseName) {
if (ENV.getItEnvType() == TransactionITEnvTypeEnum.DOCKER) {
final DockerStorageContainer databaseContainer =
((DockerComposedContainer) composedContainer).getStorageContainer();
- return DataSourceEnvironment.getURL(getDatabaseType(),
getDatabaseType().getType().toLowerCase() + ".host",
databaseContainer.getPort(), databaseName);
+ return DataSourceEnvironment.getURL(getDatabaseType(),
getDatabaseType().getType().toLowerCase() + ".host",
databaseContainer.getExposedPort(), databaseName);
} else {
return DataSourceEnvironment.getURL(getDatabaseType(),
"127.0.0.1", ENV.getActualDataSourceDefaultPort(databaseType), databaseName);
}
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/env/IntegrationTestEnvironment.java
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/env/IntegrationTestEnvironment.java
index 87f2a3349f1..aa74961d960 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/env/IntegrationTestEnvironment.java
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/env/IntegrationTestEnvironment.java
@@ -140,11 +140,11 @@ public final class IntegrationTestEnvironment {
public int getActualDataSourceDefaultPort(final DatabaseType databaseType)
{
switch (databaseType.getType()) {
case "MySQL":
- return
Integer.parseInt(props.getOrDefault("transaction.it.native.mysql.port",
3306).toString());
+ return
Integer.parseInt(props.getOrDefault("transaction.it.native.mysql.port",
StorageContainerConstants.MYSQL_EXPOSED_PORT).toString());
case "PostgreSQL":
- return
Integer.parseInt(props.getOrDefault("transaction.it.native.postgresql.port",
5432).toString());
+ return
Integer.parseInt(props.getOrDefault("transaction.it.native.postgresql.port",
StorageContainerConstants.POSTGRESQL_EXPOSED_PORT).toString());
case "openGauss":
- return
Integer.parseInt(props.getOrDefault("transaction.it.native.opengauss.port",
5432).toString());
+ return
Integer.parseInt(props.getOrDefault("transaction.it.native.opengauss.port",
StorageContainerConstants.OPENGAUSS_EXPOSED_PORT).toString());
default:
throw new IllegalArgumentException("Unsupported database type:
" + databaseType.getType());
}