[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:
@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user