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.