Skip to content

Commit

Permalink
rollback initHttpServer update, might be flaky
Browse files Browse the repository at this point in the history
Signed-off-by: pengyu <[email protected]>
  • Loading branch information
py023 committed Feb 27, 2024
1 parent e9f4404 commit fb25b6e
Showing 1 changed file with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import org.apache.doris.common.ExceptionChecker.ThrowingRunnable;
import org.apache.doris.common.FeConstants;
import org.apache.doris.common.jmockit.Deencapsulation;
import org.apache.doris.common.util.UnitTestUtil;
import org.apache.doris.datasource.CatalogMgr;
import org.apache.doris.datasource.InternalCatalog;
import org.apache.doris.httpv2.HttpServer;
Expand Down Expand Up @@ -75,6 +74,7 @@

import java.io.File;
import java.io.IOException;
import java.net.ServerSocket;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.HashMap;
Expand Down Expand Up @@ -326,8 +326,24 @@ private static void assignBackends() {

@BeforeClass
public static void initHttpServer() throws IllegalArgException, InterruptedException {
HTTP_PORT = UnitTestUtil.findValidPort();
URI = "http://localhost:" + HTTP_PORT + "/api/" + DB_NAME + "/" + TABLE_NAME;
ServerSocket socket = null;
try {
socket = new ServerSocket(0);
socket.setReuseAddress(true);
HTTP_PORT = socket.getLocalPort();
URI = "http://localhost:" + HTTP_PORT + "/api/" + DB_NAME + "/" + TABLE_NAME;
} catch (Exception e) {
throw new IllegalStateException("Could not find a free TCP/IP port to start HTTP Server on");
} finally {
if (socket != null) {
try {
socket.close();
} catch (Exception e) {
// CHECKSTYLE IGNORE THIS LINE
}
}
}

FeConstants.runningUnitTest = true;
httpServer = new HttpServer();
httpServer.setPort(HTTP_PORT);
Expand Down

0 comments on commit fb25b6e

Please sign in to comment.