Добавить генератор нагрузки, сбор метрик реплик и сценарии экспериментов для отказов, rolling update и трека 1

This commit is contained in:
2026-11-02 17:44:59 +03:00
parent c5cdcb3377
commit b2973405f3
30 changed files with 2067 additions and 18 deletions
+24
View File
@@ -143,3 +143,27 @@ func waitFor(t *testing.T, url string, status int) {
}
t.Fatalf("%s did not return %d in time", url, status)
}
// The debug listener has no drain: it serves the benchmark's metrics scraper
// only and stops with the process.
func TestRunDebugServesUntilCancelled(t *testing.T) {
log := slog.New(slog.NewTextHandler(io.Discard, nil))
ln, err := net.Listen("tcp", "127.0.0.1:0")
if err != nil {
t.Fatal(err)
}
h := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusTeapot) })
ctx, cancel := context.WithCancel(context.Background())
done := make(chan error, 1)
go func() { done <- server.RunDebug(ctx, log, ln, h) }()
waitFor(t, "http://"+ln.Addr().String()+"/debug/vars", http.StatusTeapot)
cancel()
select {
case err := <-done:
if err != nil {
t.Fatalf("RunDebug returned %v", err)
}
case <-time.After(2 * time.Second):
t.Fatal("RunDebug did not stop after cancel")
}
}