You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2021/09/08 09:01:57 UTC
[shardingsphere] branch master updated: Optimize the integration
test mirror code. (#12274)
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 231d93f Optimize the integration test mirror code. (#12274)
231d93f is described below
commit 231d93f1bf95d8ecaf4940bf420ce19b647e24af
Author: Guocheng Tang <to...@qq.com>
AuthorDate: Wed Sep 8 17:01:26 2021 +0800
Optimize the integration test mirror code. (#12274)
---
.../env/database/embedded/EmbeddedDatabaseManager.java | 2 +-
.../integration/env/dataset/DataSetEnvironmentManager.java | 14 ++++++--------
.../junit/container/governance/ZookeeperContainer.java | 2 +-
.../junit/container/storage/impl/PostgreSQLContainer.java | 7 ++++---
4 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/env/database/embedded/EmbeddedDatabaseManager.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/env/database/embedded/EmbeddedDatabaseManager.java
index 813a784..1f27f03 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/env/database/embedded/EmbeddedDatabaseManager.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/env/database/embedded/EmbeddedDatabaseManager.java
@@ -62,8 +62,8 @@ public final class EmbeddedDatabaseManager {
if (EMBEDDED_DATABASES_CACHE.containsKey(embeddedDatabaseKey)) {
return;
}
+ DATABASE_RESOURCE_LOCK.lock();
try {
- DATABASE_RESOURCE_LOCK.lock();
startUpSafely(embeddedDatabaseKey, databaseType, embeddedDatabaseProps, port);
} finally {
DATABASE_RESOURCE_LOCK.unlock();
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/env/dataset/DataSetEnvironmentManager.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/env/dataset/DataSetEnvironmentManager.java
index 2977d97..2b8b43c 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/env/dataset/DataSetEnvironmentManager.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/env/dataset/DataSetEnvironmentManager.java
@@ -170,17 +170,15 @@ public final class DataSetEnvironmentManager {
private final String insertSQL;
private final Collection<SQLValueGroup> sqlValueGroups;
-
+
@Override
public Void call() throws SQLException {
- try (Connection connection = dataSource.getConnection()) {
- try (PreparedStatement preparedStatement = connection.prepareStatement(insertSQL)) {
- for (SQLValueGroup each : sqlValueGroups) {
- setParameters(preparedStatement, each);
- preparedStatement.addBatch();
- }
- preparedStatement.executeBatch();
+ try (Connection connection = dataSource.getConnection(); PreparedStatement preparedStatement = connection.prepareStatement(insertSQL)) {
+ for (SQLValueGroup each : sqlValueGroups) {
+ setParameters(preparedStatement, each);
+ preparedStatement.addBatch();
}
+ preparedStatement.executeBatch();
}
return null;
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/governance/ZookeeperContainer.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/governance/ZookeeperContainer.java
index 8c47c00..0757eb3 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/governance/ZookeeperContainer.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/governance/ZookeeperContainer.java
@@ -34,6 +34,6 @@ public final class ZookeeperContainer extends ShardingSphereContainer {
* @return server list
*/
public String getServerLists() {
- return "localhost:" + getMappedPort(2181);
+ return this.getHost() + getMappedPort(2181);
}
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/storage/impl/PostgreSQLContainer.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/storage/impl/PostgreSQLContainer.java
index eef5d62..7246bb9 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/storage/impl/PostgreSQLContainer.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/container/storage/impl/PostgreSQLContainer.java
@@ -48,13 +48,14 @@ public final class PostgreSQLContainer extends ShardingSphereStorageContainer {
@SneakyThrows
protected void execute() {
int time = 0;
+ Class.forName(getDriverClassName());
+ String url = DataSourceEnvironment.getURL("PostgreSQL", getHost(), getPort());
// TODO logic need prefect
while (time++ < 20) {
- Class.forName(getDriverClassName());
- try (Connection ignored = DriverManager.getConnection(DataSourceEnvironment.getURL("PostgreSQL", getHost(), getPort()), getUsername(), getPassword())) {
+ try (Connection ignored = DriverManager.getConnection(url, getUsername(), getPassword())) {
break;
} catch (PSQLException ex) {
- Thread.sleep(1000);
+ Thread.sleep(1000L);
}
}
}