Class DslDefaultThreadGroup
- java.lang.Object
-
- us.abstracta.jmeter.javadsl.core.testelements.BaseTestElement
-
- us.abstracta.jmeter.javadsl.core.testelements.TestElementContainer<T,BaseThreadGroup.ThreadGroupChild>
-
- us.abstracta.jmeter.javadsl.core.threadgroups.BaseThreadGroup<DslDefaultThreadGroup>
-
- us.abstracta.jmeter.javadsl.core.threadgroups.DslDefaultThreadGroup
-
- All Implemented Interfaces:
DslTestElement,DslTestPlan.TestPlanChild,DslThreadGroup
public class DslDefaultThreadGroup extends BaseThreadGroup<DslDefaultThreadGroup>
Represents the standard thread group test element included by JMeter.For complex thread profiles that can't be mapped to JMeter built-in thread group element, the DSL uses Ultimate Thread Group plugin
- Since:
- 0.1
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDslDefaultThreadGroup.CodeBuilder-
Nested classes/interfaces inherited from class us.abstracta.jmeter.javadsl.core.threadgroups.BaseThreadGroup
BaseThreadGroup.SampleErrorAction, BaseThreadGroup.ThreadGroupChild
-
-
Field Summary
Fields Modifier and Type Field Description protected List<Stage>stages-
Fields inherited from class us.abstracta.jmeter.javadsl.core.threadgroups.BaseThreadGroup
sampleErrorAction
-
Fields inherited from class us.abstracta.jmeter.javadsl.core.testelements.TestElementContainer
children
-
Fields inherited from class us.abstracta.jmeter.javadsl.core.testelements.BaseTestElement
guiClass, name
-
-
Constructor Summary
Constructors Constructor Description DslDefaultThreadGroup(String name)DslDefaultThreadGroup(String name, int threads, int iterations, List<BaseThreadGroup.ThreadGroupChild> children)DslDefaultThreadGroup(String name, int threads, Duration duration, List<BaseThreadGroup.ThreadGroupChild> children)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LoadTimeLinebuildLoadTimeline()This method is used byDslTestPlan.showTimeline()to get the timeline chart for this thread group.org.apache.jmeter.threads.AbstractThreadGroupbuildThreadGroup()DslDefaultThreadGroupchildren(BaseThreadGroup.ThreadGroupChild... children)Allows specifying thread group children elements (samplers, listeners, post processors, etc.).DslDefaultThreadGroupholdFor(String duration)Same asholdFor(Duration)but allowing to use JMeter expressions (variables or functions) to solve the duration.DslDefaultThreadGroupholdFor(Duration duration)Specifies to keep current number of threads for a given duration.DslDefaultThreadGroupholdIterating(int iterations)Specifies to keep current number of threads until they execute the given number of iterations each.DslDefaultThreadGroupholdIterating(String iterations)Same asholdIterating(int)but allowing to use JMeter expressions (variables or functions) to solve the iterations.DslDefaultThreadGrouprampTo(int threadCount, Duration duration)Allows ramping up or down threads with a given duration.DslDefaultThreadGrouprampTo(String threadCount, String duration)Same asrampTo(int, Duration)but allowing to use JMeter expressions (variables or functions) to solve the actual parameter values.DslDefaultThreadGrouprampToAndHold(int threads, Duration rampDuration, Duration holdDuration)simply combinesrampTo(int, Duration)andholdFor(Duration)which are usually used in combination.DslDefaultThreadGrouprampToAndHold(String threads, String rampDuration, String holdDuration)Same asrampToAndHold(int, Duration, Duration)but allowing to use JMeter expressions (variables or functions) to solve the actual parameter values.voidshowTimeline()Shows a graph with a timeline of planned threads count execution for this test plan.DslDefaultThreadGroupupTo(Duration duration)Specifies to stop thread group if iterations take more than specified duration.-
Methods inherited from class us.abstracta.jmeter.javadsl.core.threadgroups.BaseThreadGroup
buildTestElement, sampleErrorAction
-
Methods inherited from class us.abstracta.jmeter.javadsl.core.testelements.TestElementContainer
buildTreeUnder
-
Methods inherited from class us.abstracta.jmeter.javadsl.core.testelements.BaseTestElement
buildConfiguredTestElement, buildTestElementGui, configureTestElement, durationToSeconds, loadBeanProperties, showAndWaitFrameWith, showFrameWith, showInGui, showTestElementGui
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface us.abstracta.jmeter.javadsl.core.DslTestElement
buildTreeUnder, showInGui
-
-
-
-
Constructor Detail
-
DslDefaultThreadGroup
public DslDefaultThreadGroup(String name, int threads, int iterations, List<BaseThreadGroup.ThreadGroupChild> children)
-
DslDefaultThreadGroup
public DslDefaultThreadGroup(String name, int threads, Duration duration, List<BaseThreadGroup.ThreadGroupChild> children)
-
DslDefaultThreadGroup
public DslDefaultThreadGroup(String name)
-
-
Method Detail
-
rampTo
public DslDefaultThreadGroup rampTo(int threadCount, Duration duration)
Allows ramping up or down threads with a given 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 / threadCountmilliseconds.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)andrampToAndHold(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(...)- Parameters:
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.- Returns:
- the thread group for further configuration or usage.
- Throws:
IllegalStateException- if used after an iterations stage, since JMeter does not provide built-in thread group to support such scenario.- Since:
- 0.18
-
rampTo
public DslDefaultThreadGroup rampTo(String threadCount, String duration)
Same asrampTo(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.
- Parameters:
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.- Returns:
- the thread group for further configuration or usage.
- Since:
- 0.57
- See Also:
rampTo(int, Duration)
-
holdFor
public DslDefaultThreadGroup holdFor(Duration duration)
Specifies to keep current number of threads for a given duration.This method is usually used in combination with
rampTo(int, Duration)to define the profile of the test plan.- Parameters:
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.- Returns:
- the thread group for further configuration or usage.
- Since:
- 0.18
- See Also:
rampTo(int, Duration)
-
holdFor
public DslDefaultThreadGroup holdFor(String duration)
Same asholdFor(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.
- Parameters:
duration- a JMeter expression that returns the number of seconds to hold current thread groups.- Returns:
- the thread group for further configuration or usage.
- Since:
- 0.57
- See Also:
holdFor(Duration)
-
holdIterating
public DslDefaultThreadGroup holdIterating(int iterations)
Specifies to keep current number of threads until they execute the given number of iterations each.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.
- Parameters:
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.
- Returns:
- the thread group for further configuration or usage.
- Throws:
IllegalStateException- when adding iterations would result in not supported JMeter thread group.- Since:
- 0.18
-
holdIterating
public DslDefaultThreadGroup holdIterating(String iterations)
Same asholdIterating(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.
- Parameters:
iterations- a JMeter expression that returns the number of iterations for current threads to execute.- Returns:
- the thread group for further configuration or usage.
- Since:
- 0.57
- See Also:
holdIterating(int)
-
upTo
public DslDefaultThreadGroup upTo(Duration duration)
Specifies to stop thread group if iterations take more than specified duration.Note: This method should only be used after specifying iterations.
- Parameters:
duration- specifies a maximum duration for thread execution when threads are iterating.- Returns:
- the thread group for further configuration or usage.
- Since:
- 1.24
-
rampToAndHold
public DslDefaultThreadGroup rampToAndHold(int threads, Duration rampDuration, Duration holdDuration)
simply combinesrampTo(int, Duration)andholdFor(Duration)which are usually used in combination.- Parameters:
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.- Returns:
- the thread group for further configuration or usage.
- Since:
- 0.18
- See Also:
rampTo(int, Duration),holdFor(Duration)
-
rampToAndHold
public DslDefaultThreadGroup rampToAndHold(String threads, String rampDuration, String holdDuration)
Same asrampToAndHold(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.
- Parameters:
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.- Returns:
- the thread group for further configuration or usage.
- Since:
- 0.57
- See Also:
rampToAndHold(int, Duration, Duration)
-
children
public DslDefaultThreadGroup children(BaseThreadGroup.ThreadGroupChild... children)
Allows specifying thread group children elements (samplers, listeners, post processors, etc.).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).
- Overrides:
childrenin classBaseThreadGroup<DslDefaultThreadGroup>- Parameters:
children- list of test elements to add as children of the thread group.- Returns:
- the thread group for further configuration or usage.
- Since:
- 0.12
-
buildThreadGroup
public org.apache.jmeter.threads.AbstractThreadGroup buildThreadGroup()
- Specified by:
buildThreadGroupin classBaseThreadGroup<DslDefaultThreadGroup>
-
showTimeline
public void showTimeline()
Shows a graph with a timeline of planned threads count execution for this test plan.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).
- Since:
- 0.26
-
buildLoadTimeline
public LoadTimeLine buildLoadTimeline()
Description copied from class:BaseThreadGroupThis method is used byDslTestPlan.showTimeline()to get the timeline chart for this thread group.- Overrides:
buildLoadTimelinein classBaseThreadGroup<DslDefaultThreadGroup>- Returns:
- the timeline chart for this thread group or null if it is not supported.
-
-