Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wait for kubernetes components on soft start #8199

Merged
merged 4 commits into from
May 19, 2020
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 29 additions & 18 deletions test/integration/functional_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (

"github.com/google/go-cmp/cmp"

"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/localpath"
"k8s.io/minikube/pkg/util/retry"
Expand Down Expand Up @@ -293,27 +294,37 @@ func validateMinikubeKubectl(ctx context.Context, t *testing.T, profile string)
func validateComponentHealth(ctx context.Context, t *testing.T, profile string) {
defer PostMortemLogs(t, profile)

rr, err := Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "get", "cs", "-o=json"))
if err != nil {
t.Fatalf("failed to get components. args %q: %v", rr.Command(), err)
}
cs := api.ComponentStatusList{}
d := json.NewDecoder(bytes.NewReader(rr.Stdout.Bytes()))
if err := d.Decode(&cs); err != nil {
t.Fatalf("failed to decode kubectl json output: args %q : %v", rr.Command(), err)
}
f := func() (bool, error) {
rr, err := Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "get", "cs", "-o=json"))
if err != nil {
t.Logf("failed to get components. args %q: %v", rr.Command(), err)
return false, nil
}
cs := api.ComponentStatusList{}
d := json.NewDecoder(bytes.NewReader(rr.Stdout.Bytes()))
if err := d.Decode(&cs); err != nil {
t.Logf("failed to decode kubectl json output: args %q : %v", rr.Command(), err)
return false, nil
}

for _, i := range cs.Items {
status := api.ConditionFalse
for _, c := range i.Conditions {
if c.Type != api.ComponentHealthy {
continue
for _, i := range cs.Items {
status := api.ConditionFalse
for _, c := range i.Conditions {
if c.Type != api.ComponentHealthy {
continue
}
status = c.Status
}
if status != api.ConditionTrue {
t.Logf("unexpected status: %v - item: %+v", status, i)
return false, nil
}
status = c.Status
}
if status != api.ConditionTrue {
t.Errorf("unexpected status: %v - item: %+v", status, i)
}
return true, nil
}

if err := wait.PollImmediate(10*time.Second, 40*time.Second, f); err != nil {
t.Fatalf("error: %v", err)
}
}

Expand Down