Class JmeterDsl
- java.lang.Object
-
- us.abstracta.jmeter.javadsl.JmeterDsl
-
public class JmeterDsl extends Object
This is the main class to be imported from any code using JMeter DSL.This class contains factory methods to create
DslTestElementinstances that allow specifying test plans and associated test elements (samplers, thread groups, listeners, etc.). If you want to support new test elements, then you either add them here (if they are considered to be part of the core of JMeter), or implement another similar class containing only the specifics of the protocol, repository, or grouping of test elements that you want to build (eg, one might implement an Http2JMeterDsl class with only http2 test elements' factory methods).When implement new factory methods consider adding only as parameters the main properties of the test elements (the ones that makes sense to specify in most of the cases). For the rest of parameters (the optional ones), prefer them to be specified as methods of the implemented
DslTestElementfor such case, in a similar fashion as Builder Pattern.- Since:
- 0.1
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static AutoStopListenerautoStop()Builds an AutoStopListener that allows to stop a test plan execution if some condition over collected metrics is met.static AutoStopListenerautoStop(String name)Same asautoStop()but allowing to set a name on the listener, which can help identify which autoStop listener stopped a test plan if multiple ones are configured.static DslBoundaryExtractorboundaryExtractor(String variableName, String leftBoundary, String rightBoundary)Builds a Boundary Extractor which allows using left and right boundary texts to extract different parts of a sample result (request or response).static DslConstantTimerconstantTimer(String duration)Same asconstantTimer(Duration)but allowing tu use a JMeter expression.static DslConstantTimerconstantTimer(Duration duration)Builds a Constant Timer which pauses the thread with for a given duration.static DslCountercounter(String name)Builds a counter for easy usage of auto incremental numbers in test plans.static DslCsvDataSetcsvDataSet(String csvFile)Builds a CSV Data Set which allows loading from a CSV file variables to be used in test plan.static DslCsvDataSetcsvDataSet(TestResource resource)Same ascsvDataSet(String)but easing usage of test resources.static DslDebugPostProcessordebugPostProcessor()Builds a Debug post processor which is helpful to collect debugging information from test plans executions.static DslDummySamplerdummySampler(String responseBody)Builds a JMeter plugin Dummy Sampler which allows emulating a sampler easing testing other parts of a test plan (like extractors, controllers conditions, etc).static DslDummySamplerdummySampler(String name, String responseBody)Same asdummySampler(String)but allowing to set a name on the sampler.static DslForEachControllerforEachController(String name, String varsPrefix, String iterationVarName, BaseThreadGroup.ThreadGroupChild... children)Same asforEachController(String, String, ThreadGroupChild...)but allowing to set a name which defines autogenerated variable created by JMeter containing iteration index.static DslForEachControllerforEachController(String varsPrefix, String iterationVarName, BaseThreadGroup.ThreadGroupChild... children)Builds a For each controller that iterates over a set of variables and runs a given set of children for each variable in the set.static ForLoopControllerforLoopController(int count, BaseThreadGroup.ThreadGroupChild... children)Builds a Loop Controller that allows to run specific number of times the given children in each thread group iteration.static ForLoopControllerforLoopController(String name, int count, BaseThreadGroup.ThreadGroupChild... children)Same asforLoopController(int, ThreadGroupChild...)but allowing to set a name which defines autogenerated variable created by JMeter containing iteration index.static ForLoopControllerforLoopController(String name, String count, BaseThreadGroup.ThreadGroupChild... children)Same asforLoopController(String, ThreadGroupChild...)but allowing to set a name which defines autogenerated variable created by JMeter containing iteration index.static ForLoopControllerforLoopController(String count, BaseThreadGroup.ThreadGroupChild... children)Same asforLoopController(int, ThreadGroupChild...)but allowing to use JMeter expressions for number of loops.static GraphiteBackendListenergraphiteListener(String graphiteUrl)Builds a Backend Listener configured to use Graphite to send all results for easy tracing, historic, comparison, and live test results.static HtmlReporterhtmlReporter(String reportsDirectory)Builds an HTML Reporter which allows easily generating HTML reports for test plans.static HtmlReporterhtmlReporter(String reportsDirectory, String name)Builds an HTML Reporter which allows easily generating HTML reports for test plans.static DslAuthManagerhttpAuth()Builds an Auth manager which simplifies configuration for automatic authentication of HTTP requests.static DslCacheManagerhttpCache()Builds a Cache manager at the test plan level which allows configuring caching behavior used by HTTPRequest samplers.static DslCookieManagerhttpCookies()Builds a Cookie manager at the test plan level which allows configuring cookies settings used by HTTPRequest samplers.static DslHttpDefaultshttpDefaults()Builds an HTTP request defaults element that allows setting default values used by HTTP samplers.static HttpHeadershttpHeaders()Builds an HTTP header manager which allows setting HTTP headers to be used by HTTPRequest samplers.static DslHttpSamplerhttpSampler(Class<? extends PropertyScriptBuilder.PropertyScript<String>> urlSolverClass)Same ashttpSampler(Function)but with support for running at scale in a remote engine.static DslHttpSamplerhttpSampler(String url)Builds an HTTP Request sampler to sample HTTP requests.static DslHttpSamplerhttpSampler(String name, Class<? extends PropertyScriptBuilder.PropertyScript<String>> urlSolverClass)Same ashttpSampler(Class)but allowing to set a name to the HTTP Request sampler.static DslHttpSamplerhttpSampler(String name, String url)Same ashttpSampler(String)but allowing to set a name to the HTTP Request sampler.static DslHttpSamplerhttpSampler(String name, Function<DslJsr223PreProcessor.PreProcessorVars,String> urlSupplier)Same ashttpSampler(Function)but allowing to set a name to the HTTP Request sampler.static DslHttpSamplerhttpSampler(Function<DslJsr223PreProcessor.PreProcessorVars,String> urlSupplier)Builds an HTTP Request sampler to sample HTTP requests with a dynamically calculated URL.static DslIfControllerifController(Class<? extends PropertyScriptBuilder.PropertyScript<Boolean>> conditionClass, BaseThreadGroup.ThreadGroupChild... children)Same asifController(PropertyScript, ThreadGroupChild...)but with support for running at scale in a remote engine.static DslIfControllerifController(String condition, BaseThreadGroup.ThreadGroupChild... children)Builds an If Controller that allows to conditionally run specified children.static DslIfControllerifController(PropertyScriptBuilder.PropertyScript<Boolean> condition, BaseThreadGroup.ThreadGroupChild... children)Same asifController(String, ThreadGroupChild...)but allowing to use Java type safety and code completion when specifying the condition.static InfluxDbBackendListenerinfluxDbListener(String influxDbUrl)Builds a Backend Listener configured to use InfluxDB to send all results for easy tracing, historic, comparison and live test results.static DslJsonAssertionjsonAssertion(String jsonQuery)Builds an Assertion element to check that obtained sampler result JSON is the expected one.static DslJsonAssertionjsonAssertion(String name, String jsonQuery)Same asjsonAssertion(String)but allowing to set a name on the assertion, which can be later used to identify assertion results and differentiate it from other assertions.static DslJsonExtractorjsonExtractor(String variableName, String query)Builds an Extractor which allows using JMESPath or JSONPath to extract part of a JSON response.static DslJsr223PostProcessorjsr223PostProcessor(Class<? extends DslJsr223PostProcessor.PostProcessorScript> scriptClass)Same asjsr223PostProcessor(PostProcessorScript)but with support for running at scale in a remote engine.static DslJsr223PostProcessorjsr223PostProcessor(String script)Builds a JSR223 Post Processor which allows including custom logic to process sample results.static DslJsr223PostProcessorjsr223PostProcessor(String name, Class<? extends DslJsr223PostProcessor.PostProcessorScript> scriptClass)Same asjsr223PostProcessor(Class)but allowing to set a name on the sampler.static DslJsr223PostProcessorjsr223PostProcessor(String name, String script)Same asjsr223PostProcessor(String)but allowing to set a name on the post processor.static DslJsr223PostProcessorjsr223PostProcessor(String name, DslJsr223PostProcessor.PostProcessorScript script)Same asjsr223PostProcessor(String, String)but allowing to use Java type safety and code completion when specifying the script.static DslJsr223PostProcessorjsr223PostProcessor(DslJsr223PostProcessor.PostProcessorScript script)Same asjsr223PostProcessor(String)but allowing to use Java type safety and code completion when specifying the script.static DslJsr223PreProcessorjsr223PreProcessor(Class<? extends DslJsr223PreProcessor.PreProcessorScript> scriptClass)Same asjsr223PreProcessor(PreProcessorScript)but with support for running at scale in a remote engine.static DslJsr223PreProcessorjsr223PreProcessor(String script)Builds a JSR223 Pre Processor which allows including custom logic to modify requests.static DslJsr223PreProcessorjsr223PreProcessor(String name, Class<? extends DslJsr223PreProcessor.PreProcessorScript> scriptClass)Same asjsr223PreProcessor(Class)but allowing to set a name on the sampler.static DslJsr223PreProcessorjsr223PreProcessor(String name, String script)Same asjsr223PreProcessor(String)but allowing to set a name on the preprocessor.static DslJsr223PreProcessorjsr223PreProcessor(String name, DslJsr223PreProcessor.PreProcessorScript script)Same asjsr223PreProcessor(String, String)but allowing to use Java type safety and code completion when specifying the script.static DslJsr223PreProcessorjsr223PreProcessor(DslJsr223PreProcessor.PreProcessorScript script)Same asjsr223PreProcessor(String)but allowing to use Java type safety and code completion when specifying the script.static DslJsr223Samplerjsr223Sampler(Class<? extends DslJsr223Sampler.SamplerScript> scriptClass)Same asjsr223Sampler(SamplerScript)but with support for running at scale in a remote engine.static DslJsr223Samplerjsr223Sampler(String script)Builds a JSR223 Sampler which allows sampling any Java API or custom logic.static DslJsr223Samplerjsr223Sampler(String name, Class<? extends DslJsr223Sampler.SamplerScript> scriptClass)Same asjsr223Sampler(Class)but allowing to set a name on the sampler.static DslJsr223Samplerjsr223Sampler(String name, String script)Same asjsr223Sampler(String)but allowing to set a name on the sampler.static DslJsr223Samplerjsr223Sampler(String name, DslJsr223Sampler.SamplerScript script)Same asjsr223Sampler(String, String)but allowing to use Java type safety and code completion when specifying the script.static DslJsr223Samplerjsr223Sampler(DslJsr223Sampler.SamplerScript script)Same asjsr223Sampler(String)but allowing to use Java type safety and code completion when specifying the script.static JtlWriterjtlWriter(String directory)Builds a Simple Data Writer to write all collected results to a JTL file.static JtlWriterjtlWriter(String directory, String fileName)Builds a Simple Data Writer to write all collected results to a JTL file.static DslOnceOnlyControlleronceOnlyController(BaseThreadGroup.ThreadGroupChild... children)Builds a Once Only Controller that allows running a part of a test plan only once and only on the first iteration of each thread group.static PercentControllerpercentController(float percent, BaseThreadGroup.ThreadGroupChild... children)Builds a Percent Controller to execute children only a given percent of times.static PercentControllerpercentController(String percent, BaseThreadGroup.ThreadGroupChild... children)Same aspercentController(float, ThreadGroupChild...)but allowing using JMeter expressions (eg: ${PERCENT_VAR}) in percent parameter.static DslRegexExtractorregexExtractor(String variableName, String regex)Builds a Regex Extractor which allows using regular expressions to extract different parts of a sample result (request or response).static DslResponseAssertionresponseAssertion()Builds a Response Assertion to be able to check that obtained sample result is the expected one.static DslResponseAssertionresponseAssertion(String name)Same asresponseAssertion()but allowing to set a name on the assertion, which can be later used to identify assertion results and differentiate it from other assertions.static ResponseFileSaverresponseFileSaver(String fileNamePrefix)Builds a Response File Saver to generate a file for each response of a sample.static DslViewResultsTreeresultsTreeVisualizer()Builds a View Results Tree element to show live results in a pop-up window while the test runs.static RpsThreadGrouprpsThreadGroup()Builds a thread group that dynamically adapts thread count and pauses to match a given RPS.static RpsThreadGrouprpsThreadGroup(String name)Same asrpsThreadGroup()but allowing to set a name on the thread group.static DslRuntimeControllerruntimeController(String seconds, BaseThreadGroup.ThreadGroupChild... children)Same asruntimeController(Duration, ThreadGroupChild...)but allowing to use JMeter expressions for the duration.static DslRuntimeControllerruntimeController(Duration duration, BaseThreadGroup.ThreadGroupChild... children)Builds a Runtime Controller that stops executing child elements when a period of time expires.static DslSetupThreadGroupsetupThreadGroup()Builds a setup thread group which allows tuning settings before setting its children.static DslSetupThreadGroupsetupThreadGroup(String name)Same assetupThreadGroup()but allowing to set a name on the thread group.static DslSetupThreadGroupsetupThreadGroup(String name, BaseThreadGroup.ThreadGroupChild... children)Same assetupThreadGroup(ThreadGroupChild...)but allowing to set a name on the thread group.static DslSetupThreadGroupsetupThreadGroup(BaseThreadGroup.ThreadGroupChild... children)Builds a thread group that allows running logic before other thread groups.static DslSimpleControllersimpleController(String name, BaseThreadGroup.ThreadGroupChild... children)Same assimpleController(ThreadGroupChild...)but allowing to set a name.static DslSimpleControllersimpleController(BaseThreadGroup.ThreadGroupChild... children)Builds a new simple controller with the given name.static DslSynchronizingTimersynchronizingTimer()Builds a Synchronizing Timer that allows synchronizing samples to be sent all at once.static DslTeardownThreadGroupteardownThreadGroup()Builds a teardown thread group which allows tuning settings before setting its children.static DslTeardownThreadGroupteardownThreadGroup(String name)Same asteardownThreadGroup()but allowing to set a name on the thread group.static DslTeardownThreadGroupteardownThreadGroup(String name, BaseThreadGroup.ThreadGroupChild... children)Same asteardownThreadGroup(ThreadGroupChild...)but allowing to set a name on the thread group.static DslTeardownThreadGroupteardownThreadGroup(BaseThreadGroup.ThreadGroupChild... children)Builds a thread group that allows running logic after other thread groups.static DslTestPlantestPlan(DslTestPlan.TestPlanChild... children)Builds a new test plan.static TestResourcetestResource(String resourcePath)Allows easy usage of test resources like the ones insrc/test/resourcein maven projects.static DslDefaultThreadGroupthreadGroup()Builds a new thread group without any thread configuration.static DslDefaultThreadGroupthreadGroup(int threads, int iterations, BaseThreadGroup.ThreadGroupChild... children)Builds a new thread group with a given number of threads & iterations.static DslDefaultThreadGroupthreadGroup(int threads, Duration duration, BaseThreadGroup.ThreadGroupChild... children)Builds a new thread group with a given number of threads & their duration.static DslDefaultThreadGroupthreadGroup(String name)Same asthreadGroup()but allowing to set a name on the thread group.static DslDefaultThreadGroupthreadGroup(String name, int threads, int iterations, BaseThreadGroup.ThreadGroupChild... children)Same asthreadGroup(int, int, ThreadGroupChild...)but allowing to set a name on the thread group.static DslDefaultThreadGroupthreadGroup(String name, int threads, Duration duration, BaseThreadGroup.ThreadGroupChild... children)Same asthreadGroup(int, Duration, ThreadGroupChild...)but allowing to set a name on the thread group.static DslFlowControlActionthreadPause(String duration)Same asthreadPause(Duration)but allowing to use JMeter expressions for the duration.static DslFlowControlActionthreadPause(Duration duration)Builds a Flow Control Action that pauses the current thread for the given duration.static DslThroughputTimerthroughputTimer(double throughputPerMinute)Builds a Constant Throughput Timer which paces samplers to limit the throughput.static DslTransactionControllertransaction(String name, BaseThreadGroup.ThreadGroupChild... children)Builds a new transaction controller with the given name.static DslUniformRandomTimeruniformRandomTimer(Duration minimum, Duration maximum)Builds a Uniform Random Timer which pauses the thread with a random time with uniform distribution.static DslVariablesvars()Builds a DslVariables that allows to easily initialize or update JMeter variables.static DslVariablesvars(String name)Same asvars()but allowing to set a name on the element.static DslWeightedSwitchControllerweightedSwitchController()Builds a Controller which executes in each iteration choosing one child according to given weights.static DslWhileControllerwhileController(Class<? extends PropertyScriptBuilder.PropertyScript<Boolean>> conditionClass, BaseThreadGroup.ThreadGroupChild... children)Same aswhileController(PropertyScript, ThreadGroupChild...)but with support for running at scale in a remote engine.static DslWhileControllerwhileController(String name, Class<? extends PropertyScriptBuilder.PropertyScript<Boolean>> conditionClass, BaseThreadGroup.ThreadGroupChild... children)Same aswhileController(Class, ThreadGroupChild...)but allowing to set a name which defines autogenerated variable created by JMeter containing iteration index.static DslWhileControllerwhileController(String name, String condition, BaseThreadGroup.ThreadGroupChild... children)Same aswhileController(String, ThreadGroupChild...)but allowing to set a name which defines autogenerated variable created by JMeter containing iteration index.static DslWhileControllerwhileController(String condition, BaseThreadGroup.ThreadGroupChild... children)Builds a While Controller that allows to run specific part of the test plan while a given condition is met in one thread iteration.static DslWhileControllerwhileController(String name, PropertyScriptBuilder.PropertyScript<Boolean> condition, BaseThreadGroup.ThreadGroupChild... children)Same aswhileController(PropertyScript, ThreadGroupChild...)but allowing to set a name which defines autogenerated variable created by JMeter containing iteration index.static DslWhileControllerwhileController(PropertyScriptBuilder.PropertyScript<Boolean> condition, BaseThreadGroup.ThreadGroupChild... children)Same aswhileController(String, ThreadGroupChild...)but allowing to use Java type safety and code completion when specifying the condition.
-
-
-
Method Detail
-
testPlan
public static DslTestPlan testPlan(DslTestPlan.TestPlanChild... children)
Builds a new test plan.- Parameters:
children- specifies the list of test elements that compose the test plan.- Returns:
- the test plan instance.
- See Also:
DslTestPlan
-
threadGroup
public static DslDefaultThreadGroup threadGroup(int threads, int iterations, BaseThreadGroup.ThreadGroupChild... children)
Builds a new thread group with a given number of threads & iterations.- Parameters:
threads- specifies the number of threads to simulate concurrent virtual users.iterations- specifies the number of iterations that each virtual user will run of children elements until it stops.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.
children- contains the test elements that each thread will execute in each iteration.- Returns:
- the thread group instance.
- See Also:
DslDefaultThreadGroup
-
threadGroup
public static DslDefaultThreadGroup threadGroup(String name, int threads, int iterations, BaseThreadGroup.ThreadGroupChild... children)
Same asthreadGroup(int, int, ThreadGroupChild...)but allowing to set a name on the thread group.Setting a proper name allows to properly identify the requests generated in each thread group.
-
threadGroup
public static DslDefaultThreadGroup threadGroup(int threads, Duration duration, BaseThreadGroup.ThreadGroupChild... children)
Builds a new thread group with a given number of threads & their duration.- Parameters:
threads- to simulate concurrent virtual users.duration- to keep each thread running for this period of time. Take into consideration that JMeter supports specifying duration in seconds, so if you specify a smaller granularity (like milliseconds) it will be rounded up to seconds.children- contains the test elements that each thread will execute until specified duration is reached.- Returns:
- the thread group instance.
- Since:
- 0.5
- See Also:
ThreadGroup
-
threadGroup
public static DslDefaultThreadGroup threadGroup(String name, int threads, Duration duration, BaseThreadGroup.ThreadGroupChild... children)
Same asthreadGroup(int, Duration, ThreadGroupChild...)but allowing to set a name on the thread group.Setting a proper name allows to properly identify the requests generated in each thread group.
- Since:
- 0.5
- See Also:
threadGroup(int, Duration, ThreadGroupChild...)
-
threadGroup
public static DslDefaultThreadGroup threadGroup()
Builds a new thread group without any thread configuration.This method should be used as starting point for creating complex test thread profiles (like spike, or incremental tests) in combination with holdFor, rampTo and rampToAndHold
DslDefaultThreadGroupmethods.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(...)For complex thread profiles that can't be mapped to JMeter built-in thread group element, the DSL uses Ultimate Thread Group plugin.
- Returns:
- the thread group instance.
- Since:
- 0.18
-
threadGroup
public static DslDefaultThreadGroup threadGroup(String name)
Same asthreadGroup()but allowing to set a name on the thread group.Setting a proper name allows to properly identify the requests generated in each thread group.
- Since:
- 0.18
- See Also:
threadGroup()
-
setupThreadGroup
public static DslSetupThreadGroup setupThreadGroup(BaseThreadGroup.ThreadGroupChild... children)
Builds a thread group that allows running logic before other thread groups.This is usually used to run some setup logic before the actual test plan logic. In particular logic that needs to be run within the context of JMeter test (eg: requires setting some JMeter property) or needs to be run from same machines as the test plan.
Check
DslSetupThreadGroupfor more details and configuration options.- Parameters:
children- test elements to be run before any other thread group.- Returns:
- the setup thread group for further customization or just usage in test plan
- Since:
- 0.33
- See Also:
DslSetupThreadGroup
-
setupThreadGroup
public static DslSetupThreadGroup setupThreadGroup(String name, BaseThreadGroup.ThreadGroupChild... children)
Same assetupThreadGroup(ThreadGroupChild...)but allowing to set a name on the thread group.Setting a proper name allows to properly identify the requests generated in each thread group.
- Since:
- 0.35
- See Also:
DslSetupThreadGroup
-
setupThreadGroup
public static DslSetupThreadGroup setupThreadGroup()
Builds a setup thread group which allows tuning settings before setting its children.This method allows for example setting the number of iterations and threads to be used by the thread group, before setting children elements.
- Since:
- 0.35
- See Also:
DslSetupThreadGroup
-
setupThreadGroup
public static DslSetupThreadGroup setupThreadGroup(String name)
Same assetupThreadGroup()but allowing to set a name on the thread group.Setting a proper name allows to properly identify the requests generated in each thread group.
- Since:
- 0.35
- See Also:
DslSetupThreadGroup
-
teardownThreadGroup
public static DslTeardownThreadGroup teardownThreadGroup(BaseThreadGroup.ThreadGroupChild... children)
Builds a thread group that allows running logic after other thread groups.This is usually used to run some clean up logic after the actual test plan logic. In particular logic that needs to be run within the context of JMeter test (eg: requires setting some JMeter property) or needs to be run from same machines as the test plan.
Check
DslTeardownThreadGroupfor more details and configuration options.- Parameters:
children- test elements to be run after any other thread group.- Returns:
- the teardown thread group for further customization or just usage in test plan
- Since:
- 0.33
- See Also:
DslTeardownThreadGroup
-
teardownThreadGroup
public static DslTeardownThreadGroup teardownThreadGroup(String name, BaseThreadGroup.ThreadGroupChild... children)
Same asteardownThreadGroup(ThreadGroupChild...)but allowing to set a name on the thread group.Setting a proper name allows to properly identify the requests generated in each thread group.
- Since:
- 0.35
- See Also:
DslTeardownThreadGroup
-
teardownThreadGroup
public static DslTeardownThreadGroup teardownThreadGroup()
Builds a teardown thread group which allows tuning settings before setting its children.This method allows for example setting the number of iterations and threads to be used by the thread group, before setting children elements.
- Since:
- 0.35
- See Also:
DslTeardownThreadGroup
-
teardownThreadGroup
public static DslTeardownThreadGroup teardownThreadGroup(String name)
Same asteardownThreadGroup()but allowing to set a name on the thread group.Setting a proper name allows to properly identify the requests generated in each thread group.
- Since:
- 0.35
- See Also:
DslTeardownThreadGroup
-
rpsThreadGroup
public static RpsThreadGroup rpsThreadGroup()
Builds a thread group that dynamically adapts thread count and pauses to match a given RPS.Internally this element uses Concurrency Thread Group in combination with Throughput Shaping Timer.
Eg:
rpsThreadGroup() .maxThreads(500) .rampTo(20, Duration.ofSeconds(10)) .rampTo(10, Duration.ofSeconds(10)) .rampToAndHold(1000, Duration.ofSeconds(5), Duration.ofSeconds(10)) .rampTo(0, Duration.ofSeconds(5)) .children(...)- Returns:
- the thread group instance.
- Since:
- 0.26
- See Also:
RpsThreadGroup
-
rpsThreadGroup
public static RpsThreadGroup rpsThreadGroup(String name)
Same asrpsThreadGroup()but allowing to set a name on the thread group.Setting a proper name allows to properly identify the requests generated in each thread group.
- Since:
- 0.26
- See Also:
rpsThreadGroup()
-
transaction
public static DslTransactionController transaction(String name, BaseThreadGroup.ThreadGroupChild... children)
Builds a new transaction controller with the given name.- Parameters:
name- specifies the name to identify the transaction.children- contains the test elements that will be contained within the transaction.- Returns:
- the transaction instance.
- Since:
- 0.14
- See Also:
DslTransactionController
-
simpleController
public static DslSimpleController simpleController(BaseThreadGroup.ThreadGroupChild... children)
Builds a new simple controller with the given name.Simple controllers are good for defining test plan scopes, without having to create a transaction (which generates a sample result). For example, to apply configs, assertions, timers, listeners, post- and pre-processors to only part of the test plan (certain samplers).
Additionally, they are a handy way of creating methods that return certain part of a test plan (inside a simple controller) and then directly inject the method returned controller in an existing test plan.
- Parameters:
children- contains the test elements that will be contained within the controller.- Returns:
- the controller instance.
- Since:
- 1.21
- See Also:
DslSimpleController
-
simpleController
public static DslSimpleController simpleController(String name, BaseThreadGroup.ThreadGroupChild... children)
Same assimpleController(ThreadGroupChild...)but allowing to set a name.In this scenario, the name has no functional usage during test plan execution, but it can ease JMX test plan review as to keep sections of the test plan well identified.
- See Also:
simpleController(ThreadGroupChild...)
-
ifController
public static DslIfController ifController(String condition, BaseThreadGroup.ThreadGroupChild... children)
Builds an If Controller that allows to conditionally run specified children.- Parameters:
condition- contains an expression that when evaluated to true tells the controller to run specified children.children- contains the test plan elements to execute when the condition is true.- Returns:
- the controller instance for further configuration and usage.
- Since:
- 0.27
- See Also:
DslIfController
-
ifController
public static DslIfController ifController(PropertyScriptBuilder.PropertyScript<Boolean> condition, BaseThreadGroup.ThreadGroupChild... children)
Same asifController(String, ThreadGroupChild...)but allowing to use Java type safety and code completion when specifying the condition.WARNING: This only works when using embedded jmeter engine. Check the user guide for details on some alternative.
Take into consideration that the provided script is invoked from as may threads as defined in thread group. So make sure that provided logic is thread safe.
- Since:
- 0.27
- See Also:
PropertyScriptBuilder.PropertyScript,ifController(String, ThreadGroupChild...)
-
ifController
public static DslIfController ifController(Class<? extends PropertyScriptBuilder.PropertyScript<Boolean>> conditionClass, BaseThreadGroup.ThreadGroupChild... children)
Same asifController(PropertyScript, ThreadGroupChild...)but with support for running at scale in a remote engine.Check the user guide for details on additional steps required to run them at scale in a remote engine.
- Since:
- 1.14
- See Also:
PropertyScriptBuilder.PropertyScript,ifController(PropertyScript, ThreadGroupChild...)
-
whileController
public static DslWhileController whileController(String condition, BaseThreadGroup.ThreadGroupChild... children)
Builds a While Controller that allows to run specific part of the test plan while a given condition is met in one thread iteration.JMeter generates
__jm__while__idxvariable containing the iteration number (0 indexed), which can be helpful in some scenarios.- Parameters:
condition- contains an expression that will be evaluated to identify when to stop looping.children- contains the test plan elements to execute while the condition is true.- Returns:
- the controller instance for further configuration and usage.
- Since:
- 0.27
- See Also:
DslWhileController
-
whileController
public static DslWhileController whileController(String name, String condition, BaseThreadGroup.ThreadGroupChild... children)
Same aswhileController(String, ThreadGroupChild...)but allowing to set a name which defines autogenerated variable created by JMeter containing iteration index.- Parameters:
name- specifies the name to assign to the controller. This variable affects the JMeter autogenerated variable__jm__<controllerName>__idxwhich holds the loop iteration number (starting at 0).condition- contains an expression that will be evaluated to identify when to stop looping.children- contains the test plan elements to execute while the condition is true.- Returns:
- the controller instance for further configuration and usage.
- Since:
- 0.27
- See Also:
DslWhileController,whileController(String, ThreadGroupChild...)
-
whileController
public static DslWhileController whileController(PropertyScriptBuilder.PropertyScript<Boolean> condition, BaseThreadGroup.ThreadGroupChild... children)
Same aswhileController(String, ThreadGroupChild...)but allowing to use Java type safety and code completion when specifying the condition.WARNING: This only works when using embedded jmeter engine. Check the user guide for details on some alternative.
Take into consideration that the provided script is invoked from as may threads as defined in thread group. So, make sure that provided logic is thread safe.
JMeter generates
__jm__while__idxvariable containing the iteration number (0 indexed), which can be helpful in some scenarios.- Parameters:
condition- contains java code that will be evaluated to identify when to stop looping.children- contains the test plan elements to execute while the condition is true.- Returns:
- the controller instance for further configuration and usage.
- Since:
- 0.27
- See Also:
PropertyScriptBuilder.PropertyScript,whileController(String, ThreadGroupChild...)
-
whileController
public static DslWhileController whileController(String name, PropertyScriptBuilder.PropertyScript<Boolean> condition, BaseThreadGroup.ThreadGroupChild... children)
Same aswhileController(PropertyScript, ThreadGroupChild...)but allowing to set a name which defines autogenerated variable created by JMeter containing iteration index.- Parameters:
name- specifies the name to assign to the controller. This variable affects the JMeter autogenerated variable__jm__<controllerName>__idxwhich holds the loop iteration number (starting at 0).condition- contains java code that will be evaluated to identify when to stop looping.children- contains the test plan elements to execute while the condition is true.- Returns:
- the controller instance for further configuration and usage.
- Since:
- 0.27
- See Also:
PropertyScriptBuilder.PropertyScript,whileController(PropertyScript, ThreadGroupChild...)
-
whileController
public static DslWhileController whileController(Class<? extends PropertyScriptBuilder.PropertyScript<Boolean>> conditionClass, BaseThreadGroup.ThreadGroupChild... children)
Same aswhileController(PropertyScript, ThreadGroupChild...)but with support for running at scale in a remote engine.Check the user guide for details on additional steps required to run them at scale in a remote engine.
- Since:
- 1.14
- See Also:
PropertyScriptBuilder.PropertyScript,whileController(PropertyScript, ThreadGroupChild...)
-
whileController
public static DslWhileController whileController(String name, Class<? extends PropertyScriptBuilder.PropertyScript<Boolean>> conditionClass, BaseThreadGroup.ThreadGroupChild... children)
Same aswhileController(Class, ThreadGroupChild...)but allowing to set a name which defines autogenerated variable created by JMeter containing iteration index.- Parameters:
name- specifies the name to assign to the controller. This variable affects the JMeter autogenerated variable__jm__<controllerName>__idxwhich holds the loop iteration number (starting at 0).- Since:
- 1.14
- See Also:
PropertyScriptBuilder.PropertyScript,whileController(PropertyScript, ThreadGroupChild...)
-
forLoopController
public static ForLoopController forLoopController(int count, BaseThreadGroup.ThreadGroupChild... children)
Builds a Loop Controller that allows to run specific number of times the given children in each thread group iteration.Eg: if a thread group iterates 3 times and the Loop Controller is configured to 5, then the children elements will run
3*5=15times for each thread.JMeter generates
__jm__for__idxvariable containing the iteration number (0 indexed), which can be helpful in some scenarios.- Parameters:
count- specifies the number of times to execute the children elements in each thread group iteration.children- contains the test plan elements to execute the given number of times in each thread group iteration.- Returns:
- the controller instance for further configuration and usage.
- Since:
- 0.27
- See Also:
ForLoopController
-
forLoopController
public static ForLoopController forLoopController(String name, int count, BaseThreadGroup.ThreadGroupChild... children)
Same asforLoopController(int, ThreadGroupChild...)but allowing to set a name which defines autogenerated variable created by JMeter containing iteration index.- Parameters:
name- specifies the name to assign to the controller. This variable affects the JMeter autogenerated variable__jm__<controllerName>__idxwhich holds the loop iteration number (starting at 0).count- specifies the number of times to execute the children elements in each thread group iteration.children- contains the test plan elements to execute the given number of times in each thread group iteration.- Returns:
- the controller instance for further configuration and usage.
- Since:
- 0.27
- See Also:
ForLoopController,forLoopController(int, ThreadGroupChild...)
-
forLoopController
public static ForLoopController forLoopController(String count, BaseThreadGroup.ThreadGroupChild... children)
Same asforLoopController(int, ThreadGroupChild...)but allowing to use JMeter expressions for number of loops.This method allows, for example, to extract from a previous response the number of times to execute some part of the test plan and use it in forLoop with something like
."${LOOPS_COUNT}"- Parameters:
count- specifies a JMeter expression which evaluates to a number specifying the number of times to execute the children elements in each thread group iteration.children- contains the test plan elements to execute the given number of times in each thread group iteration.- Returns:
- the controller instance for further configuration and usage.
- Since:
- 0.46
- See Also:
forLoopController(int, ThreadGroupChild...)
-
forLoopController
public static ForLoopController forLoopController(String name, String count, BaseThreadGroup.ThreadGroupChild... children)
Same asforLoopController(String, ThreadGroupChild...)but allowing to set a name which defines autogenerated variable created by JMeter containing iteration index.- Parameters:
name- specifies the name to assign to the controller. This variable affects the JMeter autogenerated variable__jm__<controllerName>__idxwhich holds the loop iteration number (starting at 0).count- specifies a JMeter expression which evaluates to a number specifying the number of times to execute the children elements in each thread group iteration.children- contains the test plan elements to execute the given number of times in each thread group iteration.- Returns:
- the controller instance for further configuration and usage.
- Since:
- 0.46
- See Also:
ForLoopController,forLoopController(int, ThreadGroupChild...)
-
forEachController
public static DslForEachController forEachController(String varsPrefix, String iterationVarName, BaseThreadGroup.ThreadGroupChild... children)
Builds a For each controller that iterates over a set of variables and runs a given set of children for each variable in the set.This is usually used in combination with extractors that return more than one variable (like regex extractor with -1 index), to iterate over generated variables.
JMeter generates
__jm__<iterationVarName>__idxvariable containing the iteration number (0 indexed), which can be helpful in some scenarios.- Parameters:
varsPrefix- specifies the variable prefix of the set of variables to iterate over. This will be suffixed by underscore and the iteration index number (eg: my_var_0) to get the actual variable and store its value in a variable with name specified by iterationVarName.iterationVarName- specifies the name of the variable to store the value assigned to the variable of current iteration. eg: the value of my_var_0 when first iteration and my_var is set as varsPrefix.children- contains the test plan elements to execute for the given set of variables.- Returns:
- the controller instance for further configuration and usage.
- Since:
- 0.44
- See Also:
DslForEachController
-
forEachController
public static DslForEachController forEachController(String name, String varsPrefix, String iterationVarName, BaseThreadGroup.ThreadGroupChild... children)
Same asforEachController(String, String, ThreadGroupChild...)but allowing to set a name which defines autogenerated variable created by JMeter containing iteration index.- Parameters:
name- specifies the name to assign to the controller. This variable affects the JMeter autogenerated variable__jm__<controllerName>__idxwhich holds the loop iteration number (starting at 0).varsPrefix- specifies the variable prefix of the set of variables to iterate over. This will be suffixed by underscore and the iteration index number (eg: my_var_0) to get the actual variable and store its value in a variable with name specified by iterationVarName.iterationVarName- specifies the name of the variable to store the value assigned to the variable of current iteration. eg: the value of my_var_0 when first iteration and my_var is set as varsPrefix.children- contains the test plan elements to execute the given number of times in each thread group iteration.- Returns:
- the controller instance for further configuration and usage.
- Since:
- 0.44
- See Also:
DslForEachController,forEachController(String, String, ThreadGroupChild...)
-
onceOnlyController
public static DslOnceOnlyController onceOnlyController(BaseThreadGroup.ThreadGroupChild... children)
Builds a Once Only Controller that allows running a part of a test plan only once and only on the first iteration of each thread group.Eg: if a thread group iterates 3 times and contains few samplers inside the Once Only Controller, then children elements will run 1 time for each thread.
- Parameters:
children- contains the test plan elements to execute only one time on first iteration of each thread group.- Returns:
- the controller instance for further configuration and usage.
- Since:
- 0.34
- See Also:
DslOnceOnlyController
-
runtimeController
public static DslRuntimeController runtimeController(Duration duration, BaseThreadGroup.ThreadGroupChild... children)
Builds a Runtime Controller that stops executing child elements when a period of time expires.This can be very useful to implement some time based logic like refreshing a token after certain time while doing http requests (runtimeController + whileController).
The controller executes each child sequentially until there are no more children to execute or the time has expired.
Child elements execution is not interrupted, the controller just checks on each child execution ending if the time has expired, and if so, don't execute the rest of its child elements.
- Parameters:
duration- defines de duration after which no further child elements will be executed (on each iteration). Take into consideration that JMeter supports specifying duration in seconds, so if you specify a smaller granularity (like milliseconds) it will be rounded up to seconds.children- contains the child elements to execute.- Returns:
- the controller instance for further configuration and usage.
- Since:
- 1.1
- See Also:
DslRuntimeController
-
runtimeController
public static DslRuntimeController runtimeController(String seconds, BaseThreadGroup.ThreadGroupChild... children)
Same asruntimeController(Duration, ThreadGroupChild...)but allowing to use JMeter expressions for the duration.- Parameters:
seconds- defines a JMeter expression that evaluates to a number of seconds the runtime controller will execute child elements for.children- contains the child elements to execute.- Returns:
- the controller instance for further configuration and usage.
- Since:
- 1.1
- See Also:
runtimeController(Duration, ThreadGroupChild...),DslRuntimeController
-
percentController
public static PercentController percentController(float percent, BaseThreadGroup.ThreadGroupChild... children)
Builds a Percent Controller to execute children only a given percent of times.Internally, this uses a JMeter Throughput Controller with executions percentage configuration.
- Parameters:
percent- defines a number between 0 and 100 that defines the percentage of times to execute given children elements.children- holds test plan elements to execute when for the given percent of times.- Returns:
- the controller instance for further configuration and usage.
- Since:
- 0.25
- See Also:
PercentController
-
percentController
public static PercentController percentController(String percent, BaseThreadGroup.ThreadGroupChild... children)
Same aspercentController(float, ThreadGroupChild...)but allowing using JMeter expressions (eg: ${PERCENT_VAR}) in percent parameter.This might be useful to set percents according to different profiles, for example, using different percents in production vs staging tests
- Parameters:
percent- defines a JMeter expression that evaluates to a number between 0 and 100 that defines the percentage of times to execute given children elements.children- holds test plan elements to execute when for the given percent of times.- Returns:
- the controller instance for further configuration and usage.
- Since:
- 0.63
-
weightedSwitchController
public static DslWeightedSwitchController weightedSwitchController()
Builds a Controller which executes in each iteration choosing one child according to given weights.Internally this uses BlazeMeter Weighted Switch Controller plugin.
- Returns:
- the controller instance for further configuration and usage.
- Since:
- 0.53
- See Also:
DslWeightedSwitchController
-
httpSampler
public static DslHttpSampler httpSampler(String url)
Builds an HTTP Request sampler to sample HTTP requests.- Parameters:
url- specifies URL the HTTP Request sampler will hit.- Returns:
- the HTTP Request sampler instance which can be used to define additional settings for the HTTP request (like method, body, headers, pre & post processors, etc.).
- See Also:
DslHttpSampler
-
httpSampler
public static DslHttpSampler httpSampler(Function<DslJsr223PreProcessor.PreProcessorVars,String> urlSupplier)
Builds an HTTP Request sampler to sample HTTP requests with a dynamically calculated URL.This method is just an abstraction that uses jexl2 function as URL.
WARNING: This only works when using embedded jmeter engine. Check the user guide for details on some alternative.
- Parameters:
urlSupplier- specifies URL the HTTP Request sampler will hit.- Returns:
- the HTTP Request sampler instance which can be used to define additional settings for the HTTP request (like method, body, headers, pre & post processors, etc.).
- Since:
- 0.10
- See Also:
DslHttpSampler
-
httpSampler
public static DslHttpSampler httpSampler(String name, String url)
Same ashttpSampler(String)but allowing to set a name to the HTTP Request sampler.Setting a proper name allows to easily identify the requests generated by this sampler and check its particular statistics.
- See Also:
httpSampler(String)
-
httpSampler
public static DslHttpSampler httpSampler(String name, Function<DslJsr223PreProcessor.PreProcessorVars,String> urlSupplier)
Same ashttpSampler(Function)but allowing to set a name to the HTTP Request sampler.Setting a proper name allows to easily identify the requests generated by this sampler and check its particular statistics.
WARNING: This only works when using embedded jmeter engine. Check the user guide for details on some alternative.
- Since:
- 0.10
- See Also:
httpSampler(Function)
-
httpSampler
public static DslHttpSampler httpSampler(Class<? extends PropertyScriptBuilder.PropertyScript<String>> urlSolverClass)
Same ashttpSampler(Function)but with support for running at scale in a remote engine.Check the user guide for details on additional steps required to run them at scale in a remote engine.
- Since:
- 1.14
- See Also:
httpSampler(Function)
-
httpSampler
public static DslHttpSampler httpSampler(String name, Class<? extends PropertyScriptBuilder.PropertyScript<String>> urlSolverClass)
Same ashttpSampler(Class)but allowing to set a name to the HTTP Request sampler.Setting a proper name allows to easily identify the requests generated by this sampler and check its particular statistics.
- Since:
- 1.14
- See Also:
httpSampler(Class)
-
httpHeaders
public static HttpHeaders httpHeaders()
Builds an HTTP header manager which allows setting HTTP headers to be used by HTTPRequest samplers.- Returns:
- the HTTP header manager instance which allows specifying the particular HTTP headers to use.
- See Also:
HttpHeaders
-
httpDefaults
public static DslHttpDefaults httpDefaults()
Builds an HTTP request defaults element that allows setting default values used by HTTP samplers.In general, prefer using Java variables or custom builder methods to abstract common logic for samplers which allows for easier debugging, readability and traceability. In some cases though it might be shorter/simpler to just use and httpDefaults element.
- Returns:
- the HTTP defaults test element for customization and usage.
- Since:
- 0.39
-
httpCookies
public static DslCookieManager httpCookies()
Builds a Cookie manager at the test plan level which allows configuring cookies settings used by HTTPRequest samplers.- Returns:
- the Cookie manager instance which allows configuring cookies settings.
- Since:
- 0.17
- See Also:
DslCookieManager
-
httpCache
public static DslCacheManager httpCache()
Builds a Cache manager at the test plan level which allows configuring caching behavior used by HTTPRequest samplers.- Returns:
- the Cache manager instance which allows configuring caching settings.
- Since:
- 0.17
- See Also:
DslCacheManager
-
httpAuth
public static DslAuthManager httpAuth()
Builds an Auth manager which simplifies configuration for automatic authentication of HTTP requests.- Returns:
- the Auth manager instance which allows to specify different authentications for different URLs.
- Since:
- 1.5
- See Also:
DslAuthManager
-
vars
public static DslVariables vars()
Builds a DslVariables that allows to easily initialize or update JMeter variables.This internally uses User Defined Variables when placed as test plan child and JSR223 Samplers otherwise.
- Returns:
- the DslVariables instance to define variables values and using it in a test plan.
- Since:
- 0.50
- See Also:
DslVariables
-
vars
public static DslVariables vars(String name)
Same asvars()but allowing to set a name on the element.The name is used to easily identify what the variables are being used for in the jmx.
- Since:
- 0.22
- See Also:
(String)
-
jsr223Sampler
public static DslJsr223Sampler jsr223Sampler(String script)
Builds a JSR223 Sampler which allows sampling any Java API or custom logic.- Parameters:
script- contains the script to be use while sampling. By default, this will be a groovy script, but you can change it by setting the language property in the returned post processor.- Returns:
- the JSR223 Sampler instance
- Since:
- 0.22
- See Also:
DslJsr223Sampler
-
jsr223Sampler
public static DslJsr223Sampler jsr223Sampler(String name, String script)
Same asjsr223Sampler(String)but allowing to set a name on the sampler.The name is used in collected samples to easily identify their results and as logger name which allows configuring log level, appender, etc., for the sampler.
- Since:
- 0.22
- See Also:
jsr223Sampler(String)
-
jsr223Sampler
public static DslJsr223Sampler jsr223Sampler(DslJsr223Sampler.SamplerScript script)
Same asjsr223Sampler(String)but allowing to use Java type safety and code completion when specifying the script.WARNING: This only works when using embedded jmeter engine. Check the user guide for details on some alternative.
Take into consideration that the provided script is invoked from as may threads as defined in thread group. So make sure that provided logic is thread safe.
- Since:
- 0.22
- See Also:
DslJsr223Sampler.SamplerScript,jsr223Sampler(String)
-
jsr223Sampler
public static DslJsr223Sampler jsr223Sampler(String name, DslJsr223Sampler.SamplerScript script)
Same asjsr223Sampler(String, String)but allowing to use Java type safety and code completion when specifying the script.WARNING: This only works when using embedded jmeter engine. Check the user guide for details on some alternative.
Take into consideration that the provided script is invoked from as may threads as defined in thread group. So make sure that provided logic is thread safe.
- Since:
- 0.22
- See Also:
DslJsr223Sampler.SamplerScript,jsr223Sampler(String)
-
jsr223Sampler
public static DslJsr223Sampler jsr223Sampler(Class<? extends DslJsr223Sampler.SamplerScript> scriptClass)
Same asjsr223Sampler(SamplerScript)but with support for running at scale in a remote engine.Check the user guide for details on additional steps required to run them at scale in a remote engine.
- Since:
- 1.14
- See Also:
DslJsr223Sampler.SamplerScript,jsr223Sampler(SamplerScript)
-
jsr223Sampler
public static DslJsr223Sampler jsr223Sampler(String name, Class<? extends DslJsr223Sampler.SamplerScript> scriptClass)
Same asjsr223Sampler(Class)but allowing to set a name on the sampler.The name is used in collected samples to easily identify their results and as logger name which allows configuring log level, appender, etc., for the sampler.
- Since:
- 1.14
- See Also:
jsr223Sampler(Class)
-
dummySampler
public static DslDummySampler dummySampler(String responseBody)
Builds a JMeter plugin Dummy Sampler which allows emulating a sampler easing testing other parts of a test plan (like extractors, controllers conditions, etc).Usually you would replace an existing sampler with this one, to test some extractor or test plan complex behavior (like controllers conditions), and once you have verified that the rest of the plan works as expected, you place back the original sampler that makes actual interactions to a server.
By default, this sampler, in contrast to the JMeter plugin Dummy Sampler, does not simulate response time. This helps speeding up the debug and tracing process while using it.
- Parameters:
responseBody- specifies the response body to be included in generated sample results.- Returns:
- the dummy sampler for further configuration and usage in test plan.
- Since:
- 0.46
- See Also:
DslDummySampler
-
dummySampler
public static DslDummySampler dummySampler(String name, String responseBody)
Same asdummySampler(String)but allowing to set a name on the sampler.Setting the name of the sampler allows better simulation the final use case when dummy sampler is replaced by actual/final sampler, when sample results are reported in stats, logs, etc.
- Since:
- 0.46
- See Also:
DslDummySampler,dummySampler(String)
-
jsr223PreProcessor
public static DslJsr223PreProcessor jsr223PreProcessor(String script)
Builds a JSR223 Pre Processor which allows including custom logic to modify requests.This preprocessor is very powerful, and lets you alter request parameters, jmeter context and implement any kind of custom logic that you may think.
- Parameters:
script- contains the script to be executed by the preprocessor. By default, this will be a groovy script, but you can change it by setting the language property in the returned post processor.- Returns:
- the JSR223 Pre Processor instance
- Since:
- 0.7
- See Also:
DslJsr223PreProcessor
-
jsr223PreProcessor
public static DslJsr223PreProcessor jsr223PreProcessor(String name, String script)
Same asjsr223PreProcessor(String)but allowing to set a name on the preprocessor.The name is used as logger name which allows configuring log level, appender, etc., for the preprocessor.
- Since:
- 0.9
- See Also:
jsr223PreProcessor(String)
-
jsr223PreProcessor
public static DslJsr223PreProcessor jsr223PreProcessor(DslJsr223PreProcessor.PreProcessorScript script)
Same asjsr223PreProcessor(String)but allowing to use Java type safety and code completion when specifying the script.WARNING: This only works when using embedded jmeter engine. Check the user guide for details on some alternative.
Take into consideration that the provided script is invoked from as may threads as defined in thread group. So make sure that provided logic is thread safe.
- Since:
- 0.10
- See Also:
DslJsr223PreProcessor.PreProcessorScript,jsr223PreProcessor(String)
-
jsr223PreProcessor
public static DslJsr223PreProcessor jsr223PreProcessor(String name, DslJsr223PreProcessor.PreProcessorScript script)
Same asjsr223PreProcessor(String, String)but allowing to use Java type safety and code completion when specifying the script.WARNING: This only works when using embedded jmeter engine. Check the user guide for details on some alternative.
Take into consideration that the provided script is invoked from as may threads as defined in thread group. So make sure that provided logic is thread safe.
- Since:
- 0.10
- See Also:
DslJsr223PreProcessor.PreProcessorScript,jsr223PreProcessor(String)
-
jsr223PreProcessor
public static DslJsr223PreProcessor jsr223PreProcessor(Class<? extends DslJsr223PreProcessor.PreProcessorScript> scriptClass)
Same asjsr223PreProcessor(PreProcessorScript)but with support for running at scale in a remote engine.Check the user guide for details on additional steps required to run them at scale in a remote engine.
- Since:
- 1.14
- See Also:
DslJsr223PreProcessor.PreProcessorScript,jsr223PreProcessor(PreProcessorScript)
-
jsr223PreProcessor
public static DslJsr223PreProcessor jsr223PreProcessor(String name, Class<? extends DslJsr223PreProcessor.PreProcessorScript> scriptClass)
Same asjsr223PreProcessor(Class)but allowing to set a name on the sampler.The name is used in collected samples to easily identify their results and as logger name which allows configuring log level, appender, etc., for the sampler.
- Since:
- 1.14
- See Also:
jsr223PreProcessor(Class)
-
regexExtractor
public static DslRegexExtractor regexExtractor(String variableName, String regex)
Builds a Regex Extractor which allows using regular expressions to extract different parts of a sample result (request or response).This method provides a simple default implementation with required settings, but more settings are provided by returned DslRegexExtractor.
By default, when regex is not matched, no variable will be created or modified. On the other hand when the regex matches it will by default store the first capturing group (part of expression between parenthesis) of the first match for the regular expression.
- Parameters:
variableName- is the name of the variable to be used to store the extracted value to. Additional variables<variableName>_g<groupId>will be created for each regular expression capturing group (segment of regex between parenthesis), being the group 0 the entire match of the regex.<variableName>_gvariable contains the number of matched capturing groups (not counting the group 0).regex- regular expression used to extract part of request or response.- Returns:
- the Regex Extractor which can be used to define additional settings to use when extracting (like defining match number, template, etc.).
- Since:
- 0.8
- See Also:
DslRegexExtractor
-
boundaryExtractor
public static DslBoundaryExtractor boundaryExtractor(String variableName, String leftBoundary, String rightBoundary)
Builds a Boundary Extractor which allows using left and right boundary texts to extract different parts of a sample result (request or response).This method provides a simple default implementation with required settings, but more settings are provided by returned DslBoundaryExtractor.
By default, when no match is found, no variable will be created or modified. On the other hand, when a match is found, it will by default store the first match.
- Parameters:
variableName- is the name of the variable to be used to store the extracted value to.leftBoundary- specifies text preceding the text to be extracted.rightBoundary- specifies text following the text to be extracted.- Returns:
- the Boundary Extractor which can be used to define additional settings to use when extracting (like defining match number, targetField, etc.).
- Since:
- 0.28
- See Also:
DslBoundaryExtractor
-
jsonExtractor
public static DslJsonExtractor jsonExtractor(String variableName, String query)
Builds an Extractor which allows using JMESPath or JSONPath to extract part of a JSON response.This method provides a simple default implementation with required settings, but more settings are provided by returned DslJsonExtractor.
By default, uses JMESPath for queries and when no match is found, no variable will be created or modified. On the other hand, when a match is found, it will by default store the first match.
- Parameters:
variableName- is the name of the variable to be used to store the extracted value to.query- specifies JMESPath (or JSONPath, if queryLanguage specifies so) to extract the value.- Returns:
- the JSON Extractor which can be used to define additional settings to use when extracting (like defining match number, scope, etc.).
- Since:
- 0.28
- See Also:
DslJsonExtractor
-
debugPostProcessor
public static DslDebugPostProcessor debugPostProcessor()
Builds a Debug post processor which is helpful to collect debugging information from test plans executions.This element is particularly helpful to collect JMeter variables and debug extractors during or after a test plan execution.
Created Debug post processor is configured by default to only include JMeter variables, which covers most common usages and keeps memory and disk usage low.
- Returns:
- the post processor for further configuration and usage in test plan.
- Since:
- 0.47
- See Also:
DslDebugPostProcessor
-
jsr223PostProcessor
public static DslJsr223PostProcessor jsr223PostProcessor(String script)
Builds a JSR223 Post Processor which allows including custom logic to process sample results.This post processor is very powerful, and lets you alter sample results, jmeter context and implement any kind of custom logic that you may think.
- Parameters:
script- contains the script to be executed by the post processor. By default, this will be a groovy script, but you can change it by setting the language property in the returned post processor.- Returns:
- the JSR223 Post Processor instance
- Since:
- 0.6
- See Also:
DslJsr223PostProcessor
-
jsr223PostProcessor
public static DslJsr223PostProcessor jsr223PostProcessor(String name, String script)
Same asjsr223PostProcessor(String)but allowing to set a name on the post processor.The name is used as logger name which allows configuring log level, appender, etc., for the post processor.
- Since:
- 0.9
- See Also:
jsr223PostProcessor(String)
-
jsr223PostProcessor
public static DslJsr223PostProcessor jsr223PostProcessor(DslJsr223PostProcessor.PostProcessorScript script)
Same asjsr223PostProcessor(String)but allowing to use Java type safety and code completion when specifying the script.WARNING: This only works when using embedded jmeter engine. Check the user guide for details on some alternative.
Take into consideration that the provided script is invoked from as may threads as defined in thread group. So make sure that provided logic is thread safe.
- Since:
- 0.10
- See Also:
DslJsr223PostProcessor.PostProcessorScript,jsr223PostProcessor(String)
-
jsr223PostProcessor
public static DslJsr223PostProcessor jsr223PostProcessor(String name, DslJsr223PostProcessor.PostProcessorScript script)
Same asjsr223PostProcessor(String, String)but allowing to use Java type safety and code completion when specifying the script.WARNING: This only works when using embedded jmeter engine. Check the user guide for details on some alternative.
Take into consideration that the provided script is invoked from as may threads as defined in thread group. So make sure that provided logic is thread safe.
- Since:
- 0.10
- See Also:
DslJsr223PostProcessor.PostProcessorScript,jsr223PostProcessor(String, String)
-
jsr223PostProcessor
public static DslJsr223PostProcessor jsr223PostProcessor(Class<? extends DslJsr223PostProcessor.PostProcessorScript> scriptClass)
Same asjsr223PostProcessor(PostProcessorScript)but with support for running at scale in a remote engine.Check the user guide for details on additional steps required to run them at scale in a remote engine.
- Since:
- 1.14
- See Also:
DslJsr223PostProcessor.PostProcessorScript,jsr223PostProcessor(PostProcessorScript)
-
jsr223PostProcessor
public static DslJsr223PostProcessor jsr223PostProcessor(String name, Class<? extends DslJsr223PostProcessor.PostProcessorScript> scriptClass)
Same asjsr223PostProcessor(Class)but allowing to set a name on the sampler.The name is used in collected samples to easily identify their results and as logger name which allows configuring log level, appender, etc., for the sampler.
- Since:
- 1.14
- See Also:
jsr223PostProcessor(Class)
-
responseAssertion
public static DslResponseAssertion responseAssertion()
Builds a Response Assertion to be able to check that obtained sample result is the expected one.JMeter by default uses repose codes (eg: 4xx and 5xx HTTP response codes are error codes) to determine if a request was success or not, but in some cases this might not be enough or correct. In some cases applications might not behave in this way, for example, they might return a 200 HTTP status code but with an error message in the body, or the response might be a success one, but the information contained within the response is not the expected one to continue executing the test. In such scenarios you can use response assertions to properly verify your assumptions before continuing with next request in the test plan.
By default, response assertion will use the response body of the main sample result (not sub samples as redirects, or embedded resources) to check the specified criteria (substring match, entire string equality, contained regex or entire regex match) against.
- Returns:
- the created Response Assertion which should be modified to apply the proper criteria.
Check
DslResponseAssertionfor all available options. - Since:
- 0.11
- See Also:
DslResponseAssertion
-
responseAssertion
public static DslResponseAssertion responseAssertion(String name)
Same asresponseAssertion()but allowing to set a name on the assertion, which can be later used to identify assertion results and differentiate it from other assertions.- Parameters:
name- is the name to be assigned to the assertion- Returns:
- the created Response Assertion which should be modified to apply the proper criteria.
Check
DslResponseAssertionfor all available options. - Since:
- 0.11
- See Also:
responseAssertion(String)
-
jsonAssertion
public static DslJsonAssertion jsonAssertion(String jsonQuery)
Builds an Assertion element to check that obtained sampler result JSON is the expected one.This method simplifies checking JSON responses over
responseAssertion()alternative.By default, uses JMESPath for queries and just checks for existence of specified element. Check
DslJsonAssertionfor additional options.- Parameters:
jsonQuery- specifies JMESPath (or JSONPath, if queryLanguage specifies so) to check the existence of given element in sample result response. the value.- Returns:
- the Assertion which can be used to configure further settings (like query Language, check if value in path matches regex, etc.) and used in a test plan.
- Since:
- 1.15
- See Also:
DslJsonAssertion
-
jsonAssertion
public static DslJsonAssertion jsonAssertion(String name, String jsonQuery)
Same asjsonAssertion(String)but allowing to set a name on the assertion, which can be later used to identify assertion results and differentiate it from other assertions.- Since:
- 1.15
- See Also:
jsonAssertion(String),DslJsonAssertion
-
autoStop
public static AutoStopListener autoStop()
Builds an AutoStopListener that allows to stop a test plan execution if some condition over collected metrics is met.This element is useful to avoid waisting resources (for instance execution costs associated to remote engine execution time) and time when a test plan execution is not getting an expected behavior.
When a condition is met, the test plan is stopped and a
AutoStoppedTestExceptionis thrown, containing as message an indicator for the auto stop listener name and the condition that triggered the stop.As with other listeners, the location of the listener within the plan determines which samples will be taken into consideration by the listener (eg: if listener is placed as a child of a sampler, then only that sampler will be evaluated).
Note: This element does not use AutoStop listener plugin, but is inspired on it. One important difference is that this element by default evaluates conditions on every sample and does not reset aggregations for every second. If you need to configure similar behavior as AutoStop listener plugin, then you can use
AutoStopListener.AggregatedConditionBuilder.every(java.time.Duration)andAutoStopListener.AutoStopCondition.holdsFor(java.time.Duration)- Returns:
- the listener for further configuration or usage in test plan.
- Throws:
AutoStoppedTestException- when test plan is stopped by a met condition.- Since:
- 1.19
- See Also:
AutoStopListener
-
autoStop
public static AutoStopListener autoStop(String name)
Same asautoStop()but allowing to set a name on the listener, which can help identify which autoStop listener stopped a test plan if multiple ones are configured.- Since:
- 1.19
- See Also:
autoStop(),AutoStopListener
-
jtlWriter
public static JtlWriter jtlWriter(String directory)
Builds a Simple Data Writer to write all collected results to a JTL file.This is just a handy short way of generating JTL files using as filename the template:
<yyyy-MM-dd HH-mm-ss> <UUID>.jtlIf you need to have a predictable name, consider using
jtlWriter(String, String)instead.- Parameters:
directory- specifies the directory path where jtl files will be generated in. If the directory does not exist, then it will be created.- Returns:
- the JtlWriter instance.
- See Also:
jtlWriter(String, String),JtlWriter
-
jtlWriter
public static JtlWriter jtlWriter(String directory, String fileName)
Builds a Simple Data Writer to write all collected results to a JTL file.This is particularly helpful when you need to control de file name to do later post-processing on the file (eg: use CI build ID in the file name).
- Parameters:
directory- specifies the directory path where jtl file will be generated. If the directory does not exist, then it will be created.fileName- the name to be used for the file. File names should be unique, otherwise the new results will be appended to existing file.- Returns:
- the JtlWriter instance.
- Since:
- 1.0
-
responseFileSaver
public static ResponseFileSaver responseFileSaver(String fileNamePrefix)
Builds a Response File Saver to generate a file for each response of a sample.- Parameters:
fileNamePrefix- the prefix to be used when generating the files. This should contain the directory location where the files should be generated and can contain a file name prefix for all file names (eg: target/response-files/response- ).- Returns:
- the ResponseFileSaver instance.
- Since:
- 0.13
- See Also:
ResponseFileSaver
-
influxDbListener
public static InfluxDbBackendListener influxDbListener(String influxDbUrl)
Builds a Backend Listener configured to use InfluxDB to send all results for easy tracing, historic, comparison and live test results.- Parameters:
influxDbUrl- is the URL to connect to the InfluxDB instance where test results should be sent.- Returns:
- the Backend Listener instance which can be used to set additional settings like title, token & queueSize.
- Since:
- 0.4
- See Also:
InfluxDbBackendListener
-
graphiteListener
public static GraphiteBackendListener graphiteListener(String graphiteUrl)
Builds a Backend Listener configured to use Graphite to send all results for easy tracing, historic, comparison, and live test results.Warning: DSL graphite listener uses Pickle sender, and port 2004, by default since it is more performant. This behavior differs from the one provided by the JMeter element which uses text plain instead by default.
- Parameters:
graphiteUrl- is the URL to connect to the Graphite instance where test results should be sent. You can specify the host (eg: mygraphite) or the host + port (eg: mygraphite:2004).- Returns:
- the Backend Listener instance which can be used to set additional settings like title, token & queueSize.
- Since:
- 1.25
-
htmlReporter
public static HtmlReporter htmlReporter(String reportsDirectory)
Builds an HTML Reporter which allows easily generating HTML reports for test plans.This is just a handy short way of generating html reports following naming template
<yyyy-MM-dd HH-mm-ss> <UUID>If you need to have a predictable report name, consider using
htmlReporter(String, String)instead.- Parameters:
reportsDirectory- specifies the directory where HTML reports are generated. If the reportsDirectory does not exist, then it will be created.- Returns:
- the HTML Reporter instance
- Since:
- 0.6
- See Also:
htmlReporter(String, String),HtmlReporter
-
htmlReporter
public static HtmlReporter htmlReporter(String reportsDirectory, String name)
Builds an HTML Reporter which allows easily generating HTML reports for test plans.This is particularly helpful when you need to control de report directory name to do later post-processing on it (eg: use CI build ID in the report directory name).
- Parameters:
reportsDirectory- specifies the directory where HTML reports are generated. If the reportsDirectory does not exist, then it will be created.name- the name to be used for the report directory. Names should be unique, otherwise the report generation will fail after test plan execution.- Returns:
- the HTML Reporter instance
- Since:
- 1.0
- See Also:
HtmlReporter
-
resultsTreeVisualizer
public static DslViewResultsTree resultsTreeVisualizer()
Builds a View Results Tree element to show live results in a pop-up window while the test runs.This element is helpful when debugging a test plan to verify each sample result, and general structure of results.
- Returns:
- the View Results Tree element.
- Since:
- 0.19
- See Also:
DslViewResultsTree
-
threadPause
public static DslFlowControlAction threadPause(Duration duration)
Builds a Flow Control Action that pauses the current thread for the given duration.This is an alternative to timers, which eases adding just one pause instead of applying a pause to all elements in the scope of a timer.
- Parameters:
duration- specifies the duration for the pause.- Returns:
- the test element for usage in a test plan
- Since:
- 1.25
-
threadPause
public static DslFlowControlAction threadPause(String duration)
Same asthreadPause(Duration)but allowing to use JMeter expressions for the duration.For example, you can set a delay depending on the amount of time taken in last sample with something like
.${__groovy(5000 - prev.time)}- Parameters:
duration- specifies a JMeter expression that evaluates to the number of milliseconds to pause the thread.- Returns:
- the test element for usage in a test plan
- Since:
- 1.25
-
constantTimer
public static DslConstantTimer constantTimer(Duration duration)
Builds a Constant Timer which pauses the thread with for a given duration.- Parameters:
duration- specifies the duration for the timer to wait.- Returns:
- the timer for usage in test plan.
- Since:
- 1.0
-
constantTimer
public static DslConstantTimer constantTimer(String duration)
Same asconstantTimer(Duration)but allowing tu use a JMeter expression.For example, you can set a delay depending on the amount of time taken in last sample with something like
.${__groovy(5000 - prev.time)}- Parameters:
duration- specifies a JMeter expression that evaluates to the number of milliseconds to pause the thread.- Returns:
- the timer for usage in test plan.
- Since:
- 1.25
-
uniformRandomTimer
public static DslUniformRandomTimer uniformRandomTimer(Duration minimum, Duration maximum)
Builds a Uniform Random Timer which pauses the thread with a random time with uniform distribution.The timer uses the minimum and maximum durations to define the range of values to be used in the uniformly distributed selected value. These values differ from the parameters used in JMeter Uniform Random Timer element to make it simpler for general users to use. The generated JMeter test element uses as "constant delay offset" the minimum value, and as "maximum random delay" (maximum - minimum) value.
EXAMPLE: wait at least 3 seconds and maximum of 10 seconds
uniformRandomTimer(Duration.ofSeconds(3), Duration.ofSeconds(10))- Parameters:
minimum- is used to set the constant delay of the Uniform Random Timer.maximum- is used to set the maximum time the timer will be paused and will be used to obtain the random delay from the result of (maximum - minimum).- Returns:
- The Uniform Random Timer instance
- Since:
- 1.0
- See Also:
DslUniformRandomTimer
-
throughputTimer
public static DslThroughputTimer throughputTimer(double throughputPerMinute)
Builds a Constant Throughput Timer which paces samplers to limit the throughput.The timer adds variable pauses to test plan execution to limit the throughput by checking time between timer executions.
- Parameters:
throughputPerMinute- specifies the target samples per minute.- Returns:
- the timer for usage in test plan.
- Since:
- 1.5
- See Also:
DslThroughputTimer
-
synchronizingTimer
public static DslSynchronizingTimer synchronizingTimer()
Builds a Synchronizing Timer that allows synchronizing samples to be sent all at once.This timer is useful when you need to send requests in simultaneous batches, as a way to asure the system under test gets the requests all at the same time.
- Returns:
- the timer for usage in a test plan.
- Since:
- 1.17
- See Also:
DslSynchronizingTimer
-
csvDataSet
public static DslCsvDataSet csvDataSet(String csvFile)
Builds a CSV Data Set which allows loading from a CSV file variables to be used in test plan.This allows to store for example in a CSV file one line for each user credentials, and then in the test plan be able to use all the credentials to test with different users.
By default, the CSV data set will read comma separated values, use first row as name of the generated variables, restart from beginning when csv entries are exhausted and will read a new line of CSV for each thread and iteration.
E.g: If you have a csv with 2 entries and a test plan with two threads, iterating 2 times each, you might get (since threads run in parallel, the assignment is not deterministic) following assignment of rows:
thread 1, row 1 thread 2, row 2 thread 2, row 1 thread 1, row 2
- Parameters:
csvFile- path to the CSV file to read the data from.- Returns:
- the CSV Data Set instance for further configuration and usage.
- Since:
- 0.24
- See Also:
DslCsvDataSet
-
csvDataSet
public static DslCsvDataSet csvDataSet(TestResource resource)
Same ascsvDataSet(String)but easing usage of test resources.- Parameters:
resource- test resource to use as input file for the CSV data set.- Returns:
- the CSV Data Set instance for further configuration and usage.
- Since:
- 0.54
- See Also:
csvDataSet(String)
-
counter
public static DslCounter counter(String name)
Builds a counter for easy usage of auto incremental numbers in test plans.This element is handy when generating uto incremental ids, positions in a list, etc.
- Parameters:
name- specifies the variable name used for holding the counter value.- Returns:
- the counter for further configuration and usage.
- Since:
- 1.10
-
testResource
public static TestResource testResource(String resourcePath) throws IllegalArgumentException
Allows easy usage of test resources like the ones insrc/test/resourcein maven projects.- Parameters:
resourcePath- path to locate the resource. For example, in a maven project to create a resource to file"src/test/resources/csvs/my-csv.csv"you need to usetestResource("csvs/my-csv.csv").- Returns:
- the test resource.
- Throws:
IllegalArgumentException- when no file can be located for provided resource path- Since:
- 0.54
- See Also:
TestResource
-
-