JMeter
JMeter is a web application load testing tool written in Java. Tests can be built either using the UI or directly in XML.
Concepts
- Test Plans are the root of a project. They determine execution order of Thread Groups (the default is to run both concurrently) and whether generated data should be stored on-disk.
- Thread Groups create and manage lifetime of threads that serve as virtual users according to a specified ramp-up period and execute scenarios in them.
- Controllers either generate traffic or perform some logical operation:
- Samplers (also known as Generative Controllers) generate and send requests to a server and wait for a response.
- Assertions ensure correctness of a request or response
- Pre Processors execute before the sampler's request, e.g. to generate test data.
- Post Processors execute after the sampler's request, e.g. for value extraction.
- Logic Controllers determine which request (contained within them) should be executed next.
- Test Fragments are a special type of controller that's only executed if referenced by an Include or Module Controller.
- Samplers (also known as Generative Controllers) generate and send requests to a server and wait for a response.
- Timers introduce delays before executions to simulate user behaviour (e.g. reading, completing a form).
- Listeners allow accessing gathered test case data.
- Controllers either generate traffic or perform some logical operation:
- Thread Groups create and manage lifetime of threads that serve as virtual users according to a specified ramp-up period and execute scenarios in them.
Scoping
Scoping is based on an element's location in the tree.
Execution order
Elements aren't executed in the order of their definition:
- Configuration Elements
- Pre Processors
- Timers
- Samplers
- Post Processors
- Assertions
- Listeners
Functions
Functions can be called in text inputs, and can be called with the syntax __funcName([arg1[, arg2]])
.
Random(min, max)
- Scripting:
groovy(expr, varName)
allows executing p.r.comp.lang.groovy (Private) code, storing the result in the named variable.javaScript(expr, varName)
allows executing p.r.comp.lang.js (Private) code, storing the result in the named variable.jexl(expr, varName)
executes a JEXL query.
Elements
Configuration Elements
- DNS Cache Manager determines how DNS queries are served (via the host's DNS resolver, specified resolvers or statically) and how the values are cached.
- HTTP Request Defaults reduces duplication by extracting common HTTP request values into a single element.
- HTTP Header Manager allows specifying request headers.
- HTTP Cookie Manager provides a per-thread cookie jar.
- HTTP Cache Manager provides some emulation of browser
Cache-Control
header handling.
Samplers
- GraphQL HTTP Endpoint executes a GraphQL query or mutation.
- HTTP Request fetches the given URL and can optionally fetch embedded resources matching the specified RegEx.
- FTP Request performs an operation against an FTP server.
- Flow Control Action allows performing thread or test flow control, useful when paired with logic controllers.
Logic Controllers
- Simple Controllers may be used to visually group related samplers and controllers.
- Transaction Controllers can be used to generate an additional sample combining samplers' timings to represent a single user-facing operation.
- If Controllers execute their nested controllers if a given JavaScript expression evaluates to
true
. - While Controllers execute their children until the condition evaluates to
false
. There are three types of condition:""
exits the loop when the last sample in the loop fails."LAST"
performs as""
, and will additionally not enter the loop if the sample immediately before the controller fails.- Otherwise evaluate the expression and enter the loop only if its result is equal to
"false"
.
- Runtime Controllers loop over their children until the specified runtime is met.
- Interleave Controllers iteratively execute only one of their children on each invocation. They can be configured to interleave across threads.
- Random Order Controllers randomly select one of their children to execute on each invocation.
- Once Only Controllers execute only once per thread and are subsequently skipped.
- Include Controllers allow inclusion of Test Fragments from another JMeter Test Plan.
- Module Controllers allow inclusion of Test Fragments from the current JMeter Test Plan.
- Critical Section Controllers limit execution of their children to just one thread at a time.
Pre Processors
- JSR223 executes a JSR 223 script.
- User Parameters assigns properties statically for the specified users.
- HTML Link Parser extracts links and forms from HTML.
- RegEx User Parameters extracts key-value pairs from the response as returned in regular expression match groups.
Post Processors
- JSR223 executes a JSR 223 script.
- CSS Selector Extractor extracts the value of the specified HTML attribute from an element matching the specified p.r.comp.lang.markup.css (Private) selector.
- JSON Extractor extracts data from JSON responses using JSONPath expressions.
- JSON JMESPath Extractor extracts data from JSON responses using JMESPath expressions.
- XPath Extractor extracts XML/SGML elements using XPath expressions.
- Regular Expression Extractor extracts text from a response using PCRE.
Timers
- Constant Timers insert a constant delay between samplers.
- Constant Throughput Timers wait for the sum of a minimum constant delay and a maximum random value (specified in milliseconds).
- Synchronising Timers are designed to execute many requests at the same time, and work by blocking threads until the specified number of user threads are blocked.
- Uniform Random Timers pause threads for a random amount of time, equally weighting all possible wait times.
Listeners
- View Results Tree generates a visual representation of the test run.
- Summary Report is per sampler.
- Aggregate Report is per thread group.
Plugin Manager
Plugins Manager is a community-maintained extension to JMeter that provides GUI for plugin installation. Some packaging may install it by default.
Backlinks