GeekLoad contains many different operations to simulate client applications. Each of these operations, in addition to a number of unique properties and functions, has a set of common features.
To start working with the request, you need to get the connection object by specifying the server URL or the URL of the base API path.
The presence of a slash at the end of the URL connection does not matter in all cases.
When creating a connection object, the connection to the server does not occur.
You can make the connection explicitly. In this case, you will receive the duration of the request separately from the duration of the connection in all reports:
In any case, with further actions with the connection object, a connection to the server will be made, if this has not already been done.
By default, connections within the lifecycle of a single virtual user are cached.To disable automatic caching, use the following code:
All operations executing requests work according to the same algorithm:
A request build can consist of one or more calls to builder methods.
When calling any request builder method, the request is not called directly. The sync\async methods are designed for this.Calls of request operations can be collected in chains. In this case, the assembly of the next request should be started instead of the sync\async methods.
All requests in the chain are executed sequentially and synchronously relative to each other, regardless of the method of starting the chain (sync or async). To save data and transfer it to the following requests in the chain, use Session object.
Operations can be performed asynchronously using the async() method and standard JavaScript syntax.
Generates a sequence of actions to be performed after the successful execution of the operation.
There are tree types of actions: custom code, checking and saving in a special storage object.
To perform checks of any complexity, you can specify a custom handler that returns a Boolean with the result of the check.
If an exception occurs when executing this code, the status of the corresponding operation will be changed to erroneous and execution will continue.
You can also simply execute the code without returning the result:
All checks work according to the same algorithm:
Any check begins with specifying the source of the data being checked. Then you must specify a comparison expression and, optionally, a custom error message.
Returns the response body as utf-8 encoded text.
Returns the value from the response body selected using XPath.
Returns the value obtained using a regular expression.
Returns the header from the response headers selected by name.
Returns the cookie from the response cookies selected by name.
Inverts the expression.
Checks the existence of the value.
Checks that the received value is equal to the reference value.
Checks that the received value is less than the reference value.
Checks that the received value is great than the reference value.
Checks that the received value contains the reference value.
If the received value is a string, then the occurrence of the string is checked.
If the received value is an array, then the equality of the reference value to one of the array elements is checked.
Checks that the reference value contains the received value.
If the received value is a string, then the occurrence of the string is checked.
If the received value is an array, then the equality of the reference value to one of the array elements is checked.
Sets a optional custom error message for a failed check.Sets a custom error message for a failed check.
To transfer values between requests, you can use not only global variables, but also a specialized Session object. It is available in all scripts of the project:
Saving the value in the Session object.
Starting the synchronous execution of the request and returning the response.
Asynchronous execution of the operation starts and returns a promise that returns the result of the operation.
Setting a custom name for the operation. This name is used in detailed operation reports and for SLA control.
To simulate pauses between the actions of a real user or client application in a chain of calls, the pause method is used.
The delay duration of this operation is equal to a random value in the range between the two parameters of this method.