diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java index 642b71b976..b4325f33ff 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java @@ -73,6 +73,10 @@ public class MsScenario extends MsTestElement { @Override public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { + // 非导出操作,且不是启用状态则跳过执行 + if (!config.isOperating() && !this.isEnable()) { + return; + } if (this.getReferenced() != null && this.getReferenced().equals("Deleted")) { return; } else if (this.getReferenced() != null && this.getReferenced().equals("REF")) { @@ -198,6 +202,8 @@ public class MsScenario extends MsTestElement { config.getConfig().get(this.getProjectId()).getCommonConfig().getVariables().stream().filter(KeyValue::isValid).filter(KeyValue::isEnable).forEach(keyValue -> arguments.addArgument(keyValue.getName(), keyValue.getValue(), "=") ); + // 清空变量,防止重复添加 + config.getConfig().get(this.getProjectId()).getCommonConfig().getVariables().clear(); } if (arguments.getArguments() != null && arguments.getArguments().size() > 0) { return arguments; diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/assertions/MsAssertions.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/assertions/MsAssertions.java index 8197028c78..35d4503d11 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/assertions/MsAssertions.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/assertions/MsAssertions.java @@ -27,6 +27,10 @@ public class MsAssertions extends MsTestElement { @Override public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { + // 非导出操作,且不是启用状态则跳过执行 + if (!config.isOperating() && !this.isEnable()) { + return; + } addAssertions(tree); } diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsIfController.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsIfController.java index 80e1cf017b..5b7df4a228 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsIfController.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsIfController.java @@ -26,6 +26,10 @@ public class MsIfController extends MsTestElement { @Override public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { + // 非导出操作,且不是启用状态则跳过执行 + if (!config.isOperating() && !this.isEnable()) { + return; + } final HashTree groupTree = tree.add(ifController()); if (CollectionUtils.isNotEmpty(hashTree)) { hashTree.forEach(el -> { diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsLoopController.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsLoopController.java index 3e6059f5ba..b1d038c51f 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsLoopController.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsLoopController.java @@ -44,6 +44,10 @@ public class MsLoopController extends MsTestElement { @Override public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { + // 非导出操作,且不是启用状态则跳过执行 + if (!config.isOperating() && !this.isEnable()) { + return; + } final HashTree groupTree = controller(tree); if (CollectionUtils.isNotEmpty(config.getVariables())) { this.addCsvDataSet(groupTree, config.getVariables()); diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/dns/MsDNSCacheManager.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/dns/MsDNSCacheManager.java index 871b834286..38166128b8 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/dns/MsDNSCacheManager.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/dns/MsDNSCacheManager.java @@ -26,7 +26,8 @@ public class MsDNSCacheManager extends MsTestElement { @Override public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { - if (!this.isEnable()) { + // 非导出操作,且不是启用状态则跳过执行 + if (!config.isOperating() && !this.isEnable()) { return; } for (MsTestElement el : hashTree) { diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/extract/MsExtract.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/extract/MsExtract.java index 45b6051347..79951094a1 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/extract/MsExtract.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/extract/MsExtract.java @@ -30,6 +30,10 @@ public class MsExtract extends MsTestElement { @Override public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { + // 非导出操作,且不是启用状态则跳过执行 + if (!config.isOperating() && !this.isEnable()) { + return; + } addRequestExtractors(tree); } diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/MsJSR223Processor.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/MsJSR223Processor.java index 10136f6356..cb9982c704 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/MsJSR223Processor.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/MsJSR223Processor.java @@ -29,6 +29,10 @@ public class MsJSR223Processor extends MsTestElement { @Override public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { + // 非导出操作,且不是启用状态则跳过执行 + if (!config.isOperating() && !this.isEnable()) { + return; + } JSR223Sampler processor = new JSR223Sampler(); processor.setEnabled(this.isEnable()); if (StringUtils.isNotEmpty(this.getName())) { diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/post/MsJSR223PostProcessor.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/post/MsJSR223PostProcessor.java index 3172f2855e..8901e29b66 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/post/MsJSR223PostProcessor.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/post/MsJSR223PostProcessor.java @@ -29,6 +29,10 @@ public class MsJSR223PostProcessor extends MsTestElement { @Override public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { + // 非导出操作,且不是启用状态则跳过执行 + if (!config.isOperating() && !this.isEnable()) { + return; + } JSR223PostProcessor processor = new JSR223PostProcessor(); processor.setEnabled(this.isEnable()); if (StringUtils.isNotEmpty(this.getName())) { diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/pre/MsJSR223PreProcessor.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/pre/MsJSR223PreProcessor.java index 9cc8b35e56..ccf7fe7362 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/pre/MsJSR223PreProcessor.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/pre/MsJSR223PreProcessor.java @@ -30,6 +30,10 @@ public class MsJSR223PreProcessor extends MsTestElement { @Override public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { + // 非导出操作,且不是启用状态则跳过执行 + if (!config.isOperating() && !this.isEnable()) { + return; + } final HashTree jsr223PreTree = tree.add(getJSR223PreProcessor()); if (CollectionUtils.isNotEmpty(hashTree)) { hashTree.forEach(el -> { diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsDubboSampler.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsDubboSampler.java index 36e85f2570..80d78efe23 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsDubboSampler.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsDubboSampler.java @@ -60,6 +60,10 @@ public class MsDubboSampler extends MsTestElement { @Override public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { + // 非导出操作,且不是启用状态则跳过执行 + if (!config.isOperating() && !this.isEnable()) { + return; + } if (this.getReferenced() != null && "Deleted".equals(this.getReferenced())) { return; } diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java index d09567ba5d..1b428fc29d 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java @@ -93,7 +93,10 @@ public class MsHTTPSamplerProxy extends MsTestElement { @Override public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { - + // 非导出操作,且不是启用状态则跳过执行 + if (!config.isOperating() && !this.isEnable()) { + return; + } if (this.getReferenced() != null && MsTestElementConstants.REF.name().equals(this.getReferenced())) { this.getRefElement(this); } @@ -315,7 +318,9 @@ public class MsHTTPSamplerProxy extends MsTestElement { headers.stream().filter(KeyValue::isValid).filter(KeyValue::isEnable).forEach(keyValue -> headerManager.add(new Header(keyValue.getName(), keyValue.getValue())) ); - tree.add(headerManager); + if (headerManager.getHeaders().size() > 0) { + tree.add(headerManager); + } } public boolean isURL(String str) { diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsJDBCSampler.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsJDBCSampler.java index 3411db8234..c0a105e651 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsJDBCSampler.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsJDBCSampler.java @@ -58,6 +58,10 @@ public class MsJDBCSampler extends MsTestElement { @Override public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { + // 非导出操作,且不是启用状态则跳过执行 + if (!config.isOperating() && !this.isEnable()) { + return; + } if (this.getReferenced() != null && MsTestElementConstants.REF.name().equals(this.getReferenced())) { this.getRefElement(this); } diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsTCPSampler.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsTCPSampler.java index d50913b27d..dbc95ad00c 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsTCPSampler.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsTCPSampler.java @@ -72,6 +72,10 @@ public class MsTCPSampler extends MsTestElement { @Override public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { + // 非导出操作,且不是启用状态则跳过执行 + if (!config.isOperating() && !this.isEnable()) { + return; + } if (this.getReferenced() != null && MsTestElementConstants.REF.name().equals(this.getReferenced())) { this.getRefElement(this); } diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/timer/MsConstantTimer.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/timer/MsConstantTimer.java index 393cae0966..ad481db7f5 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/timer/MsConstantTimer.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/timer/MsConstantTimer.java @@ -26,7 +26,10 @@ public class MsConstantTimer extends MsTestElement { @Override public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { - + // 非导出操作,且不是启用状态则跳过执行 + if (!config.isOperating() && !this.isEnable()) { + return; + } final HashTree groupTree = tree.add(constantTimer()); if (CollectionUtils.isNotEmpty(hashTree)) { hashTree.forEach(el -> { diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/unknown/MsJmeterElement.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/unknown/MsJmeterElement.java index 96fcf10f33..423a0de176 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/unknown/MsJmeterElement.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/unknown/MsJmeterElement.java @@ -3,6 +3,7 @@ package io.metersphere.api.dto.definition.request.unknown; import com.alibaba.fastjson.annotation.JSONType; import io.metersphere.api.dto.definition.request.MsTestElement; import io.metersphere.api.dto.definition.request.ParameterConfig; +import io.metersphere.commons.utils.LogUtil; import lombok.Data; import lombok.EqualsAndHashCode; import org.apache.commons.collections.CollectionUtils; @@ -36,17 +37,22 @@ public class MsJmeterElement extends MsTestElement { Object scriptWrapper = SaveService.loadElement(inputSource); HashTree elementTree = tree; this.setElementType(scriptWrapper.getClass().getName()); + if (scriptWrapper instanceof TestElement) { + ((TestElement) scriptWrapper).setName(this.getName()); + ((TestElement) scriptWrapper).setEnabled(this.isEnable()); + } if (config.isOperating()) { elementTree = tree.add(scriptWrapper); } else if (!(scriptWrapper instanceof TestPlan) && !(scriptWrapper instanceof ThreadGroup)) { elementTree = tree.add(scriptWrapper); } - if (scriptWrapper instanceof TestElement) { - ((TestElement) scriptWrapper).setName(this.getName()); - } - if (CollectionUtils.isNotEmpty(hashTree)) { - for (MsTestElement el : hashTree) { - el.toHashTree(elementTree, el.getHashTree(), config); + if (!config.isOperating() && scriptWrapper instanceof ThreadGroup && !((ThreadGroup) scriptWrapper).isEnabled()) { + LogUtil.info(((ThreadGroup) scriptWrapper).getName() + "是被禁用线程组不加入执行"); + } else { + if (CollectionUtils.isNotEmpty(hashTree)) { + for (MsTestElement el : hashTree) { + el.toHashTree(elementTree, el.getHashTree(), config); + } } } } diff --git a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java index 7483b5e6e2..5a275afe51 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -115,7 +115,9 @@ public class ApiAutomationService { if (map != null) { if (map.isEmpty()) { List ids = (List) JSONPath.read(definition, "$..projectId"); - idList.addAll(new HashSet<>(ids)); + if (CollectionUtils.isNotEmpty(ids)) { + idList.addAll(new HashSet<>(ids)); + } } else { Set set = d.getEnvironmentMap().keySet(); idList = new ArrayList<>(set); @@ -601,6 +603,7 @@ public class ApiAutomationService { ParameterConfig config = new ParameterConfig(); config.setConfig(envConfig); HashTree hashTree = request.getTestElement().generateHashTree(config); + System.out.println(request.getTestElement().getJmx(hashTree)); // 调用执行方法 APIScenarioReportResult reportResult = createScenarioReport(request.getId(), request.getScenarioId(), request.getScenarioName(), ReportTriggerMode.MANUAL.name(), request.getExecuteType(), request.getProjectId(), SessionUtils.getUserId()); diff --git a/backend/src/main/java/io/metersphere/excel/listener/TestCaseDataListener.java b/backend/src/main/java/io/metersphere/excel/listener/TestCaseDataListener.java index 1dff285527..6ec7448a8f 100644 --- a/backend/src/main/java/io/metersphere/excel/listener/TestCaseDataListener.java +++ b/backend/src/main/java/io/metersphere/excel/listener/TestCaseDataListener.java @@ -144,12 +144,12 @@ public class TestCaseDataListener extends EasyExcelListener { String[] stepRes = new String[1]; if (data.getStepDesc() != null) { - stepDesc = data.getStepDesc().split("\n"); + stepDesc = data.getStepDesc().split("\r\n"); } else { stepDesc[0] = ""; } if (data.getStepResult() != null) { - stepRes = data.getStepResult().split("\n"); + stepRes = data.getStepResult().split("\r\n"); } else { stepRes[0] = ""; } diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java index 36579a7de3..808fda0cc8 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java @@ -520,8 +520,8 @@ public class TestCaseService { for (int j = 0; j < jsonArray.size(); j++) { int num = j + 1; - step.append(num + "." + jsonArray.getJSONObject(j).getString("desc") + "\n"); - result.append(num + "." + jsonArray.getJSONObject(j).getString("result") + "\n"); + step.append(num + "." + jsonArray.getJSONObject(j).getString("desc") + "\r\n"); + result.append(num + "." + jsonArray.getJSONObject(j).getString("result") + "\r\n"); } data.setStepDesc(step.toString()); diff --git a/backend/src/main/java/io/metersphere/xpack b/backend/src/main/java/io/metersphere/xpack index 6806c68338..c9fd084c8f 160000 --- a/backend/src/main/java/io/metersphere/xpack +++ b/backend/src/main/java/io/metersphere/xpack @@ -1 +1 @@ -Subproject commit 6806c68338543cf1d04bb25dc24201dd1949e111 +Subproject commit c9fd084c8f4453d7697677a79d9a0a953c045e38 diff --git a/frontend/src/business/components/performance/test/components/PerformanceAdvancedConfig.vue b/frontend/src/business/components/performance/test/components/PerformanceAdvancedConfig.vue index fcacb7434e..388f7a2047 100644 --- a/frontend/src/business/components/performance/test/components/PerformanceAdvancedConfig.vue +++ b/frontend/src/business/components/performance/test/components/PerformanceAdvancedConfig.vue @@ -159,7 +159,7 @@ export default { data() { return { timeout: 60000, - responseTimeout: null, + responseTimeout: 60000, statusCode: [], domains: [], params: [], diff --git a/frontend/src/business/components/track/case/TestCase.vue b/frontend/src/business/components/track/case/TestCase.vue index f3bae0ef40..5dd3b0690f 100644 --- a/frontend/src/business/components/track/case/TestCase.vue +++ b/frontend/src/business/components/track/case/TestCase.vue @@ -8,6 +8,7 @@ @setTreeNodes="setTreeNodes" @exportTestCase="exportTestCase" @saveAsEdit="editTestCase" + @refreshAll="refreshAll" :type="'edit'" ref="nodeTree" /> diff --git a/frontend/src/business/components/track/common/TestCaseNodeTree.vue b/frontend/src/business/components/track/common/TestCaseNodeTree.vue index ed31d2c7df..11f3a7f1b1 100644 --- a/frontend/src/business/components/track/common/TestCaseNodeTree.vue +++ b/frontend/src/business/components/track/common/TestCaseNodeTree.vue @@ -101,7 +101,7 @@ export default { this.$emit("refreshTable"); }, refreshAll() { - this.selectRows.clear(); + // this.selectRows.clear(); this.$emit('refreshAll'); }, handleCommand(e) { diff --git a/frontend/src/business/components/track/home/components/ReviewList.vue b/frontend/src/business/components/track/home/components/ReviewList.vue index b46bb93d01..3bfe162347 100644 --- a/frontend/src/business/components/track/home/components/ReviewList.vue +++ b/frontend/src/business/components/track/home/components/ReviewList.vue @@ -2,7 +2,7 @@
- 遗留缺陷统计 + 用例评审