fix(接口自动化): 实时报告接收后重名结果匹配错误问题修复

This commit is contained in:
fit2-zhao 2021-07-19 10:17:00 +08:00 committed by fit2-zhao
parent 97aaa445f2
commit 585188e5dc
13 changed files with 40 additions and 27 deletions

View File

@ -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<String> id_names = new LinkedList<>();
this.getScenarioSet(this, id_names);
processor.setProperty("MS-SCENARIO", JSON.toJSONString(id_names));

View File

@ -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<String> id_names = new LinkedList<>();
this.getScenarioSet(this, id_names);
jdbcPostProcessor.setProperty("MS-SCENARIO", JSON.toJSONString(id_names));

View File

@ -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<String> id_names = new LinkedList<>();
this.getScenarioSet(this, id_names);
jdbcPreProcessor.setProperty("MS-SCENARIO", JSON.toJSONString(id_names));

View File

@ -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";

View File

@ -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<String> id_names = new LinkedList<>();
this.getScenarioSet(this, id_names);
sampler.setProperty("MS-SCENARIO", JSON.toJSONString(id_names));

View File

@ -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<String> id_names = new LinkedList<>();
this.getScenarioSet(this, id_names);
sampler.setProperty("MS-SCENARIO", JSON.toJSONString(id_names));

View File

@ -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<String> id_names = new LinkedList<>();
this.getScenarioSet(this, id_names);
sampler.setProperty("MS-SCENARIO", JSON.toJSONString(id_names));

View File

@ -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<String> id_names = new LinkedList<>();
this.getScenarioSet(this, id_names);
tcpSampler.setProperty("MS-SCENARIO", JSON.toJSONString(id_names));

View File

@ -10,6 +10,9 @@ public class RequestResult {
// 请求ID
private String id;
// 步骤请求唯一ID
private String resourceId;
private String name;
private String url;

View File

@ -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));

View File

@ -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<id_name> 多层父级按照同级统计
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");
}

View File

@ -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() {

View File

@ -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;
}