How do I get information about the load test context from a script?

When running a load test, the user scenario script is run in a specific load test context. The load script API provides the following methods to access this information in your scripts.

Client module: access current client/VU information.

get_id: ID of the client/VU.

get_load_generator_id: ID of the load generator.

get_repetition: get the current repetition of the client/VU.

get_source_ip: IP address of the client/VU.

get_load_zone: API is coming soon.

Test module: access test-wide settings and data.

get_name: load test name.

get_clients: number of running client/VUs.

is_validation: true if the script is running a validation.

Having access to the load test context information can help make your performance tests more powerful, and allows you to reuse the same user scenario script in different tests.

For example, setup different thresholds based on the number of users.
local response = http.get({

local threshold_x = 0.5
if test.get_clients() > 1000 then
   -- increase threshold when large load
   threshold_x = 0.9

if response.total_load_time > threshold_x then
  log.error('threshold X fails')

Feedback and Knowledge Base