Skip to content

feat: implement comprehensive load & stress testing with k6 (#691)#760

Open
dev-fani wants to merge 1 commit into
BrainTease:mainfrom
dev-fani:feature/691-load-stress-testing-k6
Open

feat: implement comprehensive load & stress testing with k6 (#691)#760
dev-fani wants to merge 1 commit into
BrainTease:mainfrom
dev-fani:feature/691-load-stress-testing-k6

Conversation

@dev-fani

Copy link
Copy Markdown

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

Closes #691

…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**
@drips-wave

drips-wave Bot commented Jun 29, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Testing] Load & Stress Testing with k6

1 participant