feat: add executable multiplayer SLO checks

This commit is contained in:
Josh Creek
2026-08-31 21:02:29 +01:00
parent 3dde0ffb79
commit c0d1c33f54
3 changed files with 98 additions and 1 deletions
+27
View File
@@ -0,0 +1,27 @@
package observability
import (
"testing"
"time"
)
func TestEvaluateSLOAcceptsHealthyWindow(t *testing.T) {
window := SLOWindow{RegionalRTT: []time.Duration{20 * time.Millisecond, 40 * time.Millisecond}, Assignment: []time.Duration{time.Second}, Connection: []time.Duration{time.Second}, APILatency: []time.Duration{100 * time.Millisecond}, Matches: []bool{true, true, true}, Headroom: .50}
if violations := EvaluateSLO(window); len(violations) != 0 {
t.Fatalf("healthy window violations = %+v", violations)
}
}
func TestEvaluateSLOFlagsEveryLaunchGate(t *testing.T) {
window := SLOWindow{RegionalRTT: []time.Duration{101 * time.Millisecond}, Assignment: []time.Duration{11 * time.Second}, Connection: []time.Duration{6 * time.Second}, APILatency: []time.Duration{251 * time.Millisecond}, Matches: []bool{true, false}, TickBacklog: true, Headroom: .29}
violations := EvaluateSLO(window)
if len(violations) != 7 {
t.Fatalf("violations = %+v", violations)
}
}
func TestEvaluateSLODoesNotInventFailureForEmptyOptionalWindows(t *testing.T) {
if violations := EvaluateSLO(SLOWindow{}); len(violations) != 0 {
t.Fatalf("empty window violations = %+v", violations)
}
}