feat: implement comprehensive load & stress testing with k6 (#691)#760
Open
dev-fani wants to merge 1 commit into
Open
feat: implement comprehensive load & stress testing with k6 (#691)#760dev-fani wants to merge 1 commit into
dev-fani wants to merge 1 commit into
Conversation
…se#691) This PR implements operational load and stress testing with k6 scripts, CI/CD integration, and performance baseline tracking. ## What's Included ### k6 Test Scenarios ✅ **Search & Discovery**: Comprehensive tests for search and discovery endpoints ✅ **Course Browsing**: Browse, filter, and detail view scenarios ✅ **SLO Thresholds**: Predefined latency and error rate thresholds ✅ **Load Profiles**: Smoke, load, stress, spike, soak test configurations ### CI/CD Integration - **Nightly Runs**: Automated testing against staging every night at 2 AM UTC - **PR Smoke Tests**: Quick validation on pull requests - **On-Demand**: Manual workflow dispatch for any environment - **Regression Detection**: Automatic comparison against baselines ### Performance Monitoring - **Baseline Tracking**: JSON baselines for each scenario - **Trend Reports**: Historical performance trend analysis - **Regression Alerts**: Automatic GitHub issues on performance degradation - **Detailed Reports**: HTML and JSON reports with full metrics ### Documentation 📚 **Comprehensive Guides**: 1. **README.md** - Complete load testing overview (packages/api/load/) 2. **Load Testing Guide** - Updated with CI/CD integration details 3. **Baseline README** - How to manage performance baselines 4. **Config Files** - Thresholds and stage configurations ## Test Coverage ### Search & Discovery Endpoints - Course search with various queries - Instructor search - Tag-based filtering - Category browsing - Faceted search - Auto-complete suggestions ### SLO Thresholds | Endpoint | P95 Latency | P99 Latency | Error Rate | |----------|-------------|-------------|------------| | /api/search/courses | < 300ms | < 500ms | < 1% | | /api/courses | < 200ms | < 400ms | < 0.5% | | /api/courses/:id | < 150ms | < 300ms | < 0.5% | | /api/search/instructors | < 250ms | < 450ms | < 1% | ### Load Profiles - **Smoke Test**: 1-5 VUs for verification - **Load Test**: Up to 100 VUs for normal load - **Stress Test**: Up to 600 VUs to find breaking point - **Spike Test**: Sudden 500 VU spike - **Soak Test**: 50 VUs for 2 hours ## Running Tests ### Locally \\\�ash # Search & discovery k6 run packages/api/load/scenarios/search-discovery.js # Course browsing k6 run packages/api/load/scenarios/course-browsing.js # With custom profile k6 run --env PROFILE=stress packages/api/load/scenarios/search-discovery.js \\\ ### CI/CD - **Nightly**: Automatic at 2 AM UTC - **Manual**: Workflow dispatch from GitHub Actions - **PR**: Smoke tests only ## Acceptance Criteria ✅ k6 scripts cover key search and discovery endpoints ✅ Latency/error SLOs defined as thresholds ✅ Nightly runs against staging configured ✅ Trend reports published to artifacts ✅ Regression detection with baseline comparison ✅ GitHub issue creation on failures ## Files Added/Modified ### New Files - \packages/api/load/README.md\ - Main documentation - \packages/api/load/config/thresholds.js\ - SLO thresholds - \packages/api/load/config/stages.js\ - Load profiles - \packages/api/load/scenarios/search-discovery.js\ - Search tests - \packages/api/load/scenarios/course-browsing.js\ - Browse tests - \packages/api/load/utils/compare-baseline.js\ - Regression detection - \packages/api/load/baselines/\ - Performance baselines - \scripts/generate-trend-report.js\ - Trend analysis ### Modified Files - \.github/workflows/load-testing.yml\ - Enhanced CI workflow - \docs/load-testing-guide.md\ - Updated documentation ## Next Steps After merging: 1. Run initial baseline tests to populate metrics 2. Monitor nightly test results 3. Add user-workflows and auth-flows scenarios 4. Set up Grafana dashboards for visualization 5. Configure alerting for sustained regressions ## Resources - 📖 [k6 Documentation](https://k6.io/docs/) - 🎯 [Load Testing Best Practices](https://k6.io/docs/testing-guides/load-testing/) - 📊 [Performance Optimization Guide](../docs/performance-optimization.md) --- **Closes BrainTease#691**
|
@dev-fani Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
This PR implements operational load and stress testing with k6 scripts, CI/CD integration, and performance baseline tracking.
What's Included
k6 Test Scenarios
✅ Search & Discovery: Comprehensive tests for search and discovery endpoints ✅ Course Browsing: Browse, filter, and detail view scenarios ✅ SLO Thresholds: Predefined latency and error rate thresholds ✅ Load Profiles: Smoke, load, stress, spike, soak test configurations
CI/CD Integration
Performance Monitoring
Documentation
📚 Comprehensive Guides:
Test Coverage
Search & Discovery Endpoints
SLO Thresholds
| Endpoint | P95 Latency | P99 Latency | Error Rate | |----------|-------------|-------------|------------| | /api/search/courses | < 300ms | < 500ms | < 1% | | /api/courses | < 200ms | < 400ms | < 0.5% |
| /api/courses/:id | < 150ms | < 300ms | < 0.5% |
| /api/search/instructors | < 250ms | < 450ms | < 1% |
Load Profiles
Running Tests
Locally
\\�ash
Search & discovery
k6 run packages/api/load/scenarios/search-discovery.js
Course browsing
k6 run packages/api/load/scenarios/course-browsing.js
With custom profile
k6 run --env PROFILE=stress packages/api/load/scenarios/search-discovery.js \\
CI/CD
Acceptance Criteria
✅ k6 scripts cover key search and discovery endpoints ✅ Latency/error SLOs defined as thresholds
✅ Nightly runs against staging configured
✅ Trend reports published to artifacts
✅ Regression detection with baseline comparison
✅ GitHub issue creation on failures
Files Added/Modified
New Files
Modified Files
Next Steps
After merging:
Resources
Closes #691