[Testing] Add k6 Load Testing Suite to Identify Performance Bottlenecks Under Stress - #40
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces a comprehensive load testing suite using Grafana k6 to identify performance bottlenecks under stress for the EquipChain backend API. Five distinct test scenarios are implemented covering smoke, load, stress, spike, and soak testing patterns.
Closes #20
Changes Made
New API Endpoints (
index.js)GET /api/health— Health check endpoint returning server uptime, status, and timestampPOST /api/auth/challenge— Mock wallet-based auth challenge returning a JWT tokenGET /api/protected— Protected route requiring a Bearer token for accessk6 Load Testing Suite (
k6/)k6/smoke.jsk6/load.jsk6/stress.jsk6/spike.jsk6/soak.jsShared Configuration (
k6/shared.js)BASE_URLenvironment variablerandomWallet(),randomInt(),thinkTime()npm Scripts (
package.json)npm run k6:smoke— Run smoke testnpm run k6:load— Run load testnpm run k6:stress— Run stress testnpm run k6:spike— Run spike testnpm run k6:soak— Run soak testnpm run k6:quick— Run all tests except soak (which takes 30+ min)Testing (
test/server.test.js)Documentation (
README.md)Configuration (
.gitignore)k6/results/*(generated reports) while preserving directory structure via.gitkeepVerification
npm test)How to Test