This is an automated email from the ASF dual-hosted git repository.
xincheng pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git
The following commit(s) were added to refs/heads/dev by this push:
new 4e73fc28b0 Use random port in registry IT (#16014)
4e73fc28b0 is described below
commit 4e73fc28b0cbe1e9ce26f2aa7ebba1322c315268
Author: Wenjun Ruan <[email protected]>
AuthorDate: Fri May 17 17:35:44 2024 +0800
Use random port in registry IT (#16014)
---
.../plugin/registry/jdbc/MysqlJdbcRegistryTestCase.java | 11 ++++++++---
.../plugin/registry/jdbc/PostgresqlJdbcRegistryTestCase.java | 11 ++++++++---
.../plugin/registry/zookeeper/ZookeeperRegistryTestCase.java | 8 +++++---
3 files changed, 21 insertions(+), 9 deletions(-)
diff --git
a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/test/java/org/apache/dolphinscheduler/plugin/registry/jdbc/MysqlJdbcRegistryTestCase.java
b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/test/java/org/apache/dolphinscheduler/plugin/registry/jdbc/MysqlJdbcRegistryTestCase.java
index 9ae9b3d8ea..d6d5612b43 100644
---
a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/test/java/org/apache/dolphinscheduler/plugin/registry/jdbc/MysqlJdbcRegistryTestCase.java
+++
b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/test/java/org/apache/dolphinscheduler/plugin/registry/jdbc/MysqlJdbcRegistryTestCase.java
@@ -17,6 +17,8 @@
package org.apache.dolphinscheduler.plugin.registry.jdbc;
+import org.apache.commons.lang3.RandomUtils;
+
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
@@ -52,12 +54,15 @@ class MysqlJdbcRegistryTestCase extends
JdbcRegistryTestCase {
.withExposedPorts(3306)
.waitingFor(Wait.forHealthcheck());
- mysqlContainer.setPortBindings(Lists.newArrayList("3306:3306"));
+ int exposedPort = RandomUtils.nextInt(10000, 65535);
+ mysqlContainer.setPortBindings(Lists.newArrayList(exposedPort +
":3306"));
Startables.deepStart(Stream.of(mysqlContainer)).join();
+ String jdbcUrl = "jdbc:mysql://localhost:" + exposedPort +
"/dolphinscheduler?useSSL=false&serverTimezone=UTC";
+ System.setProperty("spring.datasource.url", jdbcUrl);
+
try (
- Connection connection = DriverManager.getConnection(
-
"jdbc:mysql://localhost:3306/dolphinscheduler?useSSL=false&serverTimezone=UTC",
"root", "root");
+ Connection connection = DriverManager.getConnection(jdbcUrl,
"root", "root");
Statement statement = connection.createStatement();) {
statement.execute(
"CREATE TABLE `t_ds_jdbc_registry_data`\n" +
diff --git
a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/test/java/org/apache/dolphinscheduler/plugin/registry/jdbc/PostgresqlJdbcRegistryTestCase.java
b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/test/java/org/apache/dolphinscheduler/plugin/registry/jdbc/PostgresqlJdbcRegistryTestCase.java
index 766e9f374a..a86533dcaf 100644
---
a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/test/java/org/apache/dolphinscheduler/plugin/registry/jdbc/PostgresqlJdbcRegistryTestCase.java
+++
b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/test/java/org/apache/dolphinscheduler/plugin/registry/jdbc/PostgresqlJdbcRegistryTestCase.java
@@ -17,6 +17,8 @@
package org.apache.dolphinscheduler.plugin.registry.jdbc;
+import org.apache.commons.lang3.RandomUtils;
+
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
@@ -53,12 +55,15 @@ public class PostgresqlJdbcRegistryTestCase extends
JdbcRegistryTestCase {
.withDatabaseName("dolphinscheduler")
.withNetwork(Network.newNetwork())
.withExposedPorts(5432);
- postgresqlContainer.setPortBindings(Lists.newArrayList("5432:5432"));
+ int exposedPort = RandomUtils.nextInt(10000, 65535);
+
+ postgresqlContainer.setPortBindings(Lists.newArrayList(exposedPort +
":5432"));
Startables.deepStart(Stream.of(postgresqlContainer)).join();
+ String jdbcUrl = "jdbc:postgresql://localhost:" + exposedPort +
"/dolphinscheduler";
+ System.setProperty("spring.datasource.url", jdbcUrl);
try (
- Connection connection =
DriverManager.getConnection("jdbc:postgresql://localhost:5432/dolphinscheduler",
- "root", "root");
+ Connection connection = DriverManager.getConnection(jdbcUrl,
"root", "root");
Statement statement = connection.createStatement();) {
statement.execute(
"create table t_ds_jdbc_registry_data\n" +
diff --git
a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-zookeeper/src/test/java/org/apache/dolphinscheduler/plugin/registry/zookeeper/ZookeeperRegistryTestCase.java
b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-zookeeper/src/test/java/org/apache/dolphinscheduler/plugin/registry/zookeeper/ZookeeperRegistryTestCase.java
index 0bb782e8c8..60d8520b81 100644
---
a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-zookeeper/src/test/java/org/apache/dolphinscheduler/plugin/registry/zookeeper/ZookeeperRegistryTestCase.java
+++
b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-zookeeper/src/test/java/org/apache/dolphinscheduler/plugin/registry/zookeeper/ZookeeperRegistryTestCase.java
@@ -19,6 +19,8 @@ package org.apache.dolphinscheduler.plugin.registry.zookeeper;
import org.apache.dolphinscheduler.plugin.registry.RegistryTestCase;
+import org.apache.commons.lang3.RandomUtils;
+
import java.util.stream.Stream;
import lombok.SneakyThrows;
@@ -51,10 +53,10 @@ class ZookeeperRegistryTestCase extends
RegistryTestCase<ZookeeperRegistry> {
public static void setUpTestingServer() {
zookeeperContainer = new
GenericContainer<>(DockerImageName.parse("zookeeper:3.8"))
.withNetwork(NETWORK);
-
- zookeeperContainer.setPortBindings(Lists.newArrayList("2181:2181"));
+ int randomPort = RandomUtils.nextInt(10000, 65535);
+ zookeeperContainer.setPortBindings(Lists.newArrayList(randomPort +
":2181"));
Startables.deepStart(Stream.of(zookeeperContainer)).join();
- System.setProperty("registry.zookeeper.connect-string",
"localhost:2181");
+ System.setProperty("registry.zookeeper.connect-string", "localhost:" +
randomPort);
}
@SneakyThrows