[enhancement](test) retry start be or fe when port has been bind. (#13860)

Co-authored-by: wangxiangyu@360shuke.com <wangxiangyu@360shuke.com>
This commit is contained in:
wxy
2022-11-02 08:42:35 +08:00
committed by GitHub
parent 0eeb4d2881
commit 947e67fa76

View File

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