feat: complete Windows client control and recovery paths

This commit is contained in:
2026-09-06 13:37:32 +00:00
parent 56b15c7f4f
commit 486894557d
38 changed files with 2188 additions and 106 deletions
+42
View File
@@ -0,0 +1,42 @@
package observability
import (
"net/http"
"net/http/httptest"
"strings"
"testing"
)
func TestHealthHandlerReadinessAndMetrics_HP_OPS_01(t *testing.T) {
t.Parallel()
health := New()
health.Inc("dispatch_attempt")
handler := health.Handler(Paths{Liveness: "/live", Readiness: "/ready", Metrics: "/metrics"})
ready := httptest.NewRecorder()
handler.ServeHTTP(ready, httptest.NewRequest(http.MethodGet, "/ready", nil))
if ready.Code != http.StatusServiceUnavailable || !strings.Contains(ready.Body.String(), "ready=false") {
t.Fatalf("initial readiness = %d %q", ready.Code, ready.Body.String())
}
health.SetReady(true)
health.SetDirty(true)
ready = httptest.NewRecorder()
handler.ServeHTTP(ready, httptest.NewRequest(http.MethodGet, "/ready", nil))
if ready.Code != http.StatusOK || !strings.Contains(ready.Body.String(), "dirty=true") {
t.Fatalf("ready health = %d %q", ready.Code, ready.Body.String())
}
metrics := httptest.NewRecorder()
handler.ServeHTTP(metrics, httptest.NewRequest(http.MethodGet, "/metrics", nil))
if metrics.Code != http.StatusOK || !strings.Contains(metrics.Body.String(), "rvbox_dispatch_attempt_total 1") {
t.Fatalf("metrics = %d %q", metrics.Code, metrics.Body.String())
}
}
func TestHealthMetricNamesAreBounded_BH_OPS_01(t *testing.T) {
t.Parallel()
health := New()
health.Inc("bad name")
_, _, counters := health.Snapshot()
if len(counters) != 0 {
t.Fatalf("invalid metric name recorded: %#v", counters)
}
}