fix(测试计划): 修复测试计划用例执行触发方式错误问题
--bug=1009267 --user=赵勇 [github #8888]测试计划包含接口测试时,执行测试计划会出现接口执行一直是运行中状态,而且执行方式也有问题 https://www.tapd.cn/55049933/s/1087536
This commit is contained in:
parent
23b0e3f511
commit
ece30da5f9
|
@ -15,6 +15,7 @@ import io.metersphere.base.mapper.ApiDefinitionExecResultMapper;
|
|||
import io.metersphere.base.mapper.TestPlanApiCaseMapper;
|
||||
import io.metersphere.commons.constants.APITestStatus;
|
||||
import io.metersphere.commons.constants.ApiRunMode;
|
||||
import io.metersphere.commons.constants.TriggerMode;
|
||||
import io.metersphere.constants.RunModeConstants;
|
||||
import io.metersphere.dto.JmeterRunRequestDTO;
|
||||
import io.metersphere.dto.MsExecResponseDTO;
|
||||
|
@ -54,6 +55,7 @@ public class TestPlanApiExecuteService {
|
|||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return new LinkedList<>();
|
||||
}
|
||||
LoggerUtil.debug("开始查询测试计划用例");
|
||||
TestPlanApiCaseExample example = new TestPlanApiCaseExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
example.setOrderByClause("`order` DESC");
|
||||
|
@ -80,9 +82,11 @@ public class TestPlanApiExecuteService {
|
|||
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||
}
|
||||
|
||||
LoggerUtil.debug("开始生成测试计划队列");
|
||||
String reportType = request.getConfig() != null ? request.getConfig().getReportType() : null;
|
||||
String poolId = request.getConfig() != null ? request.getConfig().getResourcePoolId() : null;
|
||||
DBTestQueue deQueue = apiExecutionQueueService.add(executeQueue, poolId, ApiRunMode.API_PLAN.name(), request.getPlanReportId(), reportType, request.getTriggerMode());
|
||||
String runMode = StringUtils.equals(request.getTriggerMode(), TriggerMode.MANUAL.name()) ? ApiRunMode.API_PLAN.name() : ApiRunMode.SCHEDULE_API_PLAN.name();
|
||||
DBTestQueue deQueue = apiExecutionQueueService.add(executeQueue, poolId, ApiRunMode.API_PLAN.name(), request.getPlanReportId(), reportType, runMode);
|
||||
|
||||
//如果是测试计划生成报告的执行,则更新执行信息、执行线程信息。
|
||||
if (TestPlanReportExecuteCatch.containsReport(request.getPlanReportId())) {
|
||||
|
@ -92,12 +96,12 @@ public class TestPlanApiExecuteService {
|
|||
}
|
||||
// 开始选择执行模式
|
||||
if (request.getConfig() != null && request.getConfig().getMode().equals(RunModeConstants.SERIAL.toString())) {
|
||||
// 开始串行执行
|
||||
LoggerUtil.debug("开始串行执行");
|
||||
if (deQueue != null && deQueue.getQueue() != null) {
|
||||
apiScenarioSerialService.serial(deQueue, deQueue.getQueue());
|
||||
}
|
||||
} else {
|
||||
// 开始并发执行
|
||||
LoggerUtil.debug("开始并发执行");
|
||||
if (deQueue != null && deQueue.getQueue() != null) {
|
||||
parallel(executeQueue, request, deQueue);
|
||||
}
|
||||
|
@ -119,7 +123,8 @@ public class TestPlanApiExecuteService {
|
|||
if (request.getConfig() == null || !GenerateHashTreeUtil.isResourcePool(request.getConfig().getResourcePoolId()).isPool()) {
|
||||
hashTree = apiScenarioSerialService.generateHashTree(testPlanApiCase.getId());
|
||||
}
|
||||
JmeterRunRequestDTO runRequest = new JmeterRunRequestDTO(testPlanApiCase.getId(), reportId, request.getTriggerMode(), hashTree);
|
||||
String runMode = StringUtils.equals(request.getTriggerMode(), TriggerMode.MANUAL.name()) ? ApiRunMode.API_PLAN.name() : ApiRunMode.SCHEDULE_API_PLAN.name();
|
||||
JmeterRunRequestDTO runRequest = new JmeterRunRequestDTO(testPlanApiCase.getId(), reportId, runMode, hashTree);
|
||||
if (request.getConfig() != null) {
|
||||
runRequest.setPool(GenerateHashTreeUtil.isResourcePool(request.getConfig().getResourcePoolId()));
|
||||
runRequest.setPoolId(request.getConfig().getResourcePoolId());
|
||||
|
|
|
@ -46,13 +46,7 @@ public class ApiDefinitionExecResultUtil {
|
|||
if (caseWithBLOBs != null) {
|
||||
apiResult.setName(caseWithBLOBs.getName());
|
||||
}
|
||||
if (StringUtils.equalsIgnoreCase(request.getTriggerMode(), ApiRunMode.SCHEDULE_API_PLAN.name())) {
|
||||
apiResult.setTriggerMode(TriggerMode.SCHEDULE.name());
|
||||
} else if (StringUtils.equalsIgnoreCase(request.getTriggerMode(), ApiRunMode.JENKINS_API_PLAN.name())) {
|
||||
apiResult.setTriggerMode(TriggerMode.MANUAL.name());
|
||||
} else {
|
||||
apiResult.setTriggerMode(TriggerMode.BATCH.name());
|
||||
}
|
||||
apiResult.setTriggerMode(request.getTriggerMode());
|
||||
apiResult.setActuator("LOCAL");
|
||||
if (request.getConfig() != null && GenerateHashTreeUtil.isResourcePool(request.getConfig().getResourcePoolId()).isPool()) {
|
||||
apiResult.setActuator(request.getConfig().getResourcePoolId());
|
||||
|
|
|
@ -325,9 +325,6 @@ public class ApiDefinitionExecResultService {
|
|||
saveResult.setId(reportId);
|
||||
saveResult.setActuator("LOCAL");
|
||||
saveResult.setName(item.getName());
|
||||
if (StringUtils.equals(type, TriggerMode.SCHEDULE.name())) {
|
||||
saveResult.setTriggerMode(TriggerMode.SCHEDULE.name());
|
||||
}
|
||||
saveResult.setType(type);
|
||||
saveResult.setCreateTime(item.getStartTime());
|
||||
if (SessionUtils.getUser() != null) {
|
||||
|
|
|
@ -1152,13 +1152,7 @@ public class TestPlanService {
|
|||
|
||||
private void executeApiTestCase(String triggerMode, String planReportId, String userId, List<String> planCaseIds, RunModeConfigDTO runModeConfig) {
|
||||
BatchRunDefinitionRequest request = new BatchRunDefinitionRequest();
|
||||
if (StringUtils.equals(triggerMode, ReportTriggerMode.API.name())) {
|
||||
request.setTriggerMode(ApiRunMode.JENKINS_API_PLAN.name());
|
||||
} else if (StringUtils.equals(triggerMode, ReportTriggerMode.MANUAL.name())) {
|
||||
request.setTriggerMode(ApiRunMode.MANUAL_PLAN.name());
|
||||
} else {
|
||||
request.setTriggerMode(ApiRunMode.SCHEDULE_API_PLAN.name());
|
||||
}
|
||||
request.setTriggerMode(triggerMode);
|
||||
request.setPlanIds(planCaseIds);
|
||||
request.setPlanReportId(planReportId);
|
||||
request.setConfig(runModeConfig);
|
||||
|
@ -1912,7 +1906,6 @@ public class TestPlanService {
|
|||
}
|
||||
|
||||
public String runPlan(TestplanRunRequest testplanRunRequest) {
|
||||
|
||||
String envType = testplanRunRequest.getEnvironmentType();
|
||||
Map<String, String> envMap = testplanRunRequest.getEnvMap();
|
||||
String environmentGroupId = testplanRunRequest.getEnvironmentGroupId();
|
||||
|
|
|
@ -575,7 +575,7 @@ export default {
|
|||
});
|
||||
},
|
||||
handleRunBatch(config) {
|
||||
let obj = {planIds: this.testPlanCaseIds, config: config};
|
||||
let obj = {planIds: this.testPlanCaseIds, config: config, triggerMode:"BATCH"};
|
||||
this.$post("/test/plan/api/case/run", obj, response => {
|
||||
this.$message(this.$t('commons.run_message'));
|
||||
this.$refs.taskCenter.open();
|
||||
|
|
Loading…
Reference in New Issue