Welcome to the k6 performance testing repository. This project is designed to test and benchmark API endpoints using k6, a modern open-source load testing tool built for developers and testers.
This repository includes performance test scripts to:
- Register users via an API.
- Simulate user login and story creation.
- Measure performance metrics such as throughput, latency, and error rates.
Key features:
- Custom scenarios for different workflows.
- Metrics collection using k6's built-in tools.
- Modular script structure for reusability.
Clone the repository and navigate to its directory:
git clone <repository-url>
cd <repository-directory>
Install any required dependencies (if applicable).
The repository includes the following key files:
- src/Secenario.js: Main k6 script defining scenarios for testing.
- helper/user.js: Helper functions for user-related operations such as registration and login.
- helper/story.js: Helper functions for story creation.
-
register_user_secenario:
- Executes user registration tasks.
- Executor:
shared-iterations
. - Virtual Users (VUs): 5.
- Iterations: 10.
- Maximum Duration: 30 seconds.
-
story_creation_secenario:
- Executes story creation tasks.
- Executor:
constant-vus
. - Virtual Users (VUs): 5.
- Duration: 10 seconds.
Run the tests with the following command:
k6 run src/Secenario.js
Use the verbose flag for more detailed logs:
k6 run --verbose src/Secenario.js
-
user_registration_counter_success
:
Counts successful user registrations. -
user_stories_counter_success
:
Counts successfully created stories.
After running the tests, view the metrics in the console output. For example:
user_registration_counter_success: 10
user_stories_counter_success: 50
Export metrics to JSON for further analysis:
k6 run --out json=output.json src/Secenario.js
Use visualization tools like k6 Cloud or Grafana for detailed insights.