Normalize registry and release tag references before Buildx runs. Use process-local liveness so a control-plane outage does not restart a healthy worker container.
34 строки
668 B
Go
34 строки
668 B
Go
package main
|
|
|
|
import (
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
)
|
|
|
|
func TestProbeLiveness(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
tests := []struct {
|
|
name string
|
|
code int
|
|
want int
|
|
}{
|
|
{name: "healthy", code: http.StatusOK, want: 0},
|
|
{name: "unhealthy", code: http.StatusServiceUnavailable, want: 1},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
t.Parallel()
|
|
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
|
w.WriteHeader(tt.code)
|
|
}))
|
|
defer srv.Close()
|
|
|
|
if got := probeLiveness(srv.URL); got != tt.want {
|
|
t.Fatalf("probeLiveness() = %d, want %d", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|