I am tying MQTT jmeter sampler plugin but it is throwing NullPointerException - jmeter

2014/12/10 15:39:52 INFO - jmeter.gui.action.Start: Stopping test
2014/12/10 15:39:52 INFO - jmeter.threads.JMeterThread: Stopping: Thread Group 1-1
2014/12/10 15:39:52 WARN - jmeter.threads.JMeterThread: Interrupting: Thread Group 1-1 sampler: MQTT Subscriber
2014/12/10 15:39:52 WARN - jmeter.protocol.mqtt.sampler.SubscriberSampler: java.lang.NullPointerException
at org.fusesource.mqtt.client.CallbackConnection$8.onSuccess(CallbackConnection.java:501)
at org.fusesource.mqtt.client.CallbackConnection$8.onSuccess(CallbackConnection.java:490)
at org.fusesource.mqtt.client.CallbackConnection.disconnect(CallbackConnection.java:514)
at org.apache.jmeter.protocol.mqtt.client.MqttSubscriber.close(MqttSubscriber.java:298)
at org.apache.jmeter.protocol.mqtt.sampler.SubscriberSampler.interrupt(SubscriberSampler.java:164)
at org.apache.jmeter.threads.JMeterThread.interrupt(JMeterThread.java:631)
at org.apache.jmeter.threads.ThreadGroup.tellThreadsToStop(ThreadGroup.java:392)
Using mosquitto client I am able to subscribe and publish. But on Jmeter its not wokring.
Thanks, In advance

It's a bug in the plugin you're using.
Try this more up to date plugin:
https://github.com/hemikak/mqtt-jmeter

Related

How will I use Throughput Shaping Timer from Jmeter API using java code?

I want to use the Throughput Shaping Timer using JMeter API in my java code.
My purpose is to to use Throughput Shaping Timer via JMeter API in my code programmatically.
I have already referenced the class file called VariableThroughputTimer.java by adding it to the source directory of my project folder.
Here is a part of my code snippet:
// VariableThroughputTimer
VariableThroughputTimer timer = new VariableThroughputTimer();
timer.setEnabled(true);
timer.setName("VariableThroughputTimer");
timer.setProperty("Start RPS", 1);
timer.setProperty("End RPS", 1000);
timer.setProperty("Duration", 60);
timer.setComment("Table below sets request rate shcedule ant preview graph instantly shows effect of changes.");
timer.setProperty(TestElement.TEST_CLASS, kg.apc.jmeter.vizualizers.CorrectedResultCollector.class.getName());
timer.setProperty(TestElement.GUI_CLASS, kg.apc.jmeter.vizualizers.TransactionsPerSecondGui.class.getName());
// Thread Group
ThreadGroup threadGroup = new ThreadGroup();
threadGroup.setName("Thread Group");
threadGroup.setNumThreads(4);
threadGroup.setRampUp(1);
threadGroup.setDuration(1);;
threadGroup.setSamplerController(loopController);
threadGroup.setSamplerController(PublishController);
threadGroup.setProperty(TestElement.TEST_CLASS, ThreadGroup.class.getName());
threadGroup.setProperty(TestElement.GUI_CLASS, ThreadGroupGui.class.getName());
// Test Plan
TestPlan testPlan = new TestPlan("IOT_Jmeter");
testPlan.setProperty(TestElement.TEST_CLASS, TestPlan.class.getName());
testPlan.setProperty(TestElement.GUI_CLASS, TestPlanGui.class.getName());
testPlan.setUserDefinedVariables((Arguments) new ArgumentsPanel().createTestElement());
// HTTP Request Sampler and Header Manager
HashTree httpRequestTree = new HashTree();
httpRequestTree.add(mqttConnectSampler);
httpRequestTree.add(mqttpubSampler);
httpRequestTree.add(csvDataSet);
httpRequestTree.add(timer);
So whenever, I try to execute the code. It doesn't execute.
Here are the logs from my eclipse IDE:
2019-02-12 16:13:28 [main] INFO StandardJMeterEngine:453 - Starting ThreadGroup: 1 : Thread Group
2019-02-12 16:13:28 [main] INFO StandardJMeterEngine:513 - Starting 4 threads for group Thread Group.
2019-02-12 16:13:28 [main] INFO StandardJMeterEngine:523 - Thread will continue on error
2019-02-12 16:13:28 [main] INFO ThreadGroup:222 - Starting thread group... number=1 threads=4 ramp-up=1 perThread=250.0 delayedStart=false
2019-02-12 16:13:28 [main] INFO ThreadGroup:236 - Started thread group number 1
2019-02-12 16:13:28 [main] INFO StandardJMeterEngine:464 - All thread groups have been started
2019-02-12 16:13:28 [Thread Group 1-1] INFO JMeterThread:705 - Thread started: Thread Group 1-1
2019-02-12 16:13:28 [Thread Group 1-1] INFO FileServer:265 - Stored: C:\Users\angshuman.basak\Downloads\apache-jmeter-5.0\csvDataNew.csv
2019-02-12 16:13:28 [Thread Group 1-1] INFO VariableThroughputTimer:304 - No further RPS schedule, asking threads to stop...
2019-02-12 16:13:28 [Thread Group 1-1] INFO VariableThroughputTimer:319 - Stopping gracefuly threads of Thread Group : Thread Group
2019-02-12 16:13:28 [Thread Group 1-1] INFO JMeterThread:797 - Stopping: Thread Group 1-2
2019-02-12 16:13:28 [Thread Group 1-1] INFO JMeterThread:797 - Stopping: Thread Group 1-3
2019-02-12 16:13:28 [Thread Group 1-1] INFO JMeterThread:797 - Stopping: Thread Group 1-4
2019-02-12 16:13:28 [Thread Group 1-1] INFO JMeterThread:797 - Stopping: Thread Group 1-1
2019-02-12 16:13:28 [Thread Group 1-1] WARN VariableThroughputTimer:147 - No free threads available in current Thread Group Thread Group, made 0 samples/s for expected rps 1.0 samples/s, increase your number of threads
2019-02-12 16:13:28 [Thread Group 1-1] INFO JMeterThread:324 - Thread finished: Thread Group 1-1
2019-02-12 16:13:29 [Thread Group 1-2] INFO JMeterThread:705 - Thread started: Thread Group 1-2
2019-02-12 16:13:29 [Thread Group 1-2] INFO JMeterThread:324 - Thread finished: Thread Group 1-2
2019-02-12 16:13:29 [Thread Group 1-3] INFO JMeterThread:705 - Thread started: Thread Group 1-3
2019-02-12 16:13:29 [Thread Group 1-3] INFO JMeterThread:324 - Thread finished: Thread Group 1-3
2019-02-12 16:13:29 [Thread Group 1-4] INFO JMeterThread:705 - Thread started: Thread Group 1-4
2019-02-12 16:13:29 [Thread Group 1-4] INFO JMeterThread:324 - Thread finished: Thread Group 1-4
2019-02-12 16:13:29 [main] INFO StandardJMeterEngine:223 - Notifying test listeners of end of test
2019-02-12 16:13:29 [main] INFO FileServer:485 - Close: C:\Users\angshuman.basak\Downloads\apache-jmeter-5.0\csvDataNew.csv
2019-02-12 16:13:29 [main] INFO Summariser:327 - summary = 0 in 00:00:00 = ******/s Avg: 0 Min: 9223372036854775807 Max: -9223372036854775808 Err: 0 (0.00%)
summary = 0 in 00:00:00 = ******/s Avg: 0 Min: 9223372036854775807 Max: -9223372036854775808 Err: 0 (0.00%)
The above Summariser represent that the test didn't get executed. From the above logs the Variable Throughput Timer fetches the below:
2019-02-12 16:13:28 [Thread Group 1-1] INFO VariableThroughputTimer:304 - No further RPS schedule, asking threads to stop...
2019-02-12 16:13:28 [Thread Group 1-1] INFO VariableThroughputTimer:319 - Stopping gracefully threads of Thread Group: Thread Group
2019-02-12 16:13:28 [Thread Group 1-1] WARN VariableThroughputTimer:147 - No free threads available in current Thread Group Thread Group, made 0 samples/s for expected rps 1.0 samples/s, increase your number of threads
I want to execute the code with Throughput Shaping Timer programmatically. I would like to have the correct code for VariableThroughputTimer if my implementation is incorrect or resolve the execution issue.
Your aid is really appreciated.
How do you plan to reach 1000 requests per second with 4 threads only? It might be possible only if you have 4 milliseconds response time which is highly unlikely.
As per log entry you should
Thread Group Thread Group, made 0 samples/s for expected rps 1.0 samples/s, increase your number of threads`
also make sure to configure underlying Loop Controller to iterate forever.
Going forward consider using Concurrency Thread Group which can be connected with the Throughput Shaping Timer using Schedule Feedback function so JMeter will be able to kick off extra threads if the current amount is not enough to reach/maintain the target throughput. Check out Using JMeter’s Throughput Shaping Timer Plugin article for more details.
Your Thread Group configuration isn't appropriate according to your required Throughput. As your required throughput is 1000 RPS, you need at-least 1000 threads if the response time is 1 second. If the response time is 0.5 seconds then you need 500 threads to achieve 1000 RPS. So, You can't achieve that 1000 RPS by using only 4 threads. Your response time have to be .004 seconds(4 ms) to achieve 1000 RPS using only 4 threads which is an unusual thing.
You have set your test duration only for 1 seconds which is also wrong for this case.

Spring Integration-Load test the tcp server using Jmeter

I am trying to load test my tcp server which is created using spring integration using JMeter. I am able to establish the connection with the server using TcpSampler in JMeter, but the server is unable to receive the text sent.
Below are my logs
INFO o.a.j.e.StandardJMeterEngine: Running the test!
INFO o.a.j.s.SampleEvent: List of sample_variables: []
INFO o.a.j.g.u.JMeterMenuBar: setRunning(true, *local*)
INFO o.a.j.e.StandardJMeterEngine: Starting ThreadGroup: 1 : Thread Group
INFO o.a.j.e.StandardJMeterEngine: Starting 1 threads for group Thread Group.
INFO o.a.j.e.StandardJMeterEngine: Test will stop abruptly on error
INFO o.a.j.t.ThreadGroup: Starting thread group... number=1 threads=1 ramp-up=1 perThread=1000.0 delayedStart=false
INFO o.a.j.t.ThreadGroup: Started thread group number 1
INFO o.a.j.e.StandardJMeterEngine: All thread groups have been started
INFO o.a.j.t.JMeterThread: Thread started: Thread Group 1-1
INFO o.a.j.p.t.s.TCPClientImpl: Using platform default charset:UTF-8
TcpServer accepts ByteArrayCrLfSerializer
In Jmeter, what should be EOL byte value?
Add a JSR223 Pre-Processor under your sampler with following code:
vars.put("LF",URLDecoder.decode("%0A", "ASCII"));
vars.put("CR",URLDecoder.decode("%0D", "ASCII"));
Then append to your TCP message:
${CR}${LF}

Getting exception while using jp#gc Graphs Generator

I am new to Jmeter and getting java.lang.ClassNotFoundException:kg.apc.jmeter.vizualizers.SynthesisReportGui when using jp#gc Graph generator plugin in Jmeter v 3.0. Please help.
I am trying to run Jmeter in GUI mode.Jmeter configuration Image
I have placed following jars in lib:
jmeter-plugins-graphs-ggl-2.0.jar
cmdrunner-2.0.jar
jmeter-plugins-cmn-jmeter-0.3.jar
and following in ext folder:
jmeter-plugins-graphs-ggl-2.0.jar
jmeter-plugins-manager-0.10.jar
cmdrunner-2.0.jar
jmeter-plugins-cmn-jmeter-0.3.jar
jmeter-plugins-cmd-2.1.jar
Following is the log:
2017/02/13 18:31:09 INFO - jmeter.engine.StandardJMeterEngine: All thread groups have been started
2017/02/13 18:31:09 INFO - jmeter.threads.JMeterThread: Thread started: CIC_Perf_Wall 1-2
2017/02/13 18:31:09 INFO - jmeter.threads.JMeterThread: Thread started: CIC_Perf_Wall 1-1
2017/02/13 18:31:09 INFO - jmeter.threads.JMeterThread: Thread started: CIC_Perf_Wall 1-5
2017/02/13 18:31:09 INFO - jmeter.threads.JMeterThread: Thread started: CIC_Perf_Wall 1-3
2017/02/13 18:31:09 INFO - jmeter.threads.JMeterThread: Thread started: CIC_Perf_Wall 1-4
2017/02/13 18:31:18 INFO - jmeter.threads.JMeterThread: Thread is done: CIC_Perf_Wall 1-3
2017/02/13 18:31:18 INFO - jmeter.threads.JMeterThread: Thread finished: CIC_Perf_Wall 1-3
2017/02/13 18:31:18 INFO - jmeter.threads.JMeterThread: Thread is done: CIC_Perf_Wall 1-1
2017/02/13 18:31:18 INFO - jmeter.threads.JMeterThread: Thread finished: CIC_Perf_Wall 1-1
2017/02/13 18:31:18 INFO - jmeter.threads.JMeterThread: Thread is done: CIC_Perf_Wall 1-4
2017/02/13 18:31:18 INFO - jmeter.threads.JMeterThread: Thread finished: CIC_Perf_Wall 1-4
2017/02/13 18:31:18 INFO - jmeter.threads.JMeterThread: Thread is done: CIC_Perf_Wall 1-2
2017/02/13 18:31:18 INFO - jmeter.threads.JMeterThread: Thread finished: CIC_Perf_Wall 1-2
2017/02/13 18:31:18 INFO - jmeter.threads.JMeterThread: Thread is done: CIC_Perf_Wall 1-5
2017/02/13 18:31:18 INFO - jmeter.threads.JMeterThread: Thread finished: CIC_Perf_Wall 1-5
2017/02/13 18:31:18 INFO - jmeter.engine.StandardJMeterEngine: Notifying test listeners of end of test
2017/02/13 18:31:18 INFO - jmeter.config.KeystoreConfig: Destroying Keystore
2017/02/13 18:31:18 INFO - kg.apc.jmeter.PluginsCMDWorker: Using JMeterPluginsCMD v. N/A
2017/02/13 18:31:18 WARN - kg.apc.jmeter.JMeterPluginsUtils: JMeter env exists. No one should see this normally.
2017/02/13 18:31:18 WARN - jmeter.engine.StandardJMeterEngine: Error encountered during shutdown of kg.apc.jmeter.listener.GraphsGeneratorListener#215ff3c0 java.lang.RuntimeException: java.lang.ClassNotFoundException: kg.apc.jmeter.vizualizers.SynthesisReportGui
at kg.apc.jmeter.PluginsCMDWorker.getGUIObject(PluginsCMDWorker.java:237)
at kg.apc.jmeter.PluginsCMDWorker.getGUIObject(PluginsCMDWorker.java:234)
at kg.apc.jmeter.PluginsCMDWorker.setPluginType(PluginsCMDWorker.java:73)
at kg.apc.jmeter.listener.GraphsGeneratorListener.testEnded(GraphsGeneratorListener.java:221)
at kg.apc.jmeter.listener.GraphsGeneratorListener.testEnded(GraphsGeneratorListener.java:137)
at org.apache.jmeter.engine.StandardJMeterEngine.notifyTestListenersOfEnd(StandardJMeterEngine.java:215)
at org.apache.jmeter.engine.StandardJMeterEngine.run(StandardJMeterEngine.java:436)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: kg.apc.jmeter.vizualizers.SynthesisReportGui
2017/02/13 18:31:18 INFO - jmeter.gui.util.JMeterMenuBar: setRunning(false,*local*)
Jmeter configuration Image
The error you're getting is about missing Synthesis Report plugin, you need to:
download it from https://jmeter-plugins.org/?search=jpgc-synthesis
drop to lib/ext folder of your JMeter installation
restart JMeter to pick up the plugin
Another (better) way of installing the plugins and keeping them up-to-date is using JMeter Plugins Manager

JMeter testing SOAP web service programmatically

Using JMeter APIs, I tried to call a SOAP web service programmatically.
After executing the service, when I checked the web service server logs, no transaction / entry is made over there. It seems the SOAP request did not send to the server at all. But, when I tried to invoke the web service directly using SOAPConnection call() method, with out JMeter APIs, it is working fine and server could generate logs.
Could any one please check it out and correct me on sending SOAP requests using JMeter APIs?
My full source code is as follows:
JMeterUtils.setJMeterHome("JmeterHome");
JMeterUtils.loadJMeterProperties("JmeterHome\\bin\\jmeter.properties");
JMeterUtils.initLogging();
JMeterUtils.initLocale();
HashTree testPlanTree=new HashTree();
HTTPSampler httpSampler=new HTTPSampler();
httpSampler.setDomain("domain");
httpSampler.setPort(<port number>);
httpSampler.setProtocol("http");
httpSampler.setPath("/wsdl");
httpSampler.setMethod("GET");
httpSampler.setName("Webservice Sampler");
httpSampler.setPostBodyRaw(true);
HeaderManager headerManager=new HeaderManager();
headerManager.add(new Header("SM_USER", "xyz#abc.com"));
headerManager.add(new Header("Content-Type","text/xml; charset=utf-8"));
headerManager.add(new Header("SOAPAction","http://example.com:<port number>/services/MyWebService?wsdl"));
httpSampler.setHeaderManager(headerManager);
HTTPArgument httpArgument=new HTTPArgument();
httpArgument.setValue(<SOAP Message>);
httpSampler.addTestElement(httpArgument);
LoopController loopController=new LoopController();
loopController.setLoops(1);
loopController.addTestElement(httpSampler);
loopController.setFirst(true);
loopController.initialize();
ThreadGroup threadGroup=new ThreadGroup();
threadGroup.setNumThreads(5);
threadGroup.setRampUp(1);
threadGroup.setSamplerController(loopController);
TestPlan testPlan=new TestPlan("Web Service Operations Test Plan");
testPlanTree.add("testPlan", testPlan);
testPlanTree.add("threadGroup",threadGroup);
testPlanTree.add("httpSampler",httpSampler);
testPlanTree.add("loopController",loopController);
SaveService.saveTree(testPlanTree, new FileOutputStream("jmeter_api.jmx"));
Summariser summary=null;
String summariserName=JMeterUtils.getPropDefault("summariser.name", "summary");
if (summariserName.length() > 0) {
summary = new Summariser(summariserName);
}
String reportFile = "report.jtl";
ResultCollector logger = new ResultCollector(summary);
logger.setFilename(reportFile);
testPlanTree.add(testPlanTree.getArray()[0], logger);
jmeter.configure(testPlanTree);
jmeter.run();
System.exit(0);
I am getting the following output in the Jmeter log file:
2017/01/10 19:50:14 INFO - jmeter.threads.JMeterThread: Thread finished: 1-1
2017/01/10 19:50:14 INFO - jmeter.threads.JMeterThread: Thread is done: 1-3
2017/01/10 19:50:14 INFO - jmeter.threads.JMeterThread: Thread finished: 1-3
2017/01/10 19:50:14 INFO - jmeter.threads.JMeterThread: Thread is done: 1-4
2017/01/10 19:50:14 INFO - jmeter.threads.JMeterThread: Thread finished: 1-4
2017/01/10 19:50:14 INFO - jmeter.threads.JMeterThread: Thread is done: 1-5
2017/01/10 19:50:14 INFO - jmeter.threads.JMeterThread: Thread finished: 1-5
2017/01/10 19:50:14 INFO - jmeter.engine.StandardJMeterEngine: Notifying test listeners of end of test
2017/01/10 19:50:14 INFO - jmeter.reporters.Summariser: summary = 5 in 00:00:02 = 3.1/s Avg: 877 Min: 780 Max: 1088 Err: 0 (0.00%)
The following results captured on result file:
2017-01-10 19:50:13.070,894, Webservice Sampler,200,OK, 1-2,text,true,,35016,0,5,5,887,0,0
2017-01-10 19:50:13.070,1088, Webservice Sampler,200,OK, 1-1,text,true,,35016,0,5,5,1082,0,0
2017-01-10 19:50:13.466,813, Webservice Sampler,200,OK, 1-3,text,true,,35016,0,3,3,806,0,0
2017-01-10 19:50:13.666,780, Webservice Sampler,200,OK, 1-4,text,true,,35016,0,2,2,776,0,0
2017-01-10 19:50:13.866,811, Webservice Sampler,200,OK, 1-5,text,true,,35016,0,1,1,802,0,0
You are going not recommended way of creating a JMeter test, check out Building a WebService Test Plan to learn how to do it using JMeter GUI.
If for some reason you need to create a SOAP request programmatically, you can get a known good test plan hashtree structure by calling SaveService.loadTree() method passing an existing .jmx script as a parameter so you will have a reference test plan in your debugger which you can re-create using JMeter API.
You can find an example of adding a Header Manager to the HTTP Request here
In any case I would strongly recommend to double check that the script is doing what it is supposed to be doing via View Results Tree listener or with a sniffer tool like Wireshark

HTTP Request Sampler not working

I am using windows7 and the latest version of Jmeter. I created a simple HTTP Request Sampler and in the server name I added google.com
When I ran it I got the following error:
2015/11/30 14:15:32 INFO - jmeter.engine.StandardJMeterEngine: Running the test!
2015/11/30 14:15:32 INFO - jmeter.samplers.SampleEvent: List of sample_variables: []
2015/11/30 14:15:32 INFO - jmeter.gui.util.JMeterMenuBar: setRunning(true,*local*)
2015/11/30 14:15:32 INFO - jmeter.engine.StandardJMeterEngine: Starting ThreadGroup: 1 : Thread Group
2015/11/30 14:15:32 INFO - jmeter.engine.StandardJMeterEngine: Starting 1 threads for group Thread Group.
2015/11/30 14:15:32 INFO - jmeter.engine.StandardJMeterEngine: Thread will continue on error
2015/11/30 14:15:32 INFO - jmeter.threads.ThreadGroup: Starting thread group number 1 threads 1 ramp-up 1 perThread 1000.0 delayedStart=false
2015/11/30 14:15:32 INFO - jmeter.threads.ThreadGroup: Started thread group number 1
2015/11/30 14:15:32 INFO - jmeter.engine.StandardJMeterEngine: All thread groups have been started
2015/11/30 14:15:32 INFO - jmeter.threads.JMeterThread: Thread started: Thread Group 1-1
2015/11/30 14:15:33 INFO - jmeter.threads.JMeterThread: Thread is done: Thread Group 1-1
2015/11/30 14:15:33 INFO - jmeter.threads.JMeterThread: Thread finished: Thread Group 1-1
2015/11/30 14:15:33 INFO - jmeter.engine.StandardJMeterEngine: Notifying test listeners of end of test
2015/11/30 14:15:33 INFO - jmeter.gui.util.JMeterMenuBar: setRunning(false,*local*)
This is normal output of JMeter, it indicates that JMeter started and finished one thread one time.
You can visualize test results with Listeners, in particular View Results Tree is extremely useful for test script development and debugging.
As you can see at below image:
the request is successful (green triangle)
google search page is displayed at "Response data" tab
log viewer contains the same entries as you posted
Don't forget to disable listeners for the actual test execution, they consume a lot of resources. You'll be able to open results file after test run using "Browse" button and perform analysis.
See How to debug your Apache JMeter script article for detailed information on getting to the bottom of JMeter test script problem.

Resources