public class DslDefaultThreadGroup extends BaseThreadGroup<DslDefaultThreadGroup>
For complex thread profiles that can't be mapped to JMeter built-in thread group element, the DSL uses Ultimate Thread Group plugin
Modifier and Type | Class and Description |
---|---|
static class |
DslDefaultThreadGroup.CodeBuilder |
BaseThreadGroup.SampleErrorAction, BaseThreadGroup.ThreadGroupChild
Modifier and Type | Field and Description |
---|---|
protected List<Stage> |
stages |
sampleErrorAction
children
guiClass, name
Constructor and Description |
---|
DslDefaultThreadGroup(String name) |
DslDefaultThreadGroup(String name,
int threads,
Duration duration,
List<BaseThreadGroup.ThreadGroupChild> children) |
DslDefaultThreadGroup(String name,
int threads,
int iterations,
List<BaseThreadGroup.ThreadGroupChild> children) |
Modifier and Type | Method and Description |
---|---|
org.apache.jmeter.threads.AbstractThreadGroup |
buildThreadGroup() |
DslDefaultThreadGroup |
children(BaseThreadGroup.ThreadGroupChild... children)
Allows specifying thread group children elements (samplers, listeners, post processors, etc.).
|
DslDefaultThreadGroup |
holdFor(Duration duration)
Specifies to keep current number of threads for a given duration.
|
DslDefaultThreadGroup |
holdFor(String duration)
Same as
holdFor(Duration) but allowing to use JMeter expressions (variables or
functions) to solve the duration. |
DslDefaultThreadGroup |
holdIterating(int iterations)
Specifies to keep current number of threads until they execute the given number of iterations
each.
|
DslDefaultThreadGroup |
holdIterating(String iterations)
Same as
holdIterating(int) but allowing to use JMeter expressions (variables or
functions) to solve the iterations. |
DslDefaultThreadGroup |
rampTo(int threadCount,
Duration duration)
Allows ramping up or down threads with a given duration.
|
DslDefaultThreadGroup |
rampTo(String threadCount,
String duration)
Same as
rampTo(int, Duration) but allowing to use JMeter expressions (variables or
functions) to solve the actual parameter values. |
DslDefaultThreadGroup |
rampToAndHold(int threads,
Duration rampDuration,
Duration holdDuration)
simply combines
rampTo(int, Duration) and holdFor(Duration) which are usually
used in combination. |
DslDefaultThreadGroup |
rampToAndHold(String threads,
String rampDuration,
String holdDuration)
Same as
rampToAndHold(int, Duration, Duration) but allowing to use JMeter expressions
(variables or functions) to solve the actual parameter values. |
void |
showTimeline()
Shows a graph with a timeline of planned threads count execution for this test plan.
|
buildTestElement, sampleErrorAction
buildTreeUnder
buildConfiguredTestElement, buildTestElementGui, configureTestElement, durationToSeconds, loadBeanProperties, showAndWaitFrameWith, showFrameWith, showInGui, showTestElementGui
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
buildTreeUnder, showInGui
public DslDefaultThreadGroup(String name, int threads, int iterations, List<BaseThreadGroup.ThreadGroupChild> children)
public DslDefaultThreadGroup(String name, int threads, Duration duration, List<BaseThreadGroup.ThreadGroupChild> children)
public DslDefaultThreadGroup(String name)
public DslDefaultThreadGroup rampTo(int threadCount, Duration duration)
It is usually advised to use this method when working with considerable amount of threads to avoid load of creating all the threads at once to affect test results.
JMeter will create (or remove) a thread every rampUp.seconds * 1000 / threadCount
milliseconds.
If you specify a thread duration time (instead of iterations), take into consideration that ramp up is not considered as part of thread duration time. For example: if you have a thread group duration of 10 seconds, and a ramp-up of 10 seconds, the last threads (and the test plan run) will run at least (duration may vary depending on test plan contents) after 20 seconds of starting the test.
You can use this method multiple times in a thread group and in conjunction with
holdFor(Duration)
and rampToAndHold(int, Duration, Duration)
to elaborate
complex test plan profiles.
Eg:
threadGroup()
.rampTo(10, Duration.ofSeconds(10))
.rampTo(5, Duration.ofSeconds(10))
.rampToAndHold(20, Duration.ofSeconds(5), Duration.ofSeconds(10))
.rampTo(0, Duration.ofSeconds(5))
.children(...)
threadCount
- specifies the final number of threads after the given period.duration
- duration taken to reach the given threadCount and move to the next stage or
end the test plan. Since JMeter only supports specifying times in seconds,
if you specify a smaller granularity (like milliseconds) it will be rounded
up to seconds.IllegalStateException
- if used after an iterations stage, since JMeter does not provide
built-in thread group to support such scenario.public DslDefaultThreadGroup rampTo(String threadCount, String duration)
rampTo(int, Duration)
but allowing to use JMeter expressions (variables or
functions) to solve the actual parameter values.
This is usually used in combination with properties to define values that change between environments or different test runs. Eg:
rampTo("${THREADS}", "${RAMP}"
.
This method can only be used for simple thread group configurations. Allowed combinations are: rampTo, rampTo + holdFor, holdFor + rampTo + holdFor, rampTo + holdIterating, holdFor + rampTo + holdIterating.
threadCount
- a JMeter expression that returns the number of threads to ramp to.duration
- a JMeter expression that returns the number of seconds to take for the
ramp.rampTo(int, Duration)
public DslDefaultThreadGroup holdFor(Duration duration)
This method is usually used in combination with rampTo(int, Duration)
to define the
profile of the test plan.
duration
- duration to hold the current number of threads until moving to next stage or
ending the test plan. Since JMeter only supports specifying times in seconds,
if you specify a smaller granularity (like milliseconds) it will be rounded up
to seconds.rampTo(int, Duration)
public DslDefaultThreadGroup holdFor(String duration)
holdFor(Duration)
but allowing to use JMeter expressions (variables or
functions) to solve the duration.
This is usually used in combination with properties to define values that change between environments or different test runs. Eg:
holdFor("${DURATION}"
.
This method can only be used for simple thread group configurations. Allowed combinations are: rampTo, rampTo + holdFor, holdFor + rampTo + holdFor, rampTo + holdIterating, holdFor + rampTo + holdIterating.
duration
- a JMeter expression that returns the number of seconds to hold current thread
groups.holdFor(Duration)
public DslDefaultThreadGroup holdIterating(int iterations)
Warning: holding for iterations can be added to a thread group that has an initial stage with 0 threads followed by a stage ramping up, or only a stage ramping up, or no stages at all.
iterations
- number of iterations to execute the test plan steps each thread.
If you specify -1, then threads will iterate until test plan execution is interrupted (you manually stop the running process, there is an error and thread group is configured to stop on error, or some other explicit termination condition).
Setting this property to -1 is in general not advised, since you might inadvertently end up running a test plan without limits consuming unnecessary computing power. Prefer specifying a big value as a safe limit for iterations or duration instead.
IllegalStateException
- when adding iterations would result in not supported JMeter
thread group.public DslDefaultThreadGroup holdIterating(String iterations)
holdIterating(int)
but allowing to use JMeter expressions (variables or
functions) to solve the iterations.
This is usually used in combination with properties to define values that change between environments or different test runs. Eg:
holdIterating("${ITERATIONS}"
.
This method can only be used for simple thread group configurations. Allowed combinations are: rampTo, rampTo + holdFor, holdFor + rampTo + holdFor, rampTo + holdIterating, holdFor + rampTo + holdIterating.
iterations
- a JMeter expression that returns the number of iterations for current threads
to execute.holdIterating(int)
public DslDefaultThreadGroup rampToAndHold(int threads, Duration rampDuration, Duration holdDuration)
rampTo(int, Duration)
and holdFor(Duration)
which are usually
used in combination.threads
- number of threads to ramp threads up/down to.rampDuration
- duration taken to reach the given threadCount to start holding that number
of threads.holdDuration
- duration to hold the given number of threads, after the ramp, until moving
to next stage or ending the test plan.rampTo(int, Duration)
,
holdFor(Duration)
public DslDefaultThreadGroup rampToAndHold(String threads, String rampDuration, String holdDuration)
rampToAndHold(int, Duration, Duration)
but allowing to use JMeter expressions
(variables or functions) to solve the actual parameter values.
This is usually used in combination with properties to define values that change between environments or different test runs. Eg:
rampToAndHold("${THREADS}", "${RAMP}" ,"${DURATION}"
.
This method can only be used for simple thread group configurations. Allowed combinations are: rampTo, rampTo + holdFor, holdFor + rampTo + holdFor, rampTo + holdIterating, holdFor + rampTo + holdIterating.
threads
- a JMeter expression that returns the number of threads to ramp to.rampDuration
- a JMeter expression that returns the number of seconds to take for the
ramp.holdDuration
- a JMeter expression that returns the number of seconds to hold current
thread groups.rampToAndHold(int, Duration, Duration)
public DslDefaultThreadGroup children(BaseThreadGroup.ThreadGroupChild... children)
This method is just an alternative to the constructor specification of children, and is handy when you want to keep general thread group settings together and then specify children (instead of specifying threadCount & duration/iterations, then children, and at the end alternative settings like ramp-up period).
children
in class BaseThreadGroup<DslDefaultThreadGroup>
children
- list of test elements to add as children of the thread group.public org.apache.jmeter.threads.AbstractThreadGroup buildThreadGroup()
buildThreadGroup
in class BaseThreadGroup<DslDefaultThreadGroup>
public void showTimeline()
The graph will be displayed in a popup window.
This method is provided mainly to ease test plan designing when working with complex thread group profiles (several stages with ramps and holds).
Copyright © 2023. All rights reserved.