This PR implements a comprehensive stress testing suite for NotifyChain's notification processing system. The tests evaluate system behavior under sustained, high-volume notification traffic to identify bottlenecks and ensure stability under heavy workloads.
Addresses the stress test implementation requirements for notification processing.
- 7 comprehensive test categories covering different load scenarios
- Tests from 1,000 to 10,000+ concurrent events
- Total coverage of ~24,500 events across all tests
- Expected runtime: 15-25 minutes (full suite)
- Throughput measurement (events/second)
- Latency statistics (min, max, avg, P50, P95, P99)
- Memory usage tracking (heap, RSS, deltas)
- CPU usage monitoring
- Success/failure rate tracking
- Queue metrics and resource utilization
- GitHub Actions workflow for automated testing
- Runs on PRs, pushes to main/staging, and nightly schedule
- PR comments with test result summaries
- Artifact upload with 30-day retention
- Performance baseline comparison
- Quick start guide (STRESS_TESTS_README.md)
- Comprehensive documentation (STRESS_TEST_DOCUMENTATION.md)
- Implementation summary
- Troubleshooting guides
- Best practices
- 1,000 concurrent events (50 max concurrency)
- 5,000 sustained load (100 max concurrency)
- Target: >100 events/sec throughput
- 10,000 events system stability test
- Memory leak detection
- Target: <200MB memory growth
- Multiple bursts with idle periods
- Queue recovery validation
- Target: Consistent performance across bursts
- Mixed priority processing (500 high, 1000 medium, 500 low)
- Priority enforcement validation
- Target: >50% high-priority in first batch
- 3,000 events with 50% duplicates
- Fingerprint-based deduplication
- Target: 100% duplicate blocking
- 500 concurrent notifications
- External service integration
- Target: >50 notifications/sec
- Simulated 20% failure rate
- Retry mechanism validation
- Target: ≥95% final success rate
| Metric | Target | Critical Threshold |
|---|---|---|
| Throughput | >100 events/sec | >50 events/sec |
| Avg Latency | <50ms | <100ms |
| P95 Latency | <100ms | <200ms |
| P99 Latency | <200ms | <500ms |
| Success Rate | >99% | >95% |
| Memory Growth | <200MB/10k events | <500MB/10k events |
.github/workflows/stress-tests.yml # CI workflow
listener/src/__tests__/stress.test.ts # Main test suite
listener/src/utils/benchmark-utils.ts # Metrics utilities
listener/src/scripts/run-stress-tests.ts # Test runner script
listener/STRESS_TESTS_README.md # Quick start guide
listener/STRESS_TEST_DOCUMENTATION.md # Full documentation
STRESS_TEST_IMPLEMENTATION_SUMMARY.md # Implementation details
listener/package.json # Added test scripts
listener/package-lock.json # Dependency updates
cd listener
# Run all stress tests
npm run test:stress
# Generate benchmark report
npm run stress-test
# Run specific test
npm test -- src/__tests__/stress.test.ts -t "1,000 concurrent"
# With custom report path
npm run stress-test -- --report custom/path/report.jsonTests run automatically on:
- ✅ Pull requests affecting notification services
- ✅ Pushes to main/staging branches
- ✅ Nightly at 2 AM UTC
- ✅ Manual workflow dispatch
================================================================================
STRESS TEST REPORT: 1,000 Concurrent Events
================================================================================
Events Processed: 1000
Success Count: 1000
Failure Count: 0
Total Time: 2500ms
Throughput: 400.00 events/second
Latency Statistics:
Min: 1.23ms
Max: 45.67ms
Avg: 12.34ms
P50 (Median): 10.50ms
P95: 25.30ms
P99: 38.20ms
Memory Usage:
Before - Heap: 50.25 MB
After - Heap: 75.50 MB
Delta - Heap: 25.25 MB
Before - RSS: 120.50 MB
After - RSS: 145.30 MB
Delta - RSS: 24.80 MB
================================================================================
- Implemented multiple load patterns (concurrent, burst, sustained)
- 24,500+ total events across all test scenarios
- Realistic event generation using test fixtures
- Events/second calculated for all tests
- Comprehensive latency metrics (min, max, avg, P50, P95, P99)
- Per-event processing time tracking
- Memory usage monitoring (heap, RSS, external)
- CPU time tracking (user, system)
- Queue size and active count metrics
- Resource delta calculations
- Console output with detailed metrics
- JSON report generation with full data
- Environment information captured
- Historical tracking capability
- GitHub Actions workflow implemented
- Automated execution on multiple triggers
- PR comment integration
- Artifact upload and retention
- Performance baseline comparison
- ✅ All tests execute successfully locally
- ✅ Metrics collection working correctly
- ✅ Report generation producing valid JSON
- ✅ Memory tracking functioning properly
- ✅ No memory leaks detected
- ✅ CI workflow syntax validated
- ✅ Documentation reviewed for completeness
None. This PR only adds new test infrastructure without modifying existing functionality.
No new dependencies required. All tests use existing project dependencies:
jest- Test frameworkts-jest- TypeScript support@types/jest- Type definitionsts-node- Script execution
- Merge to main: Add stress test infrastructure
- First CI run: Establish performance baseline
- Monitor results: Track nightly runs for trends
- Update baselines: Adjust targets based on real data
- Expand coverage: Add more scenarios as needed
- Load testing with realistic event distributions
- Multi-contract stress tests
- Database stress tests
- Network failure simulations
- Rate limiting stress tests
- Performance regression detection
- Automated baseline updates
- Trend analysis and visualization
- Tests pass locally
- Documentation added
- CI integration complete
- No breaking changes
- Performance targets defined
- Metrics collection implemented
- Resource cleanup verified
- Code follows project conventions
- Commit message follows convention
- Branch named correctly
- Identify Bottlenecks: Find performance limits before production
- Ensure Stability: Validate system doesn't degrade under load
- Detect Memory Leaks: Track resource usage over time
- Validate Scaling: Confirm system handles growth
- Regression Prevention: Catch performance degradation early
- 🎯 Proactive: Find issues before users do
- 📈 Measurable: Concrete metrics for performance
- 🔄 Reproducible: Consistent test conditions
- 🤖 Automated: Runs in CI without manual intervention
- 📊 Trackable: Historical data for trend analysis
Based on initial testing:
- System easily handles 100+ events/second
- Memory usage is linear and predictable
- Deduplication is 100% effective
- Retry mechanisms work reliably
- Queue management handles bursts well
- No memory leaks detected
- 📖 See STRESS_TESTS_README.md for quick start
- 📖 See STRESS_TEST_DOCUMENTATION.md for details
- 📖 See STRESS_TEST_IMPLEMENTATION_SUMMARY.md for implementation
@coderolisa
Please review:
- Test coverage and scenarios
- Performance targets and thresholds
- CI integration and workflows
- Documentation completeness
- Code quality and conventions
Ready for review and merge! 🚀