Giter VIP home page Giter VIP logo

k6-loadtest's Introduction

Load Testing with k6

This project performs simple unit load testing and scenario load testing on some example APIs using the k6 load testing tool.

The full description of the project can be found in instructions.pdf and report.pdf, in Persian. Some background explanation about concepts such as load testing, stress testing, checks and thresholds in k6 can also be found in the report.

Tests

1-unit-test.js

A basic unit test that hits an endpoint and validates the response.

2-scenario.js

The scenarios simulate load on the test-api.k6.io API. The script uses ./users.json and ./crocos.json for user credentials and crocodile data.

Thresholds
  • http_req_failed: The rate of failed HTTP requests should be kept below 1%.
  • http_req_duration: 95% of requests should complete within 1000ms (1 second).

Scenario 1

A gradual ramp-up of virtual users (VUs) is performed using the 'ramping-arrival-rate' executor. The goal is to simulate increasing load on the target API over time.

  1. Check Public Crocos: Verifies that the response status from the public crocodiles endpoint is 200 (OK).
  2. Check Selected Croco: Ensures that the response status from a randomly selected crocodile's endpoint is 200 and that the response contains all expected crocodile fields.

Scenario 2

A fixed number of VUs (30) perform a specified number of iterations using the 'shared-iterations' executor. The goal is to simulate a consistent load on the target API.

  1. Check Login: Verifies that the login to the API was successful by checking the response status.
  2. Check Create Crocos: Ensures that newly created crocodiles have a response status of 201 (Created) and that the response includes an assigned ID for each crocodile.

Visualization

Grafana was used to visualize the test results with k6 Grafana plugin. Explanation of this step can be found in the report.

Run

To run the tests:

k6 run 1-unit-test.js
k6 run 2-scenario.js

The test hits endpoints on https://test-api.k6.io:

  • /user/register/ - register
  • /auth/token/login/ - login
  • /my/crocodiles/ - private crocodile management
  • /my/crocodiles/{id} - select a specific private crocodile
  • /public/crocodiles/ - browse public crocodiles
  • public/crocodiles/{id} - select a specific public crocodile

Course Information

  • Course: Software Engineering II
  • University: Amirkabir University of Technology
  • Semester: Fall 2022

Let me know if you have any questions.

k6-loadtest's People

Contributors

da-nial avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.