This project contains a JMeter test plan for testing the Swagger Petstore API. The test plan is defined in api-jmeter.jmx and uses data from pet_data.csv, integrated into CI.
api-jmeter.jmx: The main JMeter test plan.pet_data.csv: CSV file with pet data (name, status, photoUrl)..github/workflows/jmeter.yml: GitHub Actions workflow for running JMeter tests in CI.
The test plan performs the following actions:
-
Reads pet data from CSV
- Uses
pet_data.csvas a data source. - Variables:
name,status,photoUrl.
- Uses
-
HTTP Header Manager
- Sets
Content-Type: application/jsonfor requests.
- Sets
-
Add Pet (POST /v2/pet)
- Sends a POST request to add a new pet using data from the CSV.
- Generates a random
petIdfor each request.
-
Extract petId
- Extracts the
idfrom the response and stores it as${petId}for later use.
- Extracts the
-
Get Pet (GET /v2/pet/${petId})
- Retrieves the pet by its ID.
-
Update Pet (PUT /v2/pet)
- Updates the pet's name (appends
-updated).
- Updates the pet's name (appends
-
Find Pets by Status (GET /v2/pet/findByStatus?status=pending)
- Retrieves pets with status
pending.
- Retrieves pets with status
-
Delete Pet (DELETE /v2/pet/${petId})
- Deletes the pet by its ID.
-
Assertions
- Each HTTP request checks for a
200response code.
- Each HTTP request checks for a
-
Timers
- Think times and random pauses are added between requests.
-
Reports
- Includes "View Results Tree" and "Summary Report" listeners.
- Number of Threads: 1
- Ramp-Up Period: 1 second
- Loop Count: 1
- Open
api-jmeter.jmxin JMeter. - Ensure
pet_data.csvis in the same directory as the JMX file. - Run the test plan.
- The test plan uses both the CSV Data Set Config and a Groovy script to read random lines from the CSV. You may want to remove one of these methods to avoid conflicts.
- Make sure JMeter has access to the required libraries for JSON processing (Jackson) if running the Java post