Skip to content

Commit 8b0952e

Browse files
fix(pre-commit): mdformat
1 parent af9dfb1 commit 8b0952e

File tree

3 files changed

+28
-9
lines changed

3 files changed

+28
-9
lines changed

tests/unit/scheduler/OVER_SATURATION_TEST_COVERAGE.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ This document outlines the comprehensive unit test coverage for the over-saturat
66

77
## Test Summary
88

9-
**Total Tests**: 81 (48 original + 33 comprehensive)
10-
**Coverage Areas**: 8 major test classes
11-
**Test Types**: Statistical accuracy, robustness, performance, integration, edge cases
9+
**Total Tests**: 81 (48 original + 33 comprehensive) **Coverage Areas**: 8 major test classes **Test Types**: Statistical accuracy, robustness, performance, integration, edge cases
1210

1311
## Test Coverage Breakdown
1412

@@ -17,6 +15,7 @@ This document outlines the comprehensive unit test coverage for the over-saturat
1715
**Purpose**: Validate the mathematical correctness of the slope detection algorithm.
1816

1917
**Tests (7)**:
18+
2019
- `test_approx_t_ppf_accuracy`: Validates t-distribution approximation accuracy
2120
- `test_approx_t_ppf_edge_cases`: Tests t-distribution edge cases (invalid df, extremes)
2221
- `test_slope_calculation_perfect_line`: Tests perfect linear data detection
@@ -26,6 +25,7 @@ This document outlines the comprehensive unit test coverage for the over-saturat
2625
- `test_margin_of_error_calculation`: Validates confidence interval calculations
2726

2827
**Key Validations**:
28+
2929
- T-distribution approximation within expected bounds
3030
- Perfect slope detection (y = 2x + 1 → slope ≈ 2.0)
3131
- Zero slope properly handled (horizontal lines)
@@ -37,6 +37,7 @@ This document outlines the comprehensive unit test coverage for the over-saturat
3737
**Purpose**: Ensure detector handles various data conditions without crashing.
3838

3939
**Tests (6)**:
40+
4041
- `test_detector_with_empty_data`: No data scenarios
4142
- `test_detector_with_single_request`: Insufficient data handling
4243
- `test_detector_with_identical_values`: Zero variance scenarios
@@ -45,6 +46,7 @@ This document outlines the comprehensive unit test coverage for the over-saturat
4546
- `test_detector_window_management_stress`: Large dataset memory management
4647

4748
**Key Validations**:
49+
4850
- Graceful handling of empty datasets
4951
- No false positives with flat/identical data
5052
- Numerical stability with extreme values
@@ -56,12 +58,14 @@ This document outlines the comprehensive unit test coverage for the over-saturat
5658
**Purpose**: Test detector with realistic request patterns.
5759

5860
**Tests (4)**:
61+
5962
- `test_gradual_performance_degradation`: Slowly degrading performance
6063
- `test_sudden_load_spike`: Sudden performance drops
6164
- `test_variable_but_stable_performance`: Noisy but stable systems
6265
- `test_recovery_after_degradation`: Recovery scenarios
6366

6467
**Key Validations**:
68+
6569
- Detects gradual TTFT increases (1.0 → 6.0 over 50 requests)
6670
- Detects sudden spikes (5 → 50 concurrent, 1.0 → 5.0 TTFT)
6771
- No false positives with variable but stable performance
@@ -72,11 +76,13 @@ This document outlines the comprehensive unit test coverage for the over-saturat
7276
**Purpose**: Test integration between detector and constraint components.
7377

7478
**Tests (3)**:
79+
7580
- `test_constraint_metadata_completeness`: Validates complete metadata output
7681
- `test_constraint_with_realistic_request_flow`: 60-second realistic simulation
7782
- `test_constraint_disabled_never_stops`: Disabled constraint behavior
7883

7984
**Key Validations**:
85+
8086
- All required metadata fields present (`is_over_saturated`, slopes, violations, etc.)
8187
- Realistic 180-request simulation over 60 seconds
8288
- Disabled constraints never stop regardless of saturation
@@ -87,10 +93,12 @@ This document outlines the comprehensive unit test coverage for the over-saturat
8793
**Purpose**: Validate performance characteristics and efficiency.
8894

8995
**Tests (2)**:
96+
9097
- `test_detector_memory_usage`: Memory bounds with 10,000 requests
9198
- `test_detector_computational_efficiency`: 100 check_alert() calls < 1 second
9299

93100
**Key Validations**:
101+
94102
- Memory usage bounded (< 2000 requests in memory)
95103
- 100 detection calls complete in < 1 second
96104
- O(1) operations maintain efficiency at scale
@@ -100,12 +108,14 @@ This document outlines the comprehensive unit test coverage for the over-saturat
100108
**Purpose**: Test constraint factory and initialization robustness.
101109

102110
**Tests (4)**:
111+
103112
- `test_initializer_parameter_validation`: Parameter passing validation
104113
- `test_initializer_with_extreme_parameters`: Extreme but valid parameters
105114
- `test_initializer_alias_precedence`: Alias resolution order
106115
- `test_constraint_creation_with_mock_detector`: Isolated constraint testing
107116

108117
**Key Validations**:
118+
109119
- Parameters correctly passed to detector
110120
- Extreme values (0.1s minimum, 3600s window) handled
111121
- Alias precedence (`stop_over_sat` overrides `stop_over_saturated=False`)
@@ -116,6 +126,7 @@ This document outlines the comprehensive unit test coverage for the over-saturat
116126
**Purpose**: Test edge cases and prevent regression bugs.
117127

118128
**Tests (7)**:
129+
119130
- `test_detector_with_malformed_request_data`: Required field validation
120131
- `test_constraint_with_missing_timings_data`: Missing timing data handling
121132
- `test_detector_concurrent_modification_safety`: Concurrent-like access patterns
@@ -125,6 +136,7 @@ This document outlines the comprehensive unit test coverage for the over-saturat
125136
- `test_ttft_violation_counting_accuracy`: TTFT threshold counting accuracy
126137

127138
**Key Validations**:
139+
128140
- Required fields properly validated (KeyError on missing data)
129141
- Graceful handling of requests without timing data
130142
- Robust handling of concurrent-like modifications
@@ -136,12 +148,14 @@ This document outlines the comprehensive unit test coverage for the over-saturat
136148
## Test Categories by Pytest Markers
137149

138150
### Smoke Tests (`@pytest.mark.smoke`)
151+
139152
- **Count**: 15 tests
140153
- **Purpose**: Quick validation of core functionality
141154
- **Runtime**: < 30 seconds total
142155
- **Focus**: Basic initialization, core algorithms, critical paths
143156

144157
### Sanity Tests (`@pytest.mark.sanity`)
158+
145159
- **Count**: 21 tests
146160
- **Purpose**: Comprehensive validation of feature behavior
147161
- **Runtime**: 1-3 minutes total
@@ -150,26 +164,30 @@ This document outlines the comprehensive unit test coverage for the over-saturat
150164
## Coverage Metrics
151165

152166
### Algorithm Coverage
167+
153168
-**T-distribution approximation**: Mathematical accuracy validated
154169
-**Slope calculation**: Linear regression with confidence intervals
155170
-**Window management**: Time-based pruning and memory bounds
156171
-**Threshold detection**: TTFT violations and concurrent request tracking
157172
-**Statistical significance**: Margin of error and confidence testing
158173

159174
### Integration Coverage
175+
160176
-**Detector ↔ Constraint**: Proper data flow and decision making
161177
-**Constraint ↔ Scheduler**: State integration and action generation
162178
-**Factory ↔ Initializer**: Proper constraint creation and configuration
163179
-**Timing ↔ Detection**: Accurate duration and timing calculations
164180

165181
### Robustness Coverage
182+
166183
-**Empty data**: No crashes or false positives
167184
-**Malformed data**: Proper validation and error handling
168185
-**Extreme values**: Numerical stability maintained
169186
-**Memory management**: Bounded growth under stress
170187
-**Performance**: Efficiency maintained at scale
171188

172189
### Scenario Coverage
190+
173191
-**Gradual degradation**: Detected correctly
174192
-**Sudden spikes**: Detected correctly
175193
-**Stable performance**: No false positives
@@ -179,30 +197,35 @@ This document outlines the comprehensive unit test coverage for the over-saturat
179197
## Maintainer Confidence Indicators
180198

181199
### **Mathematical Correctness**
200+
182201
- T-distribution approximation validated against known values
183202
- Linear regression implementation verified with perfect test data
184203
- Confidence intervals calculated correctly
185204
- Statistical significance properly assessed
186205

187206
### **Production Readiness**
207+
188208
- Memory usage bounded under stress (10,000+ requests)
189209
- Performance maintained (100 checks < 1 second)
190210
- Graceful degradation with malformed data
191211
- No crashes under extreme conditions
192212

193213
### **Feature Completeness**
214+
194215
- All configuration parameters tested
195216
- All metadata fields validated
196217
- Enable/disable functionality verified
197218
- Factory and alias systems working
198219

199220
### **Integration Reliability**
221+
200222
- 60-second realistic simulation passes
201223
- Proper scheduler state integration
202224
- Accurate timing calculations
203225
- Complete constraint lifecycle tested
204226

205227
### **Regression Protection**
228+
206229
- Edge cases identified and tested
207230
- Numerical stability validated
208231
- State management verified

tests/unit/scheduler/test_over_saturation.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
SchedulerState,
2121
SchedulerUpdateAction,
2222
SerializableConstraintInitializer,
23+
SlopeChecker,
2324
)
2425
from guidellm.schemas import RequestInfo, RequestTimings
2526

@@ -556,10 +557,6 @@ class TestSlopeChecker:
556557
@pytest.fixture
557558
def slope_checker(self):
558559
"""Create a SlopeChecker instance for testing."""
559-
from guidellm.scheduler.constraints.over_saturation import (
560-
SlopeChecker,
561-
)
562-
563560
return SlopeChecker(moe_threshold=1.0, confidence=0.95)
564561

565562
@pytest.mark.smoke

tests/unit/scheduler/test_over_saturation_comprehensive.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"""
99

1010
import math
11+
import random
1112
import time
1213
from unittest.mock import Mock, patch
1314

@@ -309,8 +310,6 @@ def test_variable_but_stable_performance(self):
309310
minimum_duration=5.0, minimum_window_size=10, moe_threshold=2.0
310311
)
311312

312-
import random
313-
314313
random.seed(123) # Reproducible
315314

316315
# Variable but centered around stable values

0 commit comments

Comments
 (0)