fix(测试计划): 修复禁用本地执行未生效问题
--bug=1019838 --user=赵勇 【测试跟踪】禁用本地执行,【开启】默认资源池,在测试计划里执行接口用例 / 场景会使用本地执行 https://www.tapd.cn/55049933/s/1298673 --bug=1019825 --user=赵勇 【测试跟踪】禁用本地执行,不开启默认资源池,在测试计划里执行接口用例会使用本地执行 https://www.tapd.cn/55049933/s/1298676
This commit is contained in:
parent
a42185eab5
commit
c5d3610bf0
|
@ -35,6 +35,7 @@ import io.metersphere.plugin.core.MsTestElement;
|
|||
import io.metersphere.service.SystemParameterService;
|
||||
import io.metersphere.service.definition.TcpApiParamService;
|
||||
import io.metersphere.utils.LoggerUtil;
|
||||
import io.metersphere.vo.BooleanPool;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
@ -127,6 +128,8 @@ public class ApiExecuteService {
|
|||
request.setReportId(request.getTestPlanId());
|
||||
}
|
||||
LoggerUtil.info("开始执行单条用例【 " + testCaseWithBLOBs.getId() + " 】", request.getReportId());
|
||||
RunModeConfigDTO runModeConfigDTO = new RunModeConfigDTO();
|
||||
jMeterService.verifyPool(testCaseWithBLOBs.getProjectId(), runModeConfigDTO);
|
||||
|
||||
// 多态JSON普通转换会丢失内容,需要通过 ObjectMapper 获取
|
||||
if (testCaseWithBLOBs != null && StringUtils.isNotEmpty(testCaseWithBLOBs.getRequest())) {
|
||||
|
@ -135,11 +138,19 @@ public class ApiExecuteService {
|
|||
if (LoggerUtil.getLogger().isDebugEnabled()) {
|
||||
LoggerUtil.debug("生成jmx文件:" + ElementUtil.hashTreeToString(jmeterHashTree));
|
||||
}
|
||||
|
||||
// 调用执行方法
|
||||
JmeterRunRequestDTO runRequest = new JmeterRunRequestDTO(testCaseWithBLOBs.getId(), StringUtils.isEmpty(request.getReportId()) ? request.getId() : request.getReportId(), request.getRunMode(), jmeterHashTree);
|
||||
if (MapUtils.isNotEmpty(extendedParameters)) {
|
||||
runRequest.setExtendedParameters(extendedParameters);
|
||||
}
|
||||
if (StringUtils.isNotBlank(runModeConfigDTO.getResourcePoolId())) {
|
||||
runRequest.setPoolId(runModeConfigDTO.getResourcePoolId());
|
||||
BooleanPool pool = GenerateHashTreeUtil.isResourcePool(runModeConfigDTO.getResourcePoolId());
|
||||
runRequest.setPool(pool);
|
||||
BaseSystemConfigDTO baseInfo = systemParameterService.getBaseInfo();
|
||||
runRequest.setPlatformUrl(GenerateHashTreeUtil.getPlatformUrl(baseInfo, runRequest, null));
|
||||
}
|
||||
jMeterService.run(runRequest);
|
||||
} catch (Exception ex) {
|
||||
ApiDefinitionExecResult result = apiDefinitionExecResultMapper.selectByPrimaryKey(request.getReportId());
|
||||
|
|
|
@ -745,6 +745,7 @@ public class TestPlanApiCaseService {
|
|||
if (apiCase == null) {
|
||||
MSException.throwException("用例已经被删除");
|
||||
}
|
||||
|
||||
String reportName = apiCase.getName();
|
||||
ApiDefinitionExecResultWithBLOBs result = ApiDefinitionExecResultUtil.add(testId, ApiReportStatus.RUNNING.name(), reportId, Objects.requireNonNull(SessionUtils.getUser()).getId());
|
||||
result.setName(reportName);
|
||||
|
|
|
@ -425,6 +425,16 @@ export default {
|
|||
getResourcePools() {
|
||||
this.result = getTestResourcePools().then(response => {
|
||||
this.resourcePools = response.data;
|
||||
let isDelPool = true;
|
||||
this.resourcePools.forEach(item =>{
|
||||
if(item.id === this.config.resourcePoolId){
|
||||
isDelPool = false;
|
||||
}
|
||||
})
|
||||
if(isDelPool){
|
||||
this.config.resourcePoolId = undefined;
|
||||
this.config.poolEnable = false;
|
||||
}
|
||||
});
|
||||
},
|
||||
runModeChange(value, other) {
|
||||
|
|
|
@ -51,6 +51,7 @@ import io.metersphere.xpack.api.service.ApiPoolDebugService;
|
|||
import io.metersphere.xpack.track.dto.IssuesDao;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.session.ExecutorType;
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
|
@ -1799,9 +1800,13 @@ public class TestPlanService {
|
|||
|
||||
for (String id : ids) {
|
||||
TestPlanWithBLOBs testPlan = testPlanMap.get(id);
|
||||
|
||||
String planReportId = UUID.randomUUID().toString();
|
||||
//创建测试报告
|
||||
RunModeConfigDTO runModeConfigDTO = JSON.parseObject(testPlan.getRunModeConfig(), RunModeConfigDTO.class);
|
||||
runModeConfigDTO = ObjectUtils.isEmpty(runModeConfigDTO) ? new RunModeConfigDTO() : runModeConfigDTO;
|
||||
this.verifyPool(testPlan.getProjectId(), runModeConfigDTO);
|
||||
|
||||
this.genTestPlanReport(planReportId, testPlan.getId(), request.getUserId(), request.getTriggerMode(), runModeConfigDTO);
|
||||
//测试计划准备执行,取消测试计划的实际结束时间
|
||||
extTestPlanMapper.updateActualEndTimeIsNullById(testPlan.getId());
|
||||
|
|
|
@ -515,6 +515,8 @@ export default {
|
|||
.then(() => {
|
||||
this.runningReport.add(reportId);
|
||||
this.$refs.apiCaseResult.open(reportId);
|
||||
},error =>{
|
||||
this.rowLoading = "";
|
||||
});
|
||||
},
|
||||
handleTestEnd(reportId) {
|
||||
|
|
Loading…
Reference in New Issue