fix(接口测试): 修复空指针bug
This commit is contained in:
parent
fecc4c4a7e
commit
759e6e7f0d
|
@ -4,16 +4,16 @@ import lombok.Data;
|
|||
|
||||
@Data
|
||||
public class TCPConfig {
|
||||
private String classname;
|
||||
private String server;
|
||||
private String port;
|
||||
private String ctimeout;
|
||||
private String timeout;
|
||||
private boolean reUseConnection;
|
||||
private String classname = "";
|
||||
private String server = "";
|
||||
private String port = "";
|
||||
private String ctimeout = "";
|
||||
private String timeout = "";
|
||||
private boolean reUseConnection = true;
|
||||
private boolean nodelay;
|
||||
private boolean closeConnection;
|
||||
private String soLinger;
|
||||
private String eolByte;
|
||||
private String username;
|
||||
private String password;
|
||||
private String soLinger = "";
|
||||
private String eolByte = "";
|
||||
private String username = "";
|
||||
private String password = "";
|
||||
}
|
||||
|
|
|
@ -12,15 +12,15 @@ public class TCPRequest extends Request {
|
|||
// type 必须放最前面,以便能够转换正确的类
|
||||
private String type = RequestType.TCP;
|
||||
@JSONField(ordinal = 51)
|
||||
private String classname;
|
||||
private String classname = "";
|
||||
@JSONField(ordinal = 52)
|
||||
private String server;
|
||||
private String server = "";
|
||||
@JSONField(ordinal = 53)
|
||||
private String port;
|
||||
private String port = "";
|
||||
@JSONField(ordinal = 54)
|
||||
private String ctimeout;
|
||||
private String ctimeout = "";
|
||||
@JSONField(ordinal = 55)
|
||||
private String timeout;
|
||||
private String timeout = "";
|
||||
@JSONField(ordinal = 56)
|
||||
private boolean reUseConnection;
|
||||
@JSONField(ordinal = 57)
|
||||
|
@ -28,13 +28,13 @@ public class TCPRequest extends Request {
|
|||
@JSONField(ordinal = 58)
|
||||
private boolean closeConnection;
|
||||
@JSONField(ordinal = 59)
|
||||
private String soLinger;
|
||||
private String soLinger = "";
|
||||
@JSONField(ordinal = 60)
|
||||
private String eolByte;
|
||||
private String eolByte = "";
|
||||
@JSONField(ordinal = 61)
|
||||
private String request;
|
||||
private String request = "";
|
||||
@JSONField(ordinal = 62)
|
||||
private String username;
|
||||
private String username = "";
|
||||
@JSONField(ordinal = 63)
|
||||
private String password;
|
||||
private String password = "";
|
||||
}
|
||||
|
|
|
@ -10,6 +10,9 @@ import io.metersphere.api.dto.scenario.environment.EnvironmentConfig;
|
|||
import io.metersphere.api.dto.scenario.environment.Host;
|
||||
import io.metersphere.api.dto.scenario.extract.*;
|
||||
import io.metersphere.api.dto.scenario.request.*;
|
||||
import io.metersphere.api.dto.scenario.request.dubbo.ConfigCenter;
|
||||
import io.metersphere.api.dto.scenario.request.dubbo.ConsumerAndService;
|
||||
import io.metersphere.api.dto.scenario.request.dubbo.RegistryCenter;
|
||||
import io.metersphere.api.service.ApiTestEnvironmentService;
|
||||
import io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
|
@ -90,6 +93,8 @@ public class JMXGenerator {
|
|||
databaseConfigMap.put(databaseConfig.getId(), databaseConfig.getName());
|
||||
});
|
||||
}
|
||||
// DUBBO Config
|
||||
threadGroupHashTree.add(dubboConfig(scenario.getName() + "DUBBO Config", scenario.getDubboConfig()));
|
||||
// 场景TCP Config
|
||||
threadGroupHashTree.add(tcpConfig(scenario.getName() + "TCP Config", scenario.getTcpConfig()));
|
||||
|
||||
|
@ -356,6 +361,53 @@ public class JMXGenerator {
|
|||
return dataSourceElement;
|
||||
}
|
||||
|
||||
private ConfigTestElement dubboConfig(String name, DubboConfig dubboConfig) {
|
||||
ConfigTestElement configTestElement = new ConfigTestElement();
|
||||
configTestElement.setEnabled(true);
|
||||
configTestElement.setName(name);
|
||||
configTestElement.setProperty(TestElement.TEST_CLASS, ConfigTestElement.class.getName());
|
||||
configTestElement.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("DubboDefaultConfigGui"));
|
||||
configTestElement.addConfigElement(configCenter(dubboConfig.getConfigCenter()));
|
||||
configTestElement.addConfigElement(registryCenter(dubboConfig.getRegistryCenter()));
|
||||
configTestElement.addConfigElement(consumerAndService(dubboConfig.getConsumerAndService()));
|
||||
return configTestElement;
|
||||
}
|
||||
|
||||
private ConfigTestElement configCenter(ConfigCenter configCenter) {
|
||||
ConfigTestElement configTestElement = new ConfigTestElement();
|
||||
Constants.setConfigCenterProtocol(configCenter.getProtocol(), configTestElement);
|
||||
Constants.setConfigCenterGroup(configCenter.getGroup(), configTestElement);
|
||||
Constants.setConfigCenterNamespace(configCenter.getNamespace(), configTestElement);
|
||||
Constants.setConfigCenterUserName(configCenter.getUsername(), configTestElement);
|
||||
Constants.setConfigCenterPassword(configCenter.getPassword(), configTestElement);
|
||||
Constants.setConfigCenterAddress(configCenter.getAddress(), configTestElement);
|
||||
Constants.setConfigCenterTimeout(configCenter.getTimeout(), configTestElement);
|
||||
return configTestElement;
|
||||
}
|
||||
|
||||
private ConfigTestElement registryCenter(RegistryCenter registryCenter) {
|
||||
ConfigTestElement configTestElement = new ConfigTestElement();
|
||||
Constants.setRegistryProtocol(registryCenter.getProtocol(), configTestElement);
|
||||
Constants.setRegistryGroup(registryCenter.getGroup(), configTestElement);
|
||||
Constants.setRegistryUserName(registryCenter.getUsername(), configTestElement);
|
||||
Constants.setRegistryPassword(registryCenter.getPassword(), configTestElement);
|
||||
Constants.setRegistryTimeout(registryCenter.getTimeout(), configTestElement);
|
||||
Constants.setAddress(registryCenter.getAddress(), configTestElement);
|
||||
return configTestElement;
|
||||
}
|
||||
|
||||
private ConfigTestElement consumerAndService(ConsumerAndService consumerAndService) {
|
||||
ConfigTestElement configTestElement = new ConfigTestElement();
|
||||
Constants.setTimeout(consumerAndService.getTimeout(), configTestElement);
|
||||
Constants.setVersion(consumerAndService.getVersion(), configTestElement);
|
||||
Constants.setGroup(consumerAndService.getGroup(), configTestElement);
|
||||
Constants.setConnections(consumerAndService.getConnections(), configTestElement);
|
||||
Constants.setLoadbalance(consumerAndService.getLoadBalance(), configTestElement);
|
||||
Constants.setAsync(consumerAndService.getAsync(), configTestElement);
|
||||
Constants.setCluster(consumerAndService.getCluster(), configTestElement);
|
||||
return configTestElement;
|
||||
}
|
||||
|
||||
private ConfigTestElement tcpConfig(String name, TCPConfig tcpConfig) {
|
||||
ConfigTestElement configTestElement = new ConfigTestElement();
|
||||
configTestElement.setEnabled(true);
|
||||
|
@ -537,28 +589,9 @@ public class JMXGenerator {
|
|||
sampler.setProperty(TestElement.TEST_CLASS, DubboSample.class.getName());
|
||||
sampler.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("DubboSampleGui"));
|
||||
|
||||
Constants.setConfigCenterProtocol(request.getConfigCenter().getProtocol(), sampler);
|
||||
Constants.setConfigCenterGroup(request.getConfigCenter().getGroup(), sampler);
|
||||
Constants.setConfigCenterNamespace(request.getConfigCenter().getNamespace(), sampler);
|
||||
Constants.setConfigCenterUserName(request.getConfigCenter().getUsername(), sampler);
|
||||
Constants.setConfigCenterPassword(request.getConfigCenter().getPassword(), sampler);
|
||||
Constants.setConfigCenterAddress(request.getConfigCenter().getAddress(), sampler);
|
||||
Constants.setConfigCenterTimeout(request.getConfigCenter().getTimeout(), sampler);
|
||||
|
||||
Constants.setRegistryProtocol(request.getRegistryCenter().getProtocol(), sampler);
|
||||
Constants.setRegistryGroup(request.getRegistryCenter().getGroup(), sampler);
|
||||
Constants.setRegistryUserName(request.getRegistryCenter().getUsername(), sampler);
|
||||
Constants.setRegistryPassword(request.getRegistryCenter().getPassword(), sampler);
|
||||
Constants.setRegistryTimeout(request.getRegistryCenter().getTimeout(), sampler);
|
||||
Constants.setAddress(request.getRegistryCenter().getAddress(), sampler);
|
||||
|
||||
Constants.setTimeout(request.getConsumerAndService().getTimeout(), sampler);
|
||||
Constants.setVersion(request.getConsumerAndService().getVersion(), sampler);
|
||||
Constants.setGroup(request.getConsumerAndService().getGroup(), sampler);
|
||||
Constants.setConnections(request.getConsumerAndService().getConnections(), sampler);
|
||||
Constants.setLoadbalance(request.getConsumerAndService().getLoadBalance(), sampler);
|
||||
Constants.setAsync(request.getConsumerAndService().getAsync(), sampler);
|
||||
Constants.setCluster(request.getConsumerAndService().getCluster(), sampler);
|
||||
sampler.addTestElement(configCenter(request.getConfigCenter()));
|
||||
sampler.addTestElement(registryCenter(request.getRegistryCenter()));
|
||||
sampler.addTestElement(consumerAndService(request.getConsumerAndService()));
|
||||
|
||||
Constants.setRpcProtocol(request.getProtocol(), sampler);
|
||||
Constants.setInterfaceName(request.get_interface(), sampler);
|
||||
|
|
|
@ -46,6 +46,7 @@ public class JMeterService {
|
|||
|
||||
public void run(String testId, String testName, List<Scenario> scenarios, String debugReportId) {
|
||||
try {
|
||||
init();
|
||||
HashTree testPlan = getHashTree(testId, testName, scenarios);
|
||||
JMeterVars.addJSR223PostProcessor(testPlan);
|
||||
addBackendListener(testId, debugReportId, testPlan);
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#---------------------------------------------------------
|
||||
# SAVESERVICE PROPERTIES - JMETER INTERNAL USE ONLY
|
||||
#---------------------------------------------------------
|
||||
|
||||
## Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
## contributor license agreements. See the NOTICE file distributed with
|
||||
## this work for additional information regarding copyright ownership.
|
||||
|
@ -16,16 +15,11 @@
|
|||
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
## See the License for the specific language governing permissions and
|
||||
## limitations under the License.
|
||||
|
||||
# This file is used to define how XStream (de-)serializes classnames
|
||||
# in JMX test plan files.
|
||||
|
||||
# FOR JMETER INTERNAL USE ONLY
|
||||
|
||||
#---------------------------------------------------------
|
||||
|
||||
# N.B. To ensure backward compatibility, please do NOT change or delete any entries
|
||||
|
||||
# New entries can be added as necessary.
|
||||
#
|
||||
# Note that keys starting with an underscore are special,
|
||||
|
@ -134,6 +128,7 @@ DNSCacheManager=org.apache.jmeter.protocol.http.control.DNSCacheManager
|
|||
DNSCachePanel=org.apache.jmeter.protocol.http.gui.DNSCachePanel
|
||||
DubboSample=io.github.ningyu.jmeter.plugin.dubbo.sample.DubboSample
|
||||
DubboSampleGui=io.github.ningyu.jmeter.plugin.dubbo.gui.DubboSampleGui
|
||||
DubboDefaultConfigGui=io.github.ningyu.jmeter.plugin.dubbo.gui.DubboDefaultConfigGui
|
||||
DurationAssertion=org.apache.jmeter.assertions.DurationAssertion
|
||||
DurationAssertionGui=org.apache.jmeter.assertions.gui.DurationAssertionGui
|
||||
PreciseThroughputTimer=org.apache.jmeter.timers.poissonarrivals.PreciseThroughputTimer
|
||||
|
@ -244,10 +239,8 @@ ModuleController=org.apache.jmeter.control.ModuleController
|
|||
ModuleControllerGui=org.apache.jmeter.control.gui.ModuleControllerGui
|
||||
MongoScriptSampler=org.apache.jmeter.protocol.mongodb.sampler.MongoScriptSampler
|
||||
MongoSourceElement=org.apache.jmeter.protocol.mongodb.config.MongoSourceElement
|
||||
|
||||
# removed in 3.2, class was deleted in r
|
||||
MonitorHealthVisualizer=org.apache.jmeter.visualizers.MonitorHealthVisualizer
|
||||
|
||||
NamePanel=org.apache.jmeter.gui.NamePanel
|
||||
BoltSampler=org.apache.jmeter.protocol.bolt.sampler.BoltSampler
|
||||
BoltConnectionElement=org.apache.jmeter.protocol.bolt.config.BoltConnectionElement
|
||||
|
@ -303,12 +296,10 @@ SMIMEAssertion=org.apache.jmeter.assertions.SMIMEAssertionTestElement
|
|||
SMIMEAssertionGui=org.apache.jmeter.assertions.gui.SMIMEAssertionGui
|
||||
SmtpSampler=org.apache.jmeter.protocol.smtp.sampler.SmtpSampler
|
||||
SmtpSamplerGui=org.apache.jmeter.protocol.smtp.sampler.gui.SmtpSamplerGui
|
||||
|
||||
# removed in 3.2, class was deleted in r
|
||||
SoapSampler=org.apache.jmeter.protocol.http.sampler.SoapSampler
|
||||
# removed in 3.2, class was deleted in r
|
||||
SoapSamplerGui=org.apache.jmeter.protocol.http.control.gui.SoapSamplerGui
|
||||
|
||||
# removed in 3.1, class was deleted in r1763837
|
||||
SplineVisualizer=org.apache.jmeter.visualizers.SplineVisualizer
|
||||
# Originally deleted in r397955 as class is obsolete; needed for compat.
|
||||
|
@ -377,7 +368,6 @@ XPathExtractor=org.apache.jmeter.extractor.XPathExtractor
|
|||
XPathExtractorGui=org.apache.jmeter.extractor.gui.XPathExtractorGui
|
||||
XPath2Extractor=org.apache.jmeter.extractor.XPath2Extractor
|
||||
XPath2ExtractorGui=org.apache.jmeter.extractor.gui.XPath2ExtractorGui
|
||||
|
||||
# Properties - all start with lower case letter and end with Prop
|
||||
#
|
||||
boolProp=org.apache.jmeter.testelement.property.BooleanProperty
|
||||
|
@ -402,7 +392,6 @@ httpSample=org.apache.jmeter.protocol.http.sampler.HTTPSampleResult
|
|||
statSample=org.apache.jmeter.samplers.StatisticalSampleResult
|
||||
testResults=org.apache.jmeter.save.TestResultWrapper
|
||||
assertionResult=org.apache.jmeter.assertions.AssertionResult
|
||||
|
||||
# removed in 3.2, class was deleted in r
|
||||
monitorStats=org.apache.jmeter.visualizers.MonitorStats
|
||||
sampleEvent=org.apache.jmeter.samplers.SampleEvent
|
||||
|
|
Loading…
Reference in New Issue