Overview
Load testing a REST API is streamlined and intuitive with LoadForge. The examples below demonstrate testing capabilities using a sample REST API. LoadForge provides the flexibility to define custom headers as required, and the ability to send requests based on the data returned from your API. Below are two illustrative examples:- Basic API Example: This showcases a straightforward set of GET requests to an API, accompanied by bearer authentication using a custom header.
- Advanced API Example: A more intricate example involving both POST and GET requests and dynamic responses based on returned data.
Basic API Example
The following Python script demonstrates how to conduct simple GET requests to your API with bearer token authentication:Advanced API Example
This test provides insights into load testing the LoadForge REST API. The script below contains comprehensive comments to elucidate each step: The test script comprises four main segments:- Fetch random hosts and tests.
- During initialization, retrieve all results, save the result IDs, and establish the bearer token.
- Acquire a random result from the previously fetched list.
- Create a new host through the API and subsequently delete it to maintain a clean slate.
LoadForge is built upon the robust foundation of locust, allowing open-source locust users to readily utilize this script. If you’re already a locust aficionado, think about importing your script to LoadForge and elevate your testing endeavors!