Reputation: 7980
I've a Spring Boot server running on my localhost:8181 and I can make GET requests to it with success and I see the logs printed out.
Now I made a proof of concept for a load test. I'm using the JMeter Java API to send requests to the Spring Boot server using the Java API from JMeter. JMeter runs the test suite and no errors are reported but on my server I so no incoming requests.
Here's the load test code I'm using:
public class Main {
public static void main(String... args) {
// Engine
StandardJMeterEngine jm = new StandardJMeterEngine();
JMeterUtils.setJMeterHome("C:\\Users\\daz\\Desktop\\apache-jmeter-3.2");
// jmeter.properties
String jmeterProperties = Main.class.getClassLoader().getResource("jmeter.properties").toString().replace("file:", "");
JMeterUtils.loadJMeterProperties(jmeterProperties);
HashTree hashTree = new HashTree();
// HTTP Sampler
HTTPSampler httpSampler = new HTTPSampler();
httpSampler.setDomain("localhost");
httpSampler.setPort(8181);
httpSampler.setPath("/job/test");
httpSampler.setMethod("GET");
// Loop Controller
LoopController loopController = new LoopController();
loopController.setLoops(1);
loopController.addTestElement(httpSampler);
loopController.setFirst(true);
loopController.initialize();
// Thread Group
SetupThreadGroup threadGroup = new SetupThreadGroup();
threadGroup.setNumThreads(2);
threadGroup.setRampUp(1);
threadGroup.setSamplerController(loopController);
// Test plan
TestPlan testPlan = new TestPlan("MY TEST SUITE");
// Construct Test Plan from previously initialized elements
hashTree.add("testPlan", testPlan);
hashTree.add("loopController", loopController);
hashTree.add("threadGroup", threadGroup);
hashTree.add("httpSampler", httpSampler);
jm.configure(hashTree);
jm.run();
}
}
Can someone help me spot out what is missing/wrong here as this code is not making the requests as expected?
------------- EDIT -------------
Using Summariser
I get the following output:
summary = 0 in 00:00:00 = ******/s Avg: 0 Min: 9223372036854775807 Max: -9223372036854775808 Err: 0 (0,00%)
Which I believe to mean that no requests where made, as I suspected.
Upvotes: 0
Views: 713
Reputation: 168002
You are constructing your test plan a little bit wrong, you need to use the following code:
hashTree.add(testPlan);
HashTree threadGroupHashTree = hashTree.add(testPlan, threadGroup);
threadGroupHashTree.add(httpSampler);
Apart from this everything looks more or less fine.
References:
You can also look at jmeter-from-code demo project to see how to build an example Test Plan using JMeter API
Upvotes: 1