Closed mikeliucc closed 1 year ago
Can you provide the sample thread group configuration you are using?
Sure! Here's a sample:
List<ThreadGroupChild> threadGroupChildren = new ArrayList<>();
threadGroupChildren.add(csvDataSet(new TestResource("testdata.csv")).randomOrder(true));
threadGroupChildren.add(httpSampler("mytest", "https://mycompany.com/api?a=b&c=d&e=f"));
int threads = 10;
int iterations = 100;
List<TestPlanChild> planItems = newTestPlanItems(testPlanName);
planItems.add(uniformRandomTimer(Duration.ofSeconds(1), Duration.ofSeconds(5)));
planItems.add(
threadGroup("mytest", threads, iterations, threadGroupChildren.toArray(new ThreadGroupChild[0]))
.rampTo(threads / 2, Duration.ofSeconds(threads * 2L))
.holdIterating(100)
);
testPlan(planItems.toArray(new TestPlanChild[0])).run();
You are specifying iterations in threadGroup creation and then configuring rampTo. Basically your test nowadays says:
Start 10 threads and iterate 100 times each. Ramp down to 5 threads for 20 seconds. Hold iterating such threads for 100 times each.
Is this what you actually wanted to emulate?
There is no way currently with JMeter DSL to do that as is. Basically, you can delay (optional), ramp up (optional), and then iterate, but not iterate and then do something else. You can use duration execution (eg: delay, ramp, hold duration, ramp, hold duration, etc) for complex scenarios.
If you actually need to emulate above scenario, how do you usually do it with JMeter GUI?
One option might be using loop controllers, but the behavior would not be the same considering cookies, cache, etc.
Ah... once again, I misunderstood the doc/intent here.
I changed to the following and now it works:
planItems.add(threadGroup(testName)
.rampTo(threads / 2, Duration.ofSeconds(threads * 2L))
.holdIterating(iterations)
.children(threadGroupChildren.toArray(new ThreadGroupChild[0]))
Thank you!
However, the error message still looks confusing... There isn't a method named holdForIterations()
. Should it be holdIterating()
instead?
Yes you are right! I will fix it. And will try for the message to be a little more explantory.
The exception message has been improved in latest release.
Saw the following error message when running my test:
However, I don't find a
holdForIterations()
method. Perhaps the error message is wrong?