fix(接口测试): 修复TCP接口测试超时时间不生效的问题

--bug=1008379 --user=宋天阳 【github#7974】tcp接口的请求时间和响应时间不起作用
https://www.tapd.cn/55049933/s/1113826
This commit is contained in:
song-tianyang 2022-03-04 14:29:54 +08:00 committed by CountryBuilder
parent 8f753b3217
commit cb9402a075
2 changed files with 16 additions and 2 deletions

View File

@ -227,7 +227,7 @@ public class MsTCPSampler extends MsTestElement {
} }
private void parseEnvironment(EnvironmentConfig config) { private void parseEnvironment(EnvironmentConfig config) {
if (!isCustomizeReq() && config != null) { if (!isCustomizeReq() && config != null && config.getTcpConfig() != null) {
if (!isCustomizeReq() && config != null) { if (!isCustomizeReq() && config != null) {
this.server = config.getTcpConfig().getServer(); this.server = config.getTcpConfig().getServer();
this.port = config.getTcpConfig().getPort(); this.port = config.getTcpConfig().getPort();
@ -238,6 +238,14 @@ public class MsTCPSampler extends MsTestElement {
this.eolByte = config.getTcpConfig().getEolByte(); this.eolByte = config.getTcpConfig().getEolByte();
} }
} }
if ((StringUtils.isEmpty(this.timeout) || StringUtils.equals(this.timeout, "0")) && StringUtils.isNotEmpty(config.getTcpConfig().getTimeout())) {
this.timeout = config.getTcpConfig().getTimeout();
}
if (StringUtils.isEmpty(this.ctimeout) || StringUtils.equals(this.ctimeout, "0") && StringUtils.isNotEmpty(config.getTcpConfig().getCtimeout())) {
this.ctimeout = config.getTcpConfig().getCtimeout();
}
} }
} }
} }
@ -265,6 +273,12 @@ public class MsTCPSampler extends MsTestElement {
tcpSampler.setCloseConnection(String.valueOf(this.isCloseConnection())); tcpSampler.setCloseConnection(String.valueOf(this.isCloseConnection()));
tcpSampler.setSoLinger(this.getSoLinger()); tcpSampler.setSoLinger(this.getSoLinger());
tcpSampler.setEolByte(this.getEolByte()); tcpSampler.setEolByte(this.getEolByte());
if (StringUtils.isNotEmpty(this.timeout)) {
tcpSampler.setTimeout(this.timeout);
}
if (StringUtils.isNotEmpty(this.ctimeout)) {
tcpSampler.setConnectTimeout(this.ctimeout);
}
String value = this.getRequest(); String value = this.getRequest();
if (StringUtils.isNotEmpty(this.getConnectEncoding())) { if (StringUtils.isNotEmpty(this.getConnectEncoding())) {

View File

@ -111,7 +111,7 @@
<el-divider></el-divider> <el-divider></el-divider>
<p class="tip">{{ $t('api_test.definition.request.req_param') }} </p> <p class="tip">{{ $t('api_test.definition.request.req_param') }} </p>
<ms-api-request-form :isShowEnable="true" :showScript="true" :headers="apiCase.request.headers " :response="apiCase.responseData" :request="apiCase.request" v-if="api.protocol==='HTTP'"/> <ms-api-request-form :isShowEnable="true" :showScript="true" :headers="apiCase.request.headers " :response="apiCase.responseData" :request="apiCase.request" v-if="api.protocol==='HTTP'"/>
<tcp-format-parameters :showScript="true" :request="apiCase.request" v-if="api.method==='TCP' && apiCase.request.esbDataStruct == null"/> <tcp-format-parameters :showScript="true" :request="apiCase.request" v-if="api.method==='TCP'"/>
<esb-definition v-xpack :request="apiCase.request" :showScript="true" v-if="isXpack&&api.method==='ESB'" ref="esbDefinition"/> <esb-definition v-xpack :request="apiCase.request" :showScript="true" v-if="isXpack&&api.method==='ESB'" ref="esbDefinition"/>
<ms-sql-basis-parameters :showScript="true" :request="apiCase.request" v-if="api.protocol==='SQL'"/> <ms-sql-basis-parameters :showScript="true" :request="apiCase.request" v-if="api.protocol==='SQL'"/>
<ms-dubbo-basis-parameters :showScript="true" :request="apiCase.request" v-if="api.protocol==='DUBBO'"/> <ms-dubbo-basis-parameters :showScript="true" :request="apiCase.request" v-if="api.protocol==='DUBBO'"/>