fix(接口测试): 修复场景引用TCP协议接口执行问题
--bug=1013501 --user=赵勇 【接口测试】场景中引用带报文长度的TCP接口,无请求体 https://www.tapd.cn/55049933/s/1165573
This commit is contained in:
parent
7ba67fd715
commit
e371746775
|
@ -121,32 +121,10 @@ public class MsTCPSampler extends MsTestElement {
|
||||||
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, MsParameter msParameter) {
|
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, MsParameter msParameter) {
|
||||||
ParameterConfig config = (ParameterConfig) msParameter;
|
ParameterConfig config = (ParameterConfig) msParameter;
|
||||||
|
|
||||||
//检查request
|
|
||||||
if (StringUtils.isNotEmpty(reportType)) {
|
|
||||||
switch (reportType) {
|
|
||||||
case "json":
|
|
||||||
if(StringUtils.isNotEmpty(this.jsonDataStruct)){
|
|
||||||
request = this.jsonDataStruct;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "xml":
|
|
||||||
if(CollectionUtils.isNotEmpty(this.xmlDataStruct)){
|
|
||||||
request = TcpTreeTableDataParser.treeTableData2Xml(this.xmlDataStruct);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "raw":
|
|
||||||
if(StringUtils.isNotEmpty(this.rawDataStruct)){
|
|
||||||
request = this.rawDataStruct;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 非导出操作,且不是启用状态则跳过执行
|
// 非导出操作,且不是启用状态则跳过执行
|
||||||
if (!config.isOperating() && !this.isEnable()) {
|
if (!config.isOperating() && !this.isEnable()) {
|
||||||
return;
|
return;
|
||||||
}else if(config.isOperating() && StringUtils.isNotEmpty(config.getOperatingSampleTestName())){
|
} else if (config.isOperating() && StringUtils.isNotEmpty(config.getOperatingSampleTestName())) {
|
||||||
this.setName(config.getOperatingSampleTestName());
|
this.setName(config.getOperatingSampleTestName());
|
||||||
}
|
}
|
||||||
if (this.getReferenced() != null && MsTestElementConstants.REF.name().equals(this.getReferenced())) {
|
if (this.getReferenced() != null && MsTestElementConstants.REF.name().equals(this.getReferenced())) {
|
||||||
|
@ -157,10 +135,32 @@ public class MsTCPSampler extends MsTestElement {
|
||||||
}
|
}
|
||||||
hashTree = this.getHashTree();
|
hashTree = this.getHashTree();
|
||||||
}
|
}
|
||||||
|
//检查request
|
||||||
|
if (StringUtils.isNotEmpty(reportType)) {
|
||||||
|
switch (reportType) {
|
||||||
|
case "json":
|
||||||
|
if (StringUtils.isNotEmpty(this.jsonDataStruct)) {
|
||||||
|
request = this.jsonDataStruct;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "xml":
|
||||||
|
if (CollectionUtils.isNotEmpty(this.xmlDataStruct)) {
|
||||||
|
request = TcpTreeTableDataParser.treeTableData2Xml(this.xmlDataStruct);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "raw":
|
||||||
|
if (StringUtils.isNotEmpty(this.rawDataStruct)) {
|
||||||
|
request = this.rawDataStruct;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (config.getConfig() == null) {
|
if (config.getConfig() == null) {
|
||||||
// 单独接口执行
|
// 单独接口执行
|
||||||
this.setProjectId(config.getProjectId());
|
this.setProjectId(config.getProjectId());
|
||||||
config.setConfig(ElementUtil.getEnvironmentConfig(useEnvironment, this.getProjectId(), this.isMockEnvironment()));
|
config.setConfig(ElementUtil.getEnvironmentConfig(StringUtils.isNotEmpty(this.getEnvironmentId()) ? this.getEnvironmentId() : useEnvironment, this.getProjectId(), this.isMockEnvironment()));
|
||||||
}
|
}
|
||||||
EnvironmentConfig envConfig = null;
|
EnvironmentConfig envConfig = null;
|
||||||
if (config.getConfig() != null) {
|
if (config.getConfig() != null) {
|
||||||
|
@ -301,10 +301,10 @@ 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());
|
||||||
|
|
||||||
if(StringUtils.equalsIgnoreCase("LengthPrefixedBinaryTCPClientImpl",this.classname)){
|
if (StringUtils.equalsIgnoreCase("LengthPrefixedBinaryTCPClientImpl", this.classname)) {
|
||||||
//LengthPrefixedBinaryTCPClientImpl取样器不可以设置eolByte
|
//LengthPrefixedBinaryTCPClientImpl取样器不可以设置eolByte
|
||||||
this.eolByte = null;
|
this.eolByte = null;
|
||||||
}else {
|
} else {
|
||||||
tcpSampler.setEolByte(this.getEolByte());
|
tcpSampler.setEolByte(this.getEolByte());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -414,7 +414,7 @@ public class MsTCPSampler extends MsTestElement {
|
||||||
configTestElement.setProperty(TCPSampler.NODELAY, this.isNodelay());
|
configTestElement.setProperty(TCPSampler.NODELAY, this.isNodelay());
|
||||||
configTestElement.setProperty(TCPSampler.CLOSE_CONNECTION, this.isCloseConnection());
|
configTestElement.setProperty(TCPSampler.CLOSE_CONNECTION, this.isCloseConnection());
|
||||||
configTestElement.setProperty(TCPSampler.SO_LINGER, this.getSoLinger());
|
configTestElement.setProperty(TCPSampler.SO_LINGER, this.getSoLinger());
|
||||||
if(!StringUtils.equalsIgnoreCase("LengthPrefixedBinaryTCPClientImpl",this.classname)){
|
if (!StringUtils.equalsIgnoreCase("LengthPrefixedBinaryTCPClientImpl", this.classname)) {
|
||||||
configTestElement.setProperty(TCPSampler.EOL_BYTE, this.getEolByte());
|
configTestElement.setProperty(TCPSampler.EOL_BYTE, this.getEolByte());
|
||||||
}
|
}
|
||||||
configTestElement.setProperty(TCPSampler.SO_LINGER, this.getSoLinger());
|
configTestElement.setProperty(TCPSampler.SO_LINGER, this.getSoLinger());
|
||||||
|
|
|
@ -533,11 +533,12 @@ export default {
|
||||||
this.singleLoading = true;
|
this.singleLoading = true;
|
||||||
this.singleRunId = row.id;
|
this.singleRunId = row.id;
|
||||||
row.request.name = row.id;
|
row.request.name = row.id;
|
||||||
if (row.apiMethod !== "SQL" && row.apiMethod !== "DUBBO" && row.apiMethod !== "dubbo://" && row.apiMethod !== "TCP") {
|
if (row.apiMethod !== "SQL" && row.apiMethod !== "DUBBO" && row.apiMethod !== "dubbo://") {
|
||||||
row.request.useEnvironment = this.environment;
|
row.request.useEnvironment = this.environment;
|
||||||
} else {
|
} else {
|
||||||
row.request.useEnvironment = row.request.environmentId;
|
row.request.useEnvironment = row.request.environmentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
row.request.projectId = this.projectId;
|
row.request.projectId = this.projectId;
|
||||||
row.request.id = row.id;
|
row.request.id = row.id;
|
||||||
this.runData.push(row.request);
|
this.runData.push(row.request);
|
||||||
|
|
Loading…
Reference in New Issue