Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
morningman committed Nov 22, 2023
1 parent 9520d1c commit 12d7060
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.apache.doris.qe.ConnectContext;
import org.apache.doris.qe.ConnectScheduler;
import org.apache.doris.utframe.TestWithFeService;

import mockit.Delegate;
import mockit.Expectations;
Expand Down Expand Up @@ -79,10 +80,7 @@ public Boolean answer() throws Throwable {

@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());

Expand All @@ -108,9 +106,7 @@ public void testNormal() throws IOException, InterruptedException {

@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);
Expand All @@ -121,9 +117,7 @@ public void testBindFail() throws IOException {

@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());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ protected void cleanDorisFeDir() {
}
}

protected int findValidPort() {
public static int findValidPort() {
int port = 0;
while (true) {
try (ServerSocket socket = new ServerSocket(0)) {
Expand Down

0 comments on commit 12d7060

Please sign in to comment.