mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-11-03 07:11:01 +00:00
Wait for all informers to sync in /readyz.
This commit is contained in:
@@ -98,11 +98,15 @@ func TestRun(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func endpointReturnsStatusOK(client *kubernetes.Clientset, path string) bool {
|
||||
res := client.CoreV1().RESTClient().Get().AbsPath(path).Do(context.TODO())
|
||||
func endpointReturnsStatusOK(client *kubernetes.Clientset, path string) (bool, error) {
|
||||
res := client.CoreV1().RESTClient().Get().RequestURI(path).Do(context.TODO())
|
||||
var status int
|
||||
res.StatusCode(&status)
|
||||
return status == http.StatusOK
|
||||
_, err := res.Raw()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return status == http.StatusOK, nil
|
||||
}
|
||||
|
||||
func TestLivezAndReadyz(t *testing.T) {
|
||||
@@ -113,11 +117,11 @@ func TestLivezAndReadyz(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if !endpointReturnsStatusOK(client, "/livez") {
|
||||
t.Fatalf("livez should be healthy")
|
||||
if statusOK, err := endpointReturnsStatusOK(client, "/livez"); err != nil || !statusOK {
|
||||
t.Fatalf("livez should be healthy, got %v and error %v", statusOK, err)
|
||||
}
|
||||
if !endpointReturnsStatusOK(client, "/readyz") {
|
||||
t.Fatalf("readyz should be healthy")
|
||||
if statusOK, err := endpointReturnsStatusOK(client, "/readyz"); err != nil || !statusOK {
|
||||
t.Fatalf("readyz should be healthy, got %v and error %v", statusOK, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user