refactor(性能测试): 资源池校验修改,停止容器错误处理
This commit is contained in:
parent
1d90a1b56c
commit
980190c6bf
|
@ -127,6 +127,7 @@ public class DockerTestEngine extends AbstractEngine {
|
|||
Integer port = node.getPort();
|
||||
|
||||
String uri = String.format(BASE_URL + "/jmeter/container/stop/" + testId, ip, port);
|
||||
try {
|
||||
ResultHolder result = restTemplateWithTimeOut.getForObject(uri, ResultHolder.class);
|
||||
if (result == null) {
|
||||
MSException.throwException(Translator.get("container_delete_fail"));
|
||||
|
@ -134,6 +135,11 @@ public class DockerTestEngine extends AbstractEngine {
|
|||
if (!result.isSuccess()) {
|
||||
MSException.throwException(result.getMessage());
|
||||
}
|
||||
} catch (MSException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
MSException.throwException("Please check node-controller status.");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -7,13 +7,13 @@ import io.metersphere.base.mapper.TestResourceMapper;
|
|||
import io.metersphere.commons.constants.ResourceStatusEnum;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
import io.metersphere.controller.ResultHolder;
|
||||
import io.metersphere.dto.NodeDTO;
|
||||
import io.metersphere.dto.TestResourcePoolDTO;
|
||||
import io.metersphere.i18n.Translator;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
@ -71,12 +71,18 @@ public class NodeResourcePoolService {
|
|||
|
||||
private boolean validateNode(NodeDTO node) {
|
||||
try {
|
||||
ResponseEntity<String> entity = restTemplateWithTimeOut.getForEntity(String.format(nodeControllerUrl, node.getIp(), node.getPort()), String.class);
|
||||
return HttpStatus.OK.equals(entity.getStatusCode());
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
ResponseEntity<ResultHolder> entity = restTemplateWithTimeOut.getForEntity(String.format(nodeControllerUrl, node.getIp(), node.getPort()), ResultHolder.class);
|
||||
ResultHolder body = entity.getBody();
|
||||
if (body == null) {
|
||||
return false;
|
||||
}
|
||||
if (body.getData() != null && StringUtils.equalsIgnoreCase("OK", body.getData().toString())) {
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void updateTestResource(TestResource testResource) {
|
||||
|
|
Loading…
Reference in New Issue