The first step is to prepare the HTTP API call. Each HTTP API call is a message in CloudTest, and this can be prepared in a clip. The screenshots of the messages in the clips for each of the API calls are shown below:
(Messages for registration and login APIs)
The clips themselves are set to have a delay of one second (see the image below). This is so that when you scale the number of users, it automatically scales to increase the number of transactions per second (e.g., if you load test 1,000 users, it also loads with 1,000 transactions per second).
(Clip with one-second delay)
When preparing a clip for HTTP API calls, the best practice is to make sure headers such as Content Type are included. Another best practice is to include a user-agent header so that the test messages can be tracked, as in the image, below.
(HTTP request headers in messages)
Below is an example of the curl commands for login and registration:
In addition, for errors to be tracked properly, it might be necessary to add in a validation in the message from the HTTP response (see the image below). By default, an error will only be logged if it is HTTP 4xx or 5xx response. However, if there’s a valid HTTP 200 response but an error in the json response, this is not be logged as an error. Hence, validations are important for reporting and tracking during the load test. It is also possible to enable more granular error tracking by matching the strings that indicate an error condition.
(Validation from the HTTP response)
Define validation for error tracking; enable granular error tracking for easier troubleshooting.
Updated over 1 year ago