Wait for all informers to sync in /readyz.

This commit is contained in:
Maciej Borsz
2020-06-18 15:21:12 +02:00
committed by wojtekt
parent dcdeed97cd
commit 3f68000203
5 changed files with 63 additions and 16 deletions

View File

@@ -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)
}
}