diff --git a/fe/fe-core/src/test/java/org/apache/doris/utframe/UtFrameUtils.java b/fe/fe-core/src/test/java/org/apache/doris/utframe/UtFrameUtils.java index 7e048e116c..adc5a86a39 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/utframe/UtFrameUtils.java +++ b/fe/fe-core/src/test/java/org/apache/doris/utframe/UtFrameUtils.java @@ -149,6 +149,19 @@ public class UtFrameUtils { public static int startFEServer(String runningDir) throws EnvVarNotSetException, IOException, FeStartException, NotInitException, DdlException, InterruptedException { + IOException exception = null; + for (int i = 0; i <= 3; i++) { + try { + return startFEServerWithoutRetry(runningDir); + } catch (IOException ignore) { + exception = ignore; + } + } + throw exception; + } + + private static int startFEServerWithoutRetry(String runningDir) throws EnvVarNotSetException, IOException, + FeStartException, NotInitException { // get DORIS_HOME String dorisHome = System.getenv("DORIS_HOME"); if (Strings.isNullOrEmpty(dorisHome)) { @@ -232,6 +245,18 @@ public class UtFrameUtils { } public static Backend createBackend(String beHost, int feRpcPort) throws IOException, InterruptedException { + IOException exception = null; + for (int i = 0; i <= 3; i++) { + try { + return createBackendWithoutRetry(beHost, feRpcPort); + } catch (IOException ignore) { + exception = ignore; + } + } + throw exception; + } + + private static Backend createBackendWithoutRetry(String beHost, int feRpcPort) throws IOException { int beHeartbeatPort = findValidPort(); int beThriftPort = findValidPort(); int beBrpcPort = findValidPort(); @@ -240,7 +265,7 @@ public class UtFrameUtils { // start be MockedBackend backend = MockedBackendFactory.createBackend(beHost, beHeartbeatPort, beThriftPort, beBrpcPort, beHttpPort, new DefaultHeartbeatServiceImpl(beThriftPort, beHttpPort, beBrpcPort), - new DefaultBeThriftServiceImpl(), new DefaultPBackendServiceImpl()); + new DefaultBeThriftServiceImpl(), new DefaultPBackendServiceImpl()); backend.setFeAddress(new TNetworkAddress("127.0.0.1", feRpcPort)); backend.start();