File tree Expand file tree Collapse file tree 3 files changed +21
-9
lines changed
dolphinscheduler-registry/dolphinscheduler-registry-plugins
dolphinscheduler-registry-jdbc/src/test/java/org/apache/dolphinscheduler/plugin/registry/jdbc
dolphinscheduler-registry-zookeeper/src/test/java/org/apache/dolphinscheduler/plugin/registry/zookeeper Expand file tree Collapse file tree 3 files changed +21
-9
lines changed Original file line number Diff line number Diff line change 1717
1818package org .apache .dolphinscheduler .plugin .registry .jdbc ;
1919
20+ import org .apache .commons .lang3 .RandomUtils ;
21+
2022import java .sql .Connection ;
2123import java .sql .DriverManager ;
2224import java .sql .Statement ;
@@ -52,12 +54,15 @@ public static void setUpTestingServer() {
5254 .withExposedPorts (3306 )
5355 .waitingFor (Wait .forHealthcheck ());
5456
55- mysqlContainer .setPortBindings (Lists .newArrayList ("3306:3306" ));
57+ int exposedPort = RandomUtils .nextInt (10000 , 65535 );
58+ mysqlContainer .setPortBindings (Lists .newArrayList (exposedPort + ":3306" ));
5659 Startables .deepStart (Stream .of (mysqlContainer )).join ();
5760
61+ String jdbcUrl = "jdbc:mysql://localhost:" + exposedPort + "/dolphinscheduler?useSSL=false&serverTimezone=UTC" ;
62+ System .setProperty ("spring.datasource.url" , jdbcUrl );
63+
5864 try (
59- Connection connection = DriverManager .getConnection (
60- "jdbc:mysql://localhost:3306/dolphinscheduler?useSSL=false&serverTimezone=UTC" , "root" , "root" );
65+ Connection connection = DriverManager .getConnection (jdbcUrl , "root" , "root" );
6166 Statement statement = connection .createStatement ();) {
6267 statement .execute (
6368 "CREATE TABLE `t_ds_jdbc_registry_data`\n " +
Original file line number Diff line number Diff line change 1717
1818package org .apache .dolphinscheduler .plugin .registry .jdbc ;
1919
20+ import org .apache .commons .lang3 .RandomUtils ;
21+
2022import java .sql .Connection ;
2123import java .sql .DriverManager ;
2224import java .sql .Statement ;
@@ -53,12 +55,15 @@ public static void setUpTestingServer() {
5355 .withDatabaseName ("dolphinscheduler" )
5456 .withNetwork (Network .newNetwork ())
5557 .withExposedPorts (5432 );
56- postgresqlContainer .setPortBindings (Lists .newArrayList ("5432:5432" ));
58+ int exposedPort = RandomUtils .nextInt (10000 , 65535 );
59+
60+ postgresqlContainer .setPortBindings (Lists .newArrayList (exposedPort + ":5432" ));
5761 Startables .deepStart (Stream .of (postgresqlContainer )).join ();
5862
63+ String jdbcUrl = "jdbc:postgresql://localhost:" + exposedPort + "/dolphinscheduler" ;
64+ System .setProperty ("spring.datasource.url" , jdbcUrl );
5965 try (
60- Connection connection = DriverManager .getConnection ("jdbc:postgresql://localhost:5432/dolphinscheduler" ,
61- "root" , "root" );
66+ Connection connection = DriverManager .getConnection (jdbcUrl , "root" , "root" );
6267 Statement statement = connection .createStatement ();) {
6368 statement .execute (
6469 "create table t_ds_jdbc_registry_data\n " +
Original file line number Diff line number Diff line change 1919
2020import org .apache .dolphinscheduler .plugin .registry .RegistryTestCase ;
2121
22+ import org .apache .commons .lang3 .RandomUtils ;
23+
2224import java .util .stream .Stream ;
2325
2426import lombok .SneakyThrows ;
@@ -51,10 +53,10 @@ class ZookeeperRegistryTestCase extends RegistryTestCase<ZookeeperRegistry> {
5153 public static void setUpTestingServer () {
5254 zookeeperContainer = new GenericContainer <>(DockerImageName .parse ("zookeeper:3.8" ))
5355 .withNetwork (NETWORK );
54-
55- zookeeperContainer .setPortBindings (Lists .newArrayList ("2181 :2181" ));
56+ int randomPort = RandomUtils . nextInt ( 10000 , 65535 );
57+ zookeeperContainer .setPortBindings (Lists .newArrayList (randomPort + " :2181" ));
5658 Startables .deepStart (Stream .of (zookeeperContainer )).join ();
57- System .setProperty ("registry.zookeeper.connect-string" , "localhost:2181" );
59+ System .setProperty ("registry.zookeeper.connect-string" , "localhost:" + randomPort );
5860 }
5961
6062 @ SneakyThrows
You can’t perform that action at this time.
0 commit comments