abstracta / jmeter-java-dsl

Simple JMeter performance tests API
https://abstracta.github.io/jmeter-java-dsl/
Apache License 2.0
477 stars 59 forks source link

Wrong exception message? #211

Closed mikeliucc closed 1 year ago

mikeliucc commented 1 year ago

Saw the following error message when running my test:

Ramping up/down after holding for iterations is not supported. If you used constructor with iterations, consider using threadGroup().rampTo(X, Y).holdForIterations(Z) instead

However, I don't find a holdForIterations() method. Perhaps the error message is wrong?

rabelenda commented 1 year ago

Can you provide the sample thread group configuration you are using?

mikeliucc commented 1 year ago

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();
rabelenda commented 1 year ago

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.

mikeliucc commented 1 year ago

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?

rabelenda commented 1 year ago

Yes you are right! I will fix it. And will try for the message to be a little more explantory.

rabelenda commented 1 year ago

The exception message has been improved in latest release.