diff --git a/backend/src/main/java/io/metersphere/api/dto/automation/parse/MsScenarioParser.java b/backend/src/main/java/io/metersphere/api/dto/automation/parse/MsScenarioParser.java index c3042baf3e..2c3345ceb6 100644 --- a/backend/src/main/java/io/metersphere/api/dto/automation/parse/MsScenarioParser.java +++ b/backend/src/main/java/io/metersphere/api/dto/automation/parse/MsScenarioParser.java @@ -56,7 +56,7 @@ public class MsScenarioParser extends MsAbstractParser { protected ApiScenarioWithBLOBs parsePluginFormat(JSONObject testObject, ApiTestImportRequest importRequest) { LinkedList results = new LinkedList<>(); testObject.keySet().forEach(tag -> { - results.addAll(parseMsHTTPSamplerProxy(testObject, tag)); + results.addAll(parseMsHTTPSamplerProxy(testObject, tag, true)); }); MsScenario msScenario = new MsScenario(); msScenario.setName(importRequest.getFileName()); diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/parse/MsDefinitionParser.java b/backend/src/main/java/io/metersphere/api/dto/definition/parse/MsDefinitionParser.java index 3570f59472..ff6fb22e6f 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/parse/MsDefinitionParser.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/parse/MsDefinitionParser.java @@ -38,7 +38,7 @@ public class MsDefinitionParser extends MsAbstractParser { } } - if (testObject.get("projectName") != null || testObject.get("projectId") != null ) {// metersphere 格式导入 + if (testObject.get("projectName") != null || testObject.get("projectId") != null) {// metersphere 格式导入 return parseMsFormat(testStr, request); } else { // chrome 插件录制格式导入 request.setPlatform(ApiImportPlatform.Plugin.name()); @@ -56,7 +56,7 @@ public class MsDefinitionParser extends MsAbstractParser { if (isCreateModule) { moduleId = ApiDefinitionImportUtil.buildModule(this.selectModule, tag, this.projectId).getId(); } - List msHTTPSamplerProxies = parseMsHTTPSamplerProxy(testObject, tag); + List msHTTPSamplerProxies = parseMsHTTPSamplerProxy(testObject, tag, false); for (MsHTTPSamplerProxy msHTTPSamplerProxy : msHTTPSamplerProxies) { ApiDefinitionWithBLOBs apiDefinition = buildApiDefinition(msHTTPSamplerProxy.getId(), msHTTPSamplerProxy.getName(), msHTTPSamplerProxy.getPath(), msHTTPSamplerProxy.getMethod(), importRequest); apiDefinition.setModuleId(moduleId); @@ -161,7 +161,7 @@ public class MsDefinitionParser extends MsAbstractParser { String path = apiDefinition.getModulePath() == null ? "" : apiDefinition.getModulePath(); if (StringUtils.isNotBlank(this.selectModulePath)) { apiDefinition.setModulePath(this.selectModulePath + path); - } else if (StringUtils.isBlank(importRequest.getModuleId())){ + } else if (StringUtils.isBlank(importRequest.getModuleId())) { apiDefinition.setModulePath("/未规划接口" + path); } } diff --git a/backend/src/main/java/io/metersphere/api/parse/MsAbstractParser.java b/backend/src/main/java/io/metersphere/api/parse/MsAbstractParser.java index 0a124bad12..3885b221de 100644 --- a/backend/src/main/java/io/metersphere/api/parse/MsAbstractParser.java +++ b/backend/src/main/java/io/metersphere/api/parse/MsAbstractParser.java @@ -16,9 +16,9 @@ import java.util.*; public abstract class MsAbstractParser extends ApiImportAbstractParser { - protected List parseMsHTTPSamplerProxy(JSONObject testObject, String tag) { + protected List parseMsHTTPSamplerProxy(JSONObject testObject, String tag, boolean isSetUrl) { JSONObject requests = testObject.getJSONObject(tag); - List msHTTPSamplerProxies = new ArrayList<>(); + List msHTTPSamplerProxies = new ArrayList<>(); requests.keySet().forEach(requestName -> { JSONObject requestObject = requests.getJSONObject(requestName); String path = requestObject.getString("url"); @@ -27,6 +27,9 @@ public abstract class MsAbstractParser extends ApiImportAbstractParser { parseBody(requestObject, request.getBody()); parseHeader(requestObject, request.getHeaders()); parsePath(request); + if (isSetUrl) { + request.setUrl(path); + } msHTTPSamplerProxies.add(request); }); return msHTTPSamplerProxies; @@ -59,6 +62,7 @@ public abstract class MsAbstractParser extends ApiImportAbstractParser { } } } + private void parseHeader(JSONObject requestObject, List msHeaders) { JSONArray headers = requestObject.getJSONArray("headers"); if (CollectionUtils.isNotEmpty(headers)) { @@ -100,6 +104,7 @@ public abstract class MsAbstractParser extends ApiImportAbstractParser { /** * 删除没有用例的节点 + * * @param nodeTree * @param ids * @return diff --git a/backend/src/main/java/io/metersphere/api/service/RemakeReportService.java b/backend/src/main/java/io/metersphere/api/service/RemakeReportService.java index 830121c00e..bcc7799e23 100644 --- a/backend/src/main/java/io/metersphere/api/service/RemakeReportService.java +++ b/backend/src/main/java/io/metersphere/api/service/RemakeReportService.java @@ -5,10 +5,12 @@ import io.metersphere.base.domain.*; import io.metersphere.base.mapper.*; import io.metersphere.commons.constants.APITestStatus; import io.metersphere.commons.constants.ApiRunMode; +import io.metersphere.commons.utils.BeanUtils; import io.metersphere.commons.utils.CommonBeanFactory; import io.metersphere.commons.utils.LogUtil; import io.metersphere.constants.RunModeConstants; import io.metersphere.dto.JmeterRunRequestDTO; +import io.metersphere.dto.ResultDTO; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -33,13 +35,6 @@ public class RemakeReportService { public void remake(JmeterRunRequestDTO request) { try { - if (StringUtils.equals(request.getReportType(), RunModeConstants.SET_REPORT.toString())) { - ApiExecutionQueueDetailExample example = new ApiExecutionQueueDetailExample(); - example.createCriteria().andQueueIdEqualTo(request.getQueueId()).andTestIdEqualTo(request.getTestId()); - CommonBeanFactory.getBean(ApiExecutionQueueDetailMapper.class).deleteByExample(example); - - CommonBeanFactory.getBean(ApiExecutionQueueService.class).handleQueue(request.getQueueId(), request.getTestId()); - } // 清理零时报告 if (StringUtils.equalsAnyIgnoreCase(request.getRunMode(), ApiRunMode.API_PLAN.name(), ApiRunMode.SCHEDULE_API_PLAN.name(), ApiRunMode.JENKINS_API_PLAN.name())) { ApiDefinitionExecResult result = execResultMapper.selectByPrimaryKey(request.getReportId()); @@ -113,6 +108,17 @@ public class RemakeReportService { } } } + // 处理队列 + if (StringUtils.equals(request.getReportType(), RunModeConstants.SET_REPORT.toString())) { + ApiExecutionQueueDetailExample example = new ApiExecutionQueueDetailExample(); + example.createCriteria().andQueueIdEqualTo(request.getQueueId()).andTestIdEqualTo(request.getTestId()); + CommonBeanFactory.getBean(ApiExecutionQueueDetailMapper.class).deleteByExample(example); + ResultDTO dto = new ResultDTO(); + BeanUtils.copyBean(dto, request); + dto.setQueueId(request.getQueueId()); + dto.setTestId(request.getTestId()); + CommonBeanFactory.getBean(ApiExecutionQueueService.class).queueNext(dto); + } } catch (Exception e) { LogUtil.error(e); } diff --git a/frontend/src/business/components/api/automation/scenario/common/CustomizeReqInfo.vue b/frontend/src/business/components/api/automation/scenario/common/CustomizeReqInfo.vue index b4a45b1bfd..25644e929d 100644 --- a/frontend/src/business/components/api/automation/scenario/common/CustomizeReqInfo.vue +++ b/frontend/src/business/components/api/automation/scenario/common/CustomizeReqInfo.vue @@ -1,14 +1,17 @@