This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new 3cb8e88602d [test](fe-ut) fix unstable MysqlServerTest (#27459)
3cb8e88602d is described below
commit 3cb8e88602d40cbcd3bbdbe911101fccdd6b2c2c
Author: Mingyu Chen <[email protected]>
AuthorDate: Thu Nov 23 22:56:38 2023 +0800
[test](fe-ut) fix unstable MysqlServerTest (#27459)
Need to find a unbind port for MysqlServerTest
---
.../test/java/org/apache/doris/mysql/MysqlServerTest.java | 15 ++++-----------
.../java/org/apache/doris/utframe/TestWithFeService.java | 2 +-
2 files changed, 5 insertions(+), 12 deletions(-)
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/mysql/MysqlServerTest.java
b/fe/fe-core/src/test/java/org/apache/doris/mysql/MysqlServerTest.java
index ed62bc65040..9bf805b2773 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/mysql/MysqlServerTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/mysql/MysqlServerTest.java
@@ -19,6 +19,7 @@ package org.apache.doris.mysql;
import org.apache.doris.qe.ConnectContext;
import org.apache.doris.qe.ConnectScheduler;
+import org.apache.doris.utframe.TestWithFeService;
import mockit.Delegate;
import mockit.Expectations;
@@ -31,7 +32,6 @@ import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.net.InetSocketAddress;
-import java.net.ServerSocket;
import java.nio.channels.SocketChannel;
public class MysqlServerTest {
@@ -79,10 +79,7 @@ public class MysqlServerTest {
@Test
public void testNormal() throws IOException, InterruptedException {
- ServerSocket socket = new ServerSocket(0);
- int port = socket.getLocalPort();
- socket.close();
-
+ int port = TestWithFeService.findValidPort();
MysqlServer server = new MysqlServer(port, scheduler);
Assert.assertTrue(server.start());
@@ -108,9 +105,7 @@ public class MysqlServerTest {
@Test
public void testBindFail() throws IOException {
- ServerSocket socket = new ServerSocket(0);
- int port = socket.getLocalPort();
- socket.close();
+ int port = TestWithFeService.findValidPort();
MysqlServer server = new MysqlServer(port, scheduler);
Assert.assertTrue(server.start());
MysqlServer server1 = new MysqlServer(port, scheduler);
@@ -121,9 +116,7 @@ public class MysqlServerTest {
@Test
public void testSubFail() throws IOException, InterruptedException {
- ServerSocket socket = new ServerSocket(0);
- int port = socket.getLocalPort();
- socket.close();
+ int port = TestWithFeService.findValidPort();
MysqlServer server = new MysqlServer(port, badScheduler);
Assert.assertTrue(server.start());
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/utframe/TestWithFeService.java
b/fe/fe-core/src/test/java/org/apache/doris/utframe/TestWithFeService.java
index b032ddd2a50..c27bdbac4c3 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/utframe/TestWithFeService.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/utframe/TestWithFeService.java
@@ -495,7 +495,7 @@ public abstract class TestWithFeService {
}
}
- protected int findValidPort() {
+ public static int findValidPort() {
int port = 0;
while (true) {
try (ServerSocket socket = new ServerSocket(0)) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]