Load Script API Reference Guide

Load scripts are used to program the behavior of simulated clients in a load test. Each user scenario has its own load script that determines exactly what objects the simulated user will load from the target site during the load test. Simulated users in a load test can run different user scenarios and load scripts, allowing the emulation of multiple user types in the same load test.

Load scripts are programs written using the high-level programming language Lua and can be very simple or very complex, depending on the requirements and programming skills of the tester.

Apart from native functionality of the Lua language, load script programmers can also use the Load Impact load script API to write their load scripts. This API consists of a subset of the Lua standard library, plus a number of Load Impact-specific functions and helper routines, all callable from within the Lua load script. We list the complete documentation available here. Below are direct links to certain sections of that document(which includes examples):

Standard Lua Library

The standard Lua library modules and functions are also available for use in load scripts.

Base64 Module

Functions to decode/encode data from/to base64.

Bit Module

This module provides functionality for bit manipulations. It is based on the LuaJIT BitOp module – see http://bitop.luajit.org/api.html for more details about BitOp.

Client Module

Functions to control execution and extract information surrounding the current client/VU.

Datastore Module

The Datastore modules provides functionality to interact with uploaded data stores (CSV files), allowing easy data parameterization in load scripts.

HTML Module

The HTML module provides functions to make the interaction with HTML and its DOM easier, specifically forms.

HTTP Module

This module provides the core functionality of generating outbound HTTP requests and making HTTP responses available to the script writer for optional further processing.

JSON Module

This module provides functionality for encoding to and decoding from JSON format. Important to note is that this module currently doesn't support null values.

LOG Module

Functions to log things during a test run. Logged messages will end up on the test result page during a load test or shown validation window during validation runs.

REGEX Module

This module provides powerful regular expression (regex) functionality based on the widely used PCRE C library.

Result Module

The result module contains functionality for controlling the aggregation and storage of metric data. For example, the result.custom_metric function allows you to store arbitrary result metrics during a load test.

Test Module

The test module provides APIs to access test-wide settings and data.

URL Module

Functions to compose and decompose URLs and other miscellaneous URL functionality.

Util Module

The Util module contains miscellaneous functionality that can be useful in a load script, such as time functions etc.

XML Module

This module provides functionality to parse and query XML.

Feedback and Knowledge Base