Files
Pulse/internal/api/slo_budget_test.go
rcourtman 2a77054035 Fix filtered chart reads and verify the idle-worker SLO
Stream ungrouped retained reads in the existing time-major index order,
avoiding temporary metric sorts without changing tier reconciliation or
chart samples. Extend query-plan and filtered-result coverage.

Add an explicit strict mode for the existing 90 ms API budget and an
optional fresh-worker CI proof with fixed executable identities and raw
capacity evidence. Keep ordinary hosted budgets and required gates intact.

Contract-Neutral: Chart payloads, retained-tier reconciliation, sampling, index layout and source/release gates are unchanged; the implementation removes an unnecessary sort and adds controlled verification of existing latency budgets.
2026-10-18 19:13:30 +01:00

37 lines
1.1 KiB
Go

package api
import (
"testing"
"time"
)
func TestAPISLOBudgetSelection(t *testing.T) {
const local = 90 * time.Millisecond
const hosted = 550 * time.Millisecond
for _, tc := range []struct {
name, actions, runID, strict string
target time.Duration
enforced bool
}{
{"local", "", "", "", local, false},
{"shared-worker", "true", "", "", local, false},
{"hosted", "true", "123", "", hosted, true},
{"strict-local", "", "", "true", local, true},
{"strict-shared-worker", "true", "", "true", local, true},
{"strict-hosted", "true", "123", "true", local, true},
{"disabled-hosted", "true", "123", "false", hosted, true},
} {
t.Run(tc.name, func(t *testing.T) {
t.Setenv("GITHUB_ACTIONS", tc.actions)
t.Setenv("GITHUB_RUN_ID", tc.runID)
t.Setenv("PULSE_STRICT_LOCAL_API_SLOS", tc.strict)
if got := effectiveAPISLOTarget(local, hosted); got != tc.target {
t.Fatalf("target=%v, want %v", got, tc.target)
}
if got := apiLatencyBudgetEnforced(); got != tc.enforced {
t.Fatalf("enforced=%v, want %v", got, tc.enforced)
}
})
}
}