Wait a few seconds for the cluster to become healthly.
parent
3fb62577ce
commit
94aca79782
|
@ -63,11 +63,16 @@ func CanReadFile(path string) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func Retry(attempts int, callback func() error) (err error) {
|
func Retry(attempts int, callback func() error) (err error) {
|
||||||
|
return RetryAfter(attempts, callback, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func RetryAfter(attempts int, callback func() error, d time.Duration) (err error) {
|
||||||
for i := 0; i < attempts; i++ {
|
for i := 0; i < attempts; i++ {
|
||||||
err = callback()
|
err = callback()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
time.Sleep(d)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,8 +21,10 @@ package integration
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
|
commonutil "k8s.io/minikube/pkg/util"
|
||||||
"k8s.io/minikube/test/integration/util"
|
"k8s.io/minikube/test/integration/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -33,19 +35,26 @@ func TestClusterStatus(t *testing.T) {
|
||||||
|
|
||||||
kubectlRunner := util.NewKubectlRunner(t)
|
kubectlRunner := util.NewKubectlRunner(t)
|
||||||
cs := api.ComponentStatusList{}
|
cs := api.ComponentStatusList{}
|
||||||
kubectlRunner.RunCommand([]string{"get", "cs"}, &cs)
|
|
||||||
|
|
||||||
for _, i := range cs.Items {
|
healthy := func() error {
|
||||||
status := api.ConditionFalse
|
kubectlRunner.RunCommand([]string{"get", "cs"}, &cs)
|
||||||
for _, c := range i.Conditions {
|
for _, i := range cs.Items {
|
||||||
if c.Type != api.ComponentHealthy {
|
status := api.ConditionFalse
|
||||||
continue
|
for _, c := range i.Conditions {
|
||||||
|
if c.Type != api.ComponentHealthy {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
fmt.Printf("Component: %s, Healthy: %s.\n", i.GetName(), c.Status)
|
||||||
|
status = c.Status
|
||||||
|
}
|
||||||
|
if status != api.ConditionTrue {
|
||||||
|
return fmt.Errorf("Component %s is not Healthy! Status: %s", i.GetName(), status)
|
||||||
}
|
}
|
||||||
fmt.Printf("Component: %s, Healthy: %s.\n", i.GetName(), c.Status)
|
|
||||||
status = c.Status
|
|
||||||
}
|
|
||||||
if status != api.ConditionTrue {
|
|
||||||
t.Fatalf("Component %s is not Healthy! Status: %s", i.GetName(), status)
|
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := commonutil.RetryAfter(4, healthy, 1*time.Second); err != nil {
|
||||||
|
t.Fatalf("Cluster is not healthy: %s", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue