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 32971f588a..650848f938 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 @@ -72,6 +72,7 @@ public class MsJSR223Processor extends MsTestElement { processor.setName(this.getName() + DelimiterConstants.SEPARATOR.toString() + name); } processor.setProperty("MS-ID", this.getId()); + processor.setProperty("MS-RESOURCE-ID", this.getResourceId()); List id_names = new LinkedList<>(); this.getScenarioSet(this, id_names); processor.setProperty("MS-SCENARIO", JSON.toJSONString(id_names)); diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/post/MsJDBCPostProcessor.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/post/MsJDBCPostProcessor.java index 20b707d325..323a3b8e6c 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/post/MsJDBCPostProcessor.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/post/MsJDBCPostProcessor.java @@ -244,6 +244,7 @@ public class MsJDBCPostProcessor extends MsTestElement { jdbcPostProcessor.setProperty(TestElement.TEST_CLASS, JDBCPostProcessor.class.getName()); jdbcPostProcessor.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI")); jdbcPostProcessor.setProperty("MS-ID", this.getId()); + jdbcPostProcessor.setProperty("MS-RESOURCE-ID", this.getResourceId()); List id_names = new LinkedList<>(); this.getScenarioSet(this, id_names); jdbcPostProcessor.setProperty("MS-SCENARIO", JSON.toJSONString(id_names)); diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/pre/MsJDBCPreProcessor.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/pre/MsJDBCPreProcessor.java index 127c458bfc..f0ce58bb46 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/pre/MsJDBCPreProcessor.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/pre/MsJDBCPreProcessor.java @@ -244,6 +244,7 @@ public class MsJDBCPreProcessor extends MsTestElement { jdbcPreProcessor.setProperty(TestElement.TEST_CLASS, JDBCPreProcessor.class.getName()); jdbcPreProcessor.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI")); jdbcPreProcessor.setProperty("MS-ID", this.getId()); + jdbcPreProcessor.setProperty("MS-RESOURCE-ID", this.getResourceId()); List id_names = new LinkedList<>(); this.getScenarioSet(this, id_names); jdbcPreProcessor.setProperty("MS-SCENARIO", JSON.toJSONString(id_names)); diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsDebugSampler.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsDebugSampler.java index 3bf621031f..94e8db52e4 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsDebugSampler.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsDebugSampler.java @@ -17,7 +17,7 @@ import java.util.List; @Data @EqualsAndHashCode(callSuper = true) -@JSONType(typeName = "TCPSampler") +@JSONType(typeName = "DebugSampler") public class MsDebugSampler extends MsTestElement { @JSONField(ordinal = 40) private String type = "DebugSampler"; 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 578bf39854..560e4ff5d9 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 @@ -141,6 +141,7 @@ public class MsDubboSampler extends MsTestElement { sampler.setProperty(TestElement.TEST_CLASS, DubboSample.class.getName()); sampler.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("DubboSampleGui")); sampler.setProperty("MS-ID", this.getId()); + sampler.setProperty("MS-RESOURCE-ID", this.getResourceId()); List id_names = new LinkedList<>(); this.getScenarioSet(this, id_names); sampler.setProperty("MS-SCENARIO", JSON.toJSONString(id_names)); 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 63ffdd32da..724f1942f4 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 @@ -185,6 +185,7 @@ public class MsHTTPSamplerProxy extends MsTestElement { sampler.setProperty(TestElement.TEST_CLASS, HTTPSamplerProxy.class.getName()); sampler.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("HttpTestSampleGui")); sampler.setProperty("MS-ID", this.getId()); + sampler.setProperty("MS-RESOURCE-ID", this.getResourceId()); List id_names = new LinkedList<>(); this.getScenarioSet(this, id_names); sampler.setProperty("MS-SCENARIO", JSON.toJSONString(id_names)); 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 5b85068ed7..ccc75ad83f 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 @@ -240,6 +240,7 @@ public class MsJDBCSampler extends MsTestElement { sampler.setProperty(TestElement.TEST_CLASS, JDBCSampler.class.getName()); sampler.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI")); sampler.setProperty("MS-ID", this.getId()); + sampler.setProperty("MS-RESOURCE-ID", this.getResourceId()); List id_names = new LinkedList<>(); this.getScenarioSet(this, id_names); sampler.setProperty("MS-SCENARIO", JSON.toJSONString(id_names)); 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 56bd605048..7f9d3688be 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 @@ -204,6 +204,7 @@ public class MsTCPSampler extends MsTestElement { tcpSampler.setName(this.getName() + DelimiterConstants.SEPARATOR.toString() + name); } tcpSampler.setProperty("MS-ID", this.getId()); + tcpSampler.setProperty("MS-RESOURCE-ID", this.getResourceId()); List id_names = new LinkedList<>(); this.getScenarioSet(this, id_names); tcpSampler.setProperty("MS-SCENARIO", JSON.toJSONString(id_names)); diff --git a/backend/src/main/java/io/metersphere/api/jmeter/RequestResult.java b/backend/src/main/java/io/metersphere/api/jmeter/RequestResult.java index e2b82595dd..797ce38c58 100644 --- a/backend/src/main/java/io/metersphere/api/jmeter/RequestResult.java +++ b/backend/src/main/java/io/metersphere/api/jmeter/RequestResult.java @@ -10,6 +10,9 @@ public class RequestResult { // 请求ID private String id; + // 步骤请求唯一ID + private String resourceId; + private String name; private String url; diff --git a/backend/src/main/java/io/metersphere/api/service/MsResultService.java b/backend/src/main/java/io/metersphere/api/service/MsResultService.java index 93c28c628c..cdfa9415ed 100644 --- a/backend/src/main/java/io/metersphere/api/service/MsResultService.java +++ b/backend/src/main/java/io/metersphere/api/service/MsResultService.java @@ -125,6 +125,7 @@ public class MsResultService { public RequestResult getRequestResult(SampleResult result) { RequestResult requestResult = new RequestResult(); requestResult.setId(result.getSamplerId()); + requestResult.setResourceId(result.getResourceId()); requestResult.setName(result.getSampleLabel()); requestResult.setUrl(result.getUrlAsString()); requestResult.setMethod(getMethod(result)); diff --git a/backend/src/main/java/org/apache/jmeter/samplers/SampleResult.java b/backend/src/main/java/org/apache/jmeter/samplers/SampleResult.java index 943eeeb2f8..529ab10c9d 100644 --- a/backend/src/main/java/org/apache/jmeter/samplers/SampleResult.java +++ b/backend/src/main/java/org/apache/jmeter/samplers/SampleResult.java @@ -168,10 +168,16 @@ public class SampleResult implements Serializable, Cloneable, Searchable { */ private String samplerId; + private String resourceId; + public String getSamplerId() { return this.samplerId; } + public String getResourceId() { + return this.resourceId; + } + // 数据格式 List 多层父级按照同级统计 private String scenario; @@ -348,6 +354,7 @@ public class SampleResult implements Serializable, Cloneable, Searchable { Sampler sampler = JMeterContextService.getContext().getCurrentSampler(); if (sampler != null) { this.samplerId = sampler.getPropertyAsString("MS-ID"); + this.resourceId = sampler.getPropertyAsString("MS-RESOURCE-ID"); this.scenario = sampler.getPropertyAsString("MS-SCENARIO"); } diff --git a/frontend/src/business/components/api/automation/report/SysnApiReportDetail.vue b/frontend/src/business/components/api/automation/report/SysnApiReportDetail.vue index 61517bcbd9..ce11e88612 100644 --- a/frontend/src/business/components/api/automation/report/SysnApiReportDetail.vue +++ b/frontend/src/business/components/api/automation/report/SysnApiReportDetail.vue @@ -152,9 +152,8 @@ export default { if (hashTree) { hashTree.forEach(item => { if (item.enable) { - let key = item.id + item.name; let name = item.name ? item.name : item.type; - let obj = {resId: key, index: Number(item.index), label: name, value: {name: name, responseResult: {}, unexecute: true}, children: [], unsolicited: true}; + let obj = {resId: item.resourceId, index: Number(item.index), label: name, value: {name: name, responseResult: {}, unexecute: true}, children: [], unsolicited: true}; tree.children.push(obj); if (ELEMENTS.get("AllSamplerProxy").indexOf(item.type) != -1) { obj.unsolicited = false; @@ -258,14 +257,12 @@ export default { if (item && item.requestResults) { item.requestResults.forEach(req => { req.responseResult.console = res.console; - let name = req.name.split('<->')[0]; - let key = req.id + name; - if (resMap.get(key)) { - if (resMap.get(key).indexOf(req) === -1) { - resMap.get(key).push(req); + if (resMap.get(req.resourceId)) { + if (resMap.get(req.resourceId).indexOf(req) === -1) { + resMap.get(req.resourceId).push(req); } } else { - resMap.set(key, [req]); + resMap.set(req.resourceId, [req]); } if (req.success) { this.content.success++; @@ -290,9 +287,9 @@ export default { this.reload(); }, reload() { - this.loading = true + this.loading = true; this.$nextTick(() => { - this.loading = false + this.loading = false; }); }, getReport() { diff --git a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue index a59a974378..fa784bc53e 100644 --- a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue @@ -457,21 +457,21 @@ export default { this.editParent(node.parent, status); } }, - findNodeChild(arr, name, index, status) { + findNodeChild(arr, resourceId, status) { arr.forEach(item => { - if (item.data.name === name && item.data.index === index) { + if (item.data.resourceId === resourceId) { this.editParent(item.parent, status); } if (item.childNodes && item.childNodes.length > 0) { - this.findNodeChild(item.childNodes, name, index, status); + this.findNodeChild(item.childNodes, resourceId, status); } }) }, - findNode(name, index, status) { + findNode(resourceId, status) { if (this.$refs.stepTree && this.$refs.stepTree.root) { this.$refs.stepTree.root.childNodes.forEach(item => { if (item.childNodes && item.childNodes.length > 0) { - this.findNodeChild(item.childNodes, name, index, status); + this.findNodeChild(item.childNodes, resourceId, status); } }) } @@ -521,8 +521,7 @@ export default { if (item && item.requestResults) { item.requestResults.forEach(req => { req.responseResult.console = res.console; - let name = req.name.split('<->')[0]; - let key = req.id + name; + let key = req.resourceId; if (resMap.get(key)) { if (resMap.get(key).indexOf(req) === -1) { resMap.get(key).push(req); @@ -716,18 +715,17 @@ export default { arr[i].projectId = scenarioProjectId ? scenarioProjectId : this.projectId; } } - - if (arr[i].hashTree !== undefined && arr[i].hashTree.length > 0) { - this.stepSize += arr[i].hashTree.length; - this.recursiveSorting(arr[i].hashTree, arr[i].projectId); - } // 添加debug结果 - let key = arr[i].id + arr[i].name; + let key = arr[i].resourceId; if (this.debugResult && this.debugResult.get(key)) { arr[i].requestResult = this.debugResult.get(key); arr[i].result = null; arr[i].debug = this.debug; - this.findNode(arr[i].name, arr[i].index, arr[i].requestResult[0].success); + this.findNode(key, arr[i].requestResult[0].success); + } + if (arr[i].hashTree && arr[i].hashTree.length > 0) { + this.stepSize += arr[i].hashTree.length; + this.recursiveSorting(arr[i].hashTree, arr[i].projectId); } } }, @@ -759,9 +757,9 @@ export default { this.recursiveSorting(this.scenarioDefinition[i].hashTree, this.scenarioDefinition[i].projectId); } // 添加debug结果 - if (this.debugResult && this.debugResult.get(this.scenarioDefinition[i].id + this.scenarioDefinition[i].name)) { + if (this.debugResult && this.debugResult.get(this.scenarioDefinition[i].resourceId)) { this.scenarioDefinition[i].result = null; - this.scenarioDefinition[i].requestResult = this.debugResult.get(this.scenarioDefinition[i].id + this.scenarioDefinition[i].name); + this.scenarioDefinition[i].requestResult = this.debugResult.get(this.scenarioDefinition[i].resourceId); this.scenarioDefinition[i].debug = this.debug; }