mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-10 16:04:04 +00:00
34 lines
1.4 KiB
Go
34 lines
1.4 KiB
Go
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)
|
|
}
|
|
}
|
|
|
|
func TestPercentileUsesConservativeNearestRankForSmallWindows(t *testing.T) {
|
|
if got := percentile([]time.Duration{time.Millisecond, 101 * time.Millisecond}, .95); got != 101*time.Millisecond {
|
|
t.Fatalf("p95 underreported small window: %s", got)
|
|
}
|
|
}
|