Skip to content

zafir0-0/API-Performance-Testing-with-k6

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

k6 Performance Testing

This repository contains performance testing scripts written with k6 for two API performance testing scenarios.

Tech Stack

  • k6
  • JavaScript (ES6)

Video Demonstration

K6.mp4

Scenario 1 – Daily Finance API Performance Test

Report

image

APIs Tested

Method Endpoint
POST /api/auth/login
GET /api/user/users
GET /api/user/:id

Test Workflow

  1. Login as Admin.

  2. Extract the authentication token.

  3. Fetch all users.

  4. Randomly select a user.

  5. Search the selected user by ID.

  6. Print:

    • User ID
    • Name
    • Email
    • Phone Number
  7. Print response time for each API.

API Tags

  • Admin Login API
  • Get All Users API
  • Get User By ID API

Validations

  • Login response status is 200
  • User list response status is 200
  • User details response status is 200
  • Selected user ID matches searched user ID

Thresholds

API Threshold
Admin Login API p(95) < 600ms
Get All Users API p(95) < 800ms
Get User By ID API p(95) < 600ms

Scenario 2 – DemoQA BookStore Performance Test

Report

image

API Tested

GET

https://demoqa.com/BookStore/v1/Books

Load Pattern

Stage Duration
Ramp up to 10 VUs 20s
Stay at 10 VUs 30s
Ramp up to 25 VUs 20s
Stay at 25 VUs 30s
Ramp down to 0 VUs 20s

Validations

  • Response status is 200
  • Response body contains books
  • Response time is below 600ms

Thresholds

  • 95% of requests complete within 600ms
  • Failed request rate remains below 1%

Output

The script prints the total number of books returned by the API.


Running the Tests

Run Question 1:

k6 run question1.js

Run Question 2:

k6 run question2.js

Expected Results

  • API response status validation
  • API response time logging
  • Random user selection and verification
  • User information printed to the console
  • Total number of books printed
  • Threshold evaluation after test completion

About

k6 Performance Testing project featuring API load tests for Daily Finance and DemoQA BookStore. Includes authentication, token handling, random user validation, response time logging, thresholds, staged load testing, and API performance verification using JavaScript (ES6).

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors