fix(接口测试): 修复TCP调试报错问题及前后置排序错误问题

--bug=1011538 --user=赵勇 【接口测试】tcp协议-快捷调试报500 https://www.tapd.cn/55049933/s/1123116
This commit is contained in:
fit2-zhao 2022-03-22 13:04:13 +08:00 committed by CountryBuilder
parent d3fe9e20c4
commit f66ffe993e
6 changed files with 24 additions and 19 deletions

View File

@ -657,6 +657,18 @@ public class ElementUtil {
}
}
private static List<MsTestElement> orderList(List<MsTestElement> list) {
if (CollectionUtils.isNotEmpty(list)) {
for (int i = 0; i < list.size(); i++) {
if (StringUtils.isEmpty(list.get(i).getIndex())) {
list.get(i).setIndex(String.valueOf(i));
}
}
return list.stream().sorted(Comparator.comparing(MsTestElement::getIndex)).collect(Collectors.toList());
}
return list;
}
public static List<MsTestElement> order(List<MsTestElement> elements) {
List<MsTestElement> elementList = new LinkedList<>();
if (CollectionUtils.isNotEmpty(elements)) {
@ -666,7 +678,7 @@ public class ElementUtil {
if (groupMap.containsKey(ASSERTIONS)) {
groupMap.get(ASSERTIONS).add(item);
} else {
groupMap.put(ASSERTIONS, new LinkedList<MsTestElement>() {{
groupMap.put(ASSERTIONS, new LinkedList<>() {{
this.add(item);
}});
}
@ -674,7 +686,7 @@ public class ElementUtil {
if (groupMap.containsKey(PRE)) {
groupMap.get(PRE).add(item);
} else {
groupMap.put(PRE, new LinkedList<MsTestElement>() {{
groupMap.put(PRE, new LinkedList<>() {{
this.add(item);
}});
}
@ -682,7 +694,7 @@ public class ElementUtil {
if (groupMap.containsKey(POST)) {
groupMap.get(POST).add(item);
} else {
groupMap.put(POST, new LinkedList<MsTestElement>() {{
groupMap.put(POST, new LinkedList<>() {{
this.add(item);
}});
}
@ -691,10 +703,10 @@ public class ElementUtil {
}
});
if (CollectionUtils.isNotEmpty(groupMap.get(PRE))) {
elementList.addAll(groupMap.get(PRE).stream().sorted(Comparator.comparing(MsTestElement::getIndex)).collect(Collectors.toList()));
elementList.addAll(orderList(groupMap.get(PRE)));
}
if (CollectionUtils.isNotEmpty(groupMap.get(POST))) {
elementList.addAll(groupMap.get(POST).stream().sorted(Comparator.comparing(MsTestElement::getIndex)).collect(Collectors.toList()));
elementList.addAll(orderList(groupMap.get(POST)));
}
if (CollectionUtils.isNotEmpty(groupMap.get(ASSERTIONS))) {
elementList.addAll(groupMap.get(ASSERTIONS));

View File

@ -172,7 +172,7 @@ public class MsTCPSampler extends MsTestElement {
hashTree = ElementUtil.order(hashTree);
EnvironmentConfig finalEnvConfig = envConfig;
hashTree.forEach(el -> {
if (el instanceof MsAssertions) {
if (el instanceof MsAssertions && finalEnvConfig != null) {
//断言设置需要和全局断言误报进行去重
el = hashTreeUtil.duplicateRegexInAssertions(finalEnvConfig.getAssertions(), (MsAssertions) el);
}

View File

@ -199,6 +199,7 @@
<ms-debug-tcp-page
:currentProtocol="currentProtocol"
:testCase="item.api"
:scenario="false"
@saveAs="editApi"
@refreshModule="refreshModule"
v-if="currentProtocol==='TCP'"/>

View File

@ -23,9 +23,8 @@
<ms-basis-parameters :request="request" ref="requestForm"/>
<!-- 请求返回数据 -->
<p class="tip">{{ $t('api_test.definition.request.res_param') }} </p>
<ms-request-result-tail v-if="!loading" :response="responseData" :currentProtocol="currentProtocol" ref="debugResult"/>
<ms-request-result-tail v-if="!loading" :response="responseData" :currentProtocol="currentProtocol" ref="debugResult"/>
</div>
<ms-jmx-step :request="request" :response="responseData"/>
<!-- 执行组件 -->
<ms-run :debug="true" :reportId="reportId" :isStop="isStop" :run-data="runData" @runRefresh="runRefresh" ref="runTest"/>
</el-card>
@ -48,7 +47,6 @@ import {createComponent} from "../jmeter/components";
import {REQ_METHOD} from "../../model/JsonData";
import MsRequestResultTail from "../response/RequestResultTail";
import MsBasisParameters from "../request/dubbo/BasisParameters";
import MsJmxStep from "../step/JmxStep";
import MsApiCaseList from "../case/ApiCaseList";
import {TYPE_TO_C} from "@/business/components/api/automation/scenario/Setting";
@ -61,7 +59,6 @@ export default {
MsResponseText,
MsRun,
MsBasisParameters,
MsJmxStep,
MsApiCaseList
},
props: {

View File

@ -25,7 +25,6 @@
<p class="tip">{{ $t('api_test.definition.request.res_param') }} </p>
<ms-request-result-tail v-if="!loading" :response="responseData" :currentProtocol="currentProtocol" ref="debugResult"/>
</div>
<ms-jmx-step :request="request" :response="responseData"/>
<!-- 执行组件 -->
<ms-run :debug="true" :reportId="reportId" :isStop="isStop" :run-data="runData" @runRefresh="runRefresh" ref="runTest"/>
@ -50,7 +49,6 @@ import {createComponent} from "../jmeter/components";
import {REQ_METHOD} from "../../model/JsonData";
import MsRequestResultTail from "../response/RequestResultTail";
import MsBasisParameters from "../request/database/BasisParameters";
import MsJmxStep from "../step/JmxStep";
import MsApiCaseList from "../case/ApiCaseList";
import {TYPE_TO_C} from "@/business/components/api/automation/scenario/Setting";
@ -63,7 +61,6 @@ export default {
MsResponseText,
MsRun,
MsBasisParameters,
MsJmxStep,
MsApiCaseList
},
props: {

View File

@ -35,10 +35,8 @@
<ms-tcp-format-parameters :request="request" @callback="runDebug" ref="requestForm"/>
<!-- TCP 请求返回数据 -->
<p class="tip">{{ $t('api_test.definition.request.res_param') }} </p>
<ms-request-result-tail v-if="!loading" :response="responseData" :currentProtocol="currentProtocol" ref="debugResult"/>
<ms-request-result-tail v-if="!loading" :response="responseData" :currentProtocol="currentProtocol" ref="debugResult"/>
</div>
<ms-jmx-step :request="request" :response="responseData"/>
<!-- 执行组件 -->
<ms-run :debug="true" :reportId="reportId" :isStop="isStop" :run-data="runData" @runRefresh="runRefresh" ref="runTest"/>
</el-card>
@ -63,14 +61,12 @@ import {createComponent} from "../jmeter/components";
import {REQ_METHOD} from "../../model/JsonData";
import MsRequestResultTail from "../response/RequestResultTail";
import MsTcpFormatParameters from "@/business/components/api/definition/components/request/tcp/TcpFormatParameters";
import MsJmxStep from "../step/JmxStep";
import MsApiCaseList from "../case/ApiCaseList";
import {TYPE_TO_C} from "@/business/components/api/automation/scenario/Setting";
export default {
name: "ApiConfig",
components: {
MsJmxStep,
MsTcpFormatParameters,
MsRequestResultTail, MsResponseResult, MsApiRequestForm, MsRequestMetric, MsResponseText, MsRun, MsApiCaseList
},
@ -162,7 +158,9 @@ export default {
this.responseData = data;
this.loading = false;
this.isStop = false;
this.$refs.debugResult.reload();
if (this.$refs.debugResult) {
this.$refs.debugResult.reload();
}
},
saveAsApi() {
let obj = {request: this.request};