/K6

Getting Started with K6

Primary LanguageJavaScript

K6

This repository was created for basic/intermediate learning of using K6.

πŸ’» Pre-requisites

  1. Node.js JS v16 or higher for API usage
  2. K6 Installation
  3. MongoDB for API usage -

MongoDB NOTE:

  1. Create a project
  2. Create an user and password
  3. Update the MONGO_URL in api/src/.env file => mongodb+srv://USER:PASSWORD@cluster0.3yi5vct.mongodb.net/UserDB?retryWrites=true&w=majority

User API

πŸ”– Functional requirements

Registration

  • Should return the IDs when registering a new user
  • Should return 201 when registering a new user
  • Should return 400 when trying to register without email and password
  • Should return 400 if the email is duplicated
campos descrição tipo obrigatório
email unique user identifier email yes
password user's password text yes

πŸ”– Non-functional Requirements

Registration

  • Successful registration should occur within 2 seconds
  • Unsuccessful registrations should occur within 2 seconds
  • Up to 100 simultaneous user registrations should be supported
  • The error margin in registration should be at least 1%

πŸš€ Tecnologias

  • [Node.js] - development platform
  • [Express] - framework where the API was built
  • [MongoDB] - Database (Non-relational)

πŸ‘¨πŸ»β€πŸ’» How to run the project (API)

Execute the following commands to install the project's dependencies:

cd api
yarn install
yarn dev

πŸ‘¨πŸ»β€πŸ’» How to run the K6 test

Run k6 with the following command:

k6 run script.js

Now run a load test with more than one virtual user and a longer duration:

k6 run --vus 10 --duration 30s script.js

Running a 30-second, 10-VU load test


πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.


Reference

Official repository: https://github.com/weareqacademy/curso-k6-basico