Class RpsThreadGroup
- 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<RpsThreadGroup>
-
- us.abstracta.jmeter.javadsl.core.threadgroups.RpsThreadGroup
-
- All Implemented Interfaces:
DslTestElement,DslTestPlan.TestPlanChild,DslThreadGroup
public class RpsThreadGroup extends BaseThreadGroup<RpsThreadGroup>
Configures a thread group which dynamically adapts the number of threads and pauses to match a given rps.Warning: by default the thread group uses unbounded maximum number of threads, but this is not a good practice since it might impose unexpected load on load generator (CPU or memory may run out). It is advisable to always set a maximum number of threads. Check
maxThreads(int).Internally this element uses Concurrency Thread Group in combination with Throughput Shaping Timer.
By default, the thread group will control the number of requests per second, but this can be changed to iterations per second with
counting(EventType).- Since:
- 0.26
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRpsThreadGroup.ContractComplyingConcurrencyThreadGroupThis implementation of ConcurrencyThreadGroup complies withAbstractThreadGroupcontract, and the original doesn't.static classRpsThreadGroup.EventTypestatic classRpsThreadGroup.NonInterruptingVariableThroughputTimerAlways stops thread group gracefully, avoiding potential exceptions generated byVariableThroughputTimerwhen stopping a test, due to thread interruptions.static classRpsThreadGroup.TimerSchedule-
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 RpsThreadGroup.EventTypecountingprotected intinitThreadsprotected doublelastRpsprotected intmaxThreadsprotected List<RpsThreadGroup.TimerSchedule>schedulesprotected doublespareThreads-
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 RpsThreadGroup(String name)
-
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.protected org.apache.jmeter.threads.AbstractThreadGroupbuildThreadGroup()org.apache.jorphan.collections.HashTreebuildTreeUnder(org.apache.jorphan.collections.HashTree parent, BuildTreeContext context)Builds the JMeter HashTree for this TestElement under the provided tree node.RpsThreadGroupcounting(RpsThreadGroup.EventType counting)Specifies to either control requests or iterations per second.RpsThreadGroupholdFor(Duration duration)Specifies to keep current RPS for a given duration.RpsThreadGroupinitThreads(int initThreads)Specifies the initial number of threads to use.RpsThreadGroupmaxThreads(int maxThreads)Specifies the maximum number of threads to use.RpsThreadGrouprampTo(double rps, Duration duration)Allows ramping up or down RPS with a given duration.RpsThreadGrouprampToAndHold(double rps, Duration rampDuration, Duration holdDuration)Simply combinesrampTo(double, Duration)andholdFor(Duration)which are usually used in combination.voidshowTimeline()Shows a graph with a timeline of planned rps count execution for this test plan.RpsThreadGroupspareThreads(double spareThreads)Specifies the number of spare (not used) threads to keep in the thread group.-
Methods inherited from class us.abstracta.jmeter.javadsl.core.threadgroups.BaseThreadGroup
buildTestElement, children, sampleErrorAction
-
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
showInGui
-
-
-
-
Field Detail
-
schedules
protected final List<RpsThreadGroup.TimerSchedule> schedules
-
lastRps
protected double lastRps
-
counting
protected RpsThreadGroup.EventType counting
-
initThreads
protected int initThreads
-
maxThreads
protected int maxThreads
-
spareThreads
protected double spareThreads
-
-
Constructor Detail
-
RpsThreadGroup
public RpsThreadGroup(String name)
-
-
Method Detail
-
rampTo
public RpsThreadGroup rampTo(double rps, Duration duration)
Allows ramping up or down RPS with a given duration.JMeter will automatically create or remove threads from thread group and add time pauses to match provided RPS.
You can use this method multiple times in a thread group and in conjunction with
holdFor(Duration)andrampToAndHold(double, Duration, Duration)to elaborate complex test plan profiles.Eg:
rpsThreadGroup() .maxThreads(10) .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:
rps- specifies the final RPS (requests/iterations per second) after the given period. This value directly affects how often threads and pauses are adjusted. For example, if you configure a ramp from 0.01 to 10 RPS with 10 seconds duration, after 1 request it will wait 100 seconds and then reevaluate, not honoring configured ramp. A value greater than 1 should at least re adjust every second.duration- duration taken to reach the given RPS 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 and usage.
-
holdFor
public RpsThreadGroup holdFor(Duration duration)
Specifies to keep current RPS for a given duration.This method is usually used in combination with
rampTo(double, Duration)to define the profile of the test plan.- Parameters:
duration- duration to hold the current RPS 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 and usage.
- See Also:
rampTo(double, Duration)
-
rampToAndHold
public RpsThreadGroup rampToAndHold(double rps, Duration rampDuration, Duration holdDuration)
Simply combinesrampTo(double, Duration)andholdFor(Duration)which are usually used in combination.- Parameters:
rps- target RPS to ramp up/down to. This value directly affects how often threads and pauses are adjusted. For example, if you configure a ramp from 0.01 to 10 RPS with 10 seconds duration, after 1 request it will wait 100 seconds and then reevaluate, not honoring configured ramp. A value greater than 1 should at least re adjust every second.rampDuration- duration taken to reach the given RPS.holdDuration- duration to hold the given RPS after the ramp, until moving to next stage or ending the test plan.- Returns:
- the thread group for further configuration and usage.
- See Also:
rampTo(double, Duration),holdFor(Duration)
-
counting
public RpsThreadGroup counting(RpsThreadGroup.EventType counting)
Specifies to either control requests or iterations per second.If you are only concerned on controlling the number of requests per second, then there is no need to use this method since this is the default behavior. On the other hand, if you actually want to control how many times per second the flow inside the thread group executes, then you can use this method counting iterations.
- Parameters:
counting- specifies what event type to use to control the RPS. When not specified requests are counted.- Returns:
- the thread group for further configuration and usage.
-
maxThreads
public RpsThreadGroup maxThreads(int maxThreads)
Specifies the maximum number of threads to use.Warning: this value should be big enough to be able to reach the maximum desired RPS, otherwise the maximum RPS will not be able to be met. If you have requests that have maximum response time (or iteration time, if you are counting iteration instead of requests, see:
counting(EventType)) R seconds, and need to reach T maximum RPS, then you should set this value to R*T.Warning: by default, maximum threads are unbounded, but this means that you may run out of memory or consume too much CPU. Is a good practice to always set this value to avoid unexpected load on generator that may affect performance test in some undesired ways.
- Parameters:
maxThreads- specifies the maximum threads to use by the thread group. By default, is unbounded.- Returns:
- the thread group for further configuration and usage.
-
initThreads
public RpsThreadGroup initThreads(int initThreads)
Specifies the initial number of threads to use.Use this method to start with a bigger pool if you know beforehand that for inital RPS 1 thread would not be enough.
- Parameters:
initThreads- specifies the initial number of threads to use by the thread group. By default, is 1.- Returns:
- the thread group for further configuration and usage.
-
spareThreads
public RpsThreadGroup spareThreads(double spareThreads)
Specifies the number of spare (not used) threads to keep in the thread group.When thread group identifies that can use less threads, it can still keep them in pool to avoid the cost to re-create them later on if needed. This method controls how many threads to keep.
- Parameters:
spareThreads- specifies either the number of spare threads (if the value is greater than 1) or the percent (if <= 1) from the current active threads count. By default, is 0.1 (10% of active threads).- Returns:
- the thread group for further configuration and usage.
-
buildTreeUnder
public org.apache.jorphan.collections.HashTree buildTreeUnder(org.apache.jorphan.collections.HashTree parent, BuildTreeContext context)Description copied from interface:DslTestElementBuilds the JMeter HashTree for this TestElement under the provided tree node.- Specified by:
buildTreeUnderin interfaceDslTestElement- Overrides:
buildTreeUnderin classTestElementContainer<RpsThreadGroup,BaseThreadGroup.ThreadGroupChild>- Parameters:
parent- the node which will be the parent for the created tree.context- context information which contains information shared by elements while building the test plan tree (eg: adding additional items to test plan when a particular protocol element is added).- Returns:
- The tree created under the parent node.
-
buildThreadGroup
protected org.apache.jmeter.threads.AbstractThreadGroup buildThreadGroup()
- Specified by:
buildThreadGroupin classBaseThreadGroup<RpsThreadGroup>
-
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<RpsThreadGroup>- Returns:
- the timeline chart for this thread group or null if it is not supported.
-
showTimeline
public void showTimeline()
Shows a graph with a timeline of planned rps 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
-
-