diff --git a/test/integration/fn_mount_cmd.go b/test/integration/fn_mount_cmd.go index eedc9e7983c8..9bfc880134ba 100644 --- a/test/integration/fn_mount_cmd.go +++ b/test/integration/fn_mount_cmd.go @@ -106,7 +106,7 @@ func validateMountCmd(ctx context.Context, t *testing.T, profile string) { } start := time.Now() - if err := retry.Expo(checkMount, time.Second, 15*time.Second); err != nil { + if err := retry.Expo(checkMount, time.Second, Seconds(15)); err != nil { // For local testing, allow macOS users to click prompt. If they don't, skip the test. if runtime.GOOS == "darwin" { t.Skip("skipping: mount did not appear, likely because macOS requires prompt to allow non-codesigned binaries to listen on non-localhost port") diff --git a/test/integration/fn_pvc.go b/test/integration/fn_pvc.go index 4f97c830ef0d..0d1f7e5778a8 100644 --- a/test/integration/fn_pvc.go +++ b/test/integration/fn_pvc.go @@ -57,7 +57,7 @@ func validatePersistentVolumeClaim(ctx context.Context, t *testing.T, profile st } // Ensure the addon-manager has created the StorageClass before creating a claim, otherwise it won't be bound - if err := retry.Expo(checkStorageClass, time.Second, 90*time.Second); err != nil { + if err := retry.Expo(checkStorageClass, time.Second, Seconds(90)); err != nil { t.Errorf("no default storage class after retry: %v", err) } diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index 8445aa364a7b..a333d8c6b3d0 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -595,6 +595,20 @@ func validateProfileCmd(ctx context.Context, t *testing.T, profile string) { // validateServiceCmd asserts basic "service" command functionality func validateServiceCmd(ctx context.Context, t *testing.T, profile string) { + // to avoid https://github.com/kubernetes/minikube/issues/6997 + // adding this logic to minikube start is not necessary but useful for rare test flakes + saReady := func() error { // check if default service account is created. + if _, err := Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "get", "serviceaccount", "default")); err != nil { + t.Logf("temporary error waiting for default service account: %v", err) + return fmt.Errorf("Error waiting for default service account %v", err) + } + return nil + } + + if err := retry.Expo(saReady, 500*time.Microsecond, time.Second*30); err != nil { + t.Errorf("default service account was not created in 30 seconds.: %v", err) + } + rr, err := Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "create", "deployment", "hello-node", "--image=gcr.io/hello-minikube-zero-install/hello-node")) if err != nil { t.Logf("%s failed: %v (may not be an error)", rr.Args, err) @@ -710,6 +724,20 @@ func validateSSHCmd(ctx context.Context, t *testing.T, profile string) { // validateMySQL validates a minimalist MySQL deployment func validateMySQL(ctx context.Context, t *testing.T, profile string) { + // to avoid https://github.com/kubernetes/minikube/issues/6997 + // adding this logic to minikube start is not necessary but useful for rare test flakes + saReady := func() error { // check if default service account is created. + if _, err := Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "get", "serviceaccount", "default")); err != nil { + t.Logf("temporary error waiting for default service account: %v", err) + return fmt.Errorf("Error waiting for default service account %v", err) + } + return nil + } + + if err := retry.Expo(saReady, 500*time.Microsecond, time.Second*30); err != nil { + t.Errorf("default service account was not created in 30 seconds.: %v", err) + } + rr, err := Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "replace", "--force", "-f", filepath.Join(*testdataDir, "mysql.yaml"))) if err != nil { t.Fatalf("%s failed: %v", rr.Args, err) @@ -725,7 +753,7 @@ func validateMySQL(ctx context.Context, t *testing.T, profile string) { rr, err = Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "exec", names[0], "--", "mysql", "-ppassword", "-e", "show databases;")) return err } - if err = retry.Expo(mysql, 5*time.Second, 180*time.Second); err != nil { + if err = retry.Expo(mysql, 5*time.Second, Seconds(180)); err != nil { t.Errorf("mysql failing: %v", err) } } diff --git a/test/integration/start_stop_delete_test.go b/test/integration/start_stop_delete_test.go index a7b11c8f42e5..862d78843511 100644 --- a/test/integration/start_stop_delete_test.go +++ b/test/integration/start_stop_delete_test.go @@ -28,11 +28,13 @@ import ( "strconv" "strings" "testing" + "time" "github.com/docker/machine/libmachine/state" "github.com/google/go-cmp/cmp" "k8s.io/minikube/pkg/minikube/bootstrapper/images" "k8s.io/minikube/pkg/minikube/constants" + "k8s.io/minikube/pkg/util/retry" ) func TestStartStop(t *testing.T) { @@ -169,6 +171,19 @@ func TestStartStop(t *testing.T) { // testPodScheduling asserts that this configuration can schedule new pods func testPodScheduling(ctx context.Context, t *testing.T, profile string) { t.Helper() + // to avoid https://github.com/kubernetes/minikube/issues/6997 + // adding this logic to minikube start is not necessary but useful for rare test flakes + saReady := func() error { // check if default service account is created. + if _, err := Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "get", "serviceaccount", "default")); err != nil { + t.Logf("temporary error waiting for default service account: %v", err) + return fmt.Errorf("Error waiting for default service account %v", err) + } + return nil + } + + if err := retry.Expo(saReady, 500*time.Microsecond, time.Second*30); err != nil { + t.Errorf("default service account was not created in 30 seconds.: %v", err) + } // schedule a pod to assert persistence rr, err := Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "create", "-f", filepath.Join(*testdataDir, "busybox.yaml")))