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

Add support to Stepping Thread Group #252

Closed yioyoiyioys222 closed 11 months ago

yioyoiyioys222 commented 11 months ago

Screenshot: image

rabelenda commented 11 months ago

Hello @yioyoiyioys222. Thanks for asking about this.

Is there any particular scenario that you would like the DSL to support?

You can achieve the same as stepping thread group with existing api, with a little of java code.

For example, to create a thread group that creates 100 threads with 10 threads every 10 seconds using ramp ups of 2 seconds with an initial delay of 5 seconds, holds final load for 30 seconds, and ramp down all threads in 5 seconds you could do something like this:

    DslDefaultThreadGroup tg = threadGroup()
        .holdFor(Duration.ofSeconds(5));
    for (int i=0; i < 100/10; i++) {
      tg.rampToAndHold(10, Duration.ofSeconds(2), Duration.ofSeconds(10));
    }
    tg.holdFor(Duration.ofSeconds(30 - 10))
      .rampTo(0, Duration.ofSeconds(5));

    testPlan(
      tg.children(
        httpSampler("http://example.com")
      )
    ).run();
yioyoiyioys222 commented 11 months ago

Okay, thank you.