feat: close v3 governance evidence and slo metrics wiring
Some checks failed
CI / Build & Test (push) Has been cancelled
CI / Lint (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / Docker Build (push) Has been cancelled
CI / Release (push) Has been cancelled

This commit is contained in:
phamnazage-jpg
2026-06-08 13:59:03 +08:00
parent 13b88ba2e7
commit dbbb313a36
15 changed files with 347 additions and 39 deletions

View File

@@ -3,11 +3,14 @@ package app
import (
"context"
"net/http"
"net/http/httptest"
"net/url"
"path/filepath"
"strings"
"testing"
"time"
"sub2api-cn-relay-manager/internal/metrics"
"sub2api-cn-relay-manager/internal/routing"
)
@@ -205,12 +208,20 @@ func TestNewActionSetResolveRouteFlow(t *testing.T) {
if err != nil {
t.Fatalf("ListRouteFailoverEvents() error = %v", err)
}
if len(failovers) != 1 {
t.Fatalf("ListRouteFailoverEvents() len = %d, want 1", len(failovers))
}
if failovers[0].FromRouteID != "codex2api" || failovers[0].ToRouteID != "asxs" || failovers[0].FailureCount != 2 {
t.Fatalf("ListRouteFailoverEvents()[0] = %+v, want codex2api -> asxs failure_count 2", failovers[0])
}
req := httptest.NewRequest(http.MethodGet, "/metrics", nil)
rr := httptest.NewRecorder()
metrics.Handler().ServeHTTP(rr, req)
body := rr.Body.String()
if !strings.Contains(body, "route_decisions_total") {
t.Fatal("metrics missing route_decisions_total after resolve flow")
}
if !strings.Contains(body, "route_failovers_total") {
t.Fatal("metrics missing route_failovers_total after fallback flow")
}
}
func TestResolveRouteHelpers(t *testing.T) {