From 6e0aeda4ea4baf9181b847b4cf2226dd2f99703e Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Thu, 20 Feb 2020 16:19:59 -0800 Subject: [PATCH] change all time durations --- test/integration/aab_offline_test.go | 2 +- test/integration/addons_test.go | 2 +- test/integration/docker_test.go | 2 +- test/integration/fn_mount_cmd.go | 2 +- test/integration/fn_pvc.go | 2 +- test/integration/fn_tunnel_cmd.go | 2 +- test/integration/functional_test.go | 12 ++++++------ test/integration/guest_env_test.go | 2 +- test/integration/gvisor_addon_test.go | 2 +- test/integration/main.go | 12 ++++++++++-- test/integration/none_test.go | 2 +- test/integration/start_stop_delete_test.go | 2 +- test/integration/version_upgrade_test.go | 2 +- 13 files changed, 27 insertions(+), 19 deletions(-) diff --git a/test/integration/aab_offline_test.go b/test/integration/aab_offline_test.go index a83d84b1b..a42287814 100644 --- a/test/integration/aab_offline_test.go +++ b/test/integration/aab_offline_test.go @@ -39,7 +39,7 @@ func TestOffline(t *testing.T) { } profile := UniqueProfileName(fmt.Sprintf("offline-%s", runtime)) - ctx, cancel := context.WithTimeout(context.Background(), 15*time.Minute) + ctx, cancel := context.WithTimeout(context.Background(), Minutes(15)) defer CleanupWithLogs(t, profile, cancel) startArgs := []string{"start", "-p", profile, "--alsologtostderr", "-v=1", "--wait=true", "--container-runtime", runtime} diff --git a/test/integration/addons_test.go b/test/integration/addons_test.go index 86e49d716..9c32710fb 100644 --- a/test/integration/addons_test.go +++ b/test/integration/addons_test.go @@ -37,7 +37,7 @@ import ( // TestAddons tests addons that require no special environment -- in parallel func TestAddons(t *testing.T) { profile := UniqueProfileName("addons") - ctx, cancel := context.WithTimeout(context.Background(), 40*time.Minute) + ctx, cancel := context.WithTimeout(context.Background(), Minutes(40)) defer CleanupWithLogs(t, profile, cancel) args := append([]string{"start", "-p", profile, "--wait=false", "--memory=2600", "--alsologtostderr", "-v=1", "--addons=ingress", "--addons=registry", "--addons=metrics-server"}, StartArgs()...) diff --git a/test/integration/docker_test.go b/test/integration/docker_test.go index e8c73df9c..143004e32 100644 --- a/test/integration/docker_test.go +++ b/test/integration/docker_test.go @@ -33,7 +33,7 @@ func TestDockerFlags(t *testing.T) { MaybeParallel(t) profile := UniqueProfileName("docker-flags") - ctx, cancel := context.WithTimeout(context.Background(), 30*time.Minute) + ctx, cancel := context.WithTimeout(context.Background(), Minutes(30)) defer CleanupWithLogs(t, profile, cancel) // Use the most verbose logging for the simplest test. If it fails, something is very wrong. diff --git a/test/integration/fn_mount_cmd.go b/test/integration/fn_mount_cmd.go index 7888971be..ed7f7747a 100644 --- a/test/integration/fn_mount_cmd.go +++ b/test/integration/fn_mount_cmd.go @@ -56,7 +56,7 @@ func validateMountCmd(ctx context.Context, t *testing.T, profile string) { t.Fatalf("Unexpected error while creating tempDir: %v", err) } - ctx, cancel := context.WithTimeout(ctx, 10*time.Minute) + ctx, cancel := context.WithTimeout(ctx, Minutes(10)) args := []string{"mount", "-p", profile, fmt.Sprintf("%s:%s", tempDir, guestMount), "--alsologtostderr", "-v=1"} ss, err := Start(t, exec.CommandContext(ctx, Target(), args...)) diff --git a/test/integration/fn_pvc.go b/test/integration/fn_pvc.go index 3110d4550..64a550eb6 100644 --- a/test/integration/fn_pvc.go +++ b/test/integration/fn_pvc.go @@ -34,7 +34,7 @@ import ( ) func validatePersistentVolumeClaim(ctx context.Context, t *testing.T, profile string) { - ctx, cancel := context.WithTimeout(ctx, 10*time.Minute) + ctx, cancel := context.WithTimeout(ctx, Minutes(10)) defer cancel() if _, err := PodWait(ctx, t, profile, "kube-system", "integration-test=storage-provisioner", 4*time.Minute); err != nil { diff --git a/test/integration/fn_tunnel_cmd.go b/test/integration/fn_tunnel_cmd.go index a080bc1b7..6e6b48d8d 100644 --- a/test/integration/fn_tunnel_cmd.go +++ b/test/integration/fn_tunnel_cmd.go @@ -38,7 +38,7 @@ import ( ) func validateTunnelCmd(ctx context.Context, t *testing.T, profile string) { - ctx, cancel := context.WithTimeout(ctx, 20*time.Minute) + ctx, cancel := context.WithTimeout(ctx, Minutes(20)) defer cancel() if runtime.GOOS != "windows" { diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index 1534abffd..758a4bc90 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -55,7 +55,7 @@ type validateFunc func(context.Context, *testing.T, string) func TestFunctional(t *testing.T) { profile := UniqueProfileName("functional") - ctx, cancel := context.WithTimeout(context.Background(), 40*time.Minute) + ctx, cancel := context.WithTimeout(context.Background(), Minutes(40)) defer func() { p := localSyncTestPath() if err := os.Remove(p); err != nil { @@ -125,7 +125,7 @@ func TestFunctional(t *testing.T) { // check functionality of minikube after evaling docker-env func validateDockerEnv(ctx context.Context, t *testing.T, profile string) { - mctx, cancel := context.WithTimeout(ctx, 13*time.Second) + mctx, cancel := context.WithTimeout(ctx, Seconds(13)) defer cancel() // we should be able to get minikube status with a bash which evaled docker-env c := exec.CommandContext(mctx, "/bin/bash", "-c", "eval $("+Target()+" -p "+profile+" docker-env) && "+Target()+" status -p "+profile) @@ -137,7 +137,7 @@ func validateDockerEnv(ctx context.Context, t *testing.T, profile string) { t.Fatalf("Expected status output to include 'Running' after eval docker-env but got \n%s", rr.Output()) } - mctx, cancel = context.WithTimeout(ctx, 13*time.Second) + mctx, cancel = context.WithTimeout(ctx, Seconds(13)) defer cancel() // do a eval $(minikube -p profile docker-env) and check if we are point to docker inside minikube c = exec.CommandContext(mctx, "/bin/bash", "-c", "eval $("+Target()+" -p "+profile+" docker-env) && docker images") @@ -294,7 +294,7 @@ func validateDashboardCmd(ctx context.Context, t *testing.T, profile string) { }() start := time.Now() - s, err := ReadLineWithTimeout(ss.Stdout, 300*time.Second) + s, err := ReadLineWithTimeout(ss.Stdout, Seconds(300)) if err != nil { if runtime.GOOS == "windows" { t.Skipf("failed to read url within %s: %v\noutput: %q\n", time.Since(start), err, s) @@ -351,7 +351,7 @@ func validateDNS(ctx context.Context, t *testing.T, profile string) { // validateDryRun asserts that the dry-run mode quickly exits with the right code func validateDryRun(ctx context.Context, t *testing.T, profile string) { // dry-run mode should always be able to finish quickly (<5s) - mctx, cancel := context.WithTimeout(ctx, 5*time.Second) + mctx, cancel := context.WithTimeout(ctx, Seconds(5)) defer cancel() // Too little memory! @@ -364,7 +364,7 @@ func validateDryRun(ctx context.Context, t *testing.T, profile string) { t.Errorf("dry-run(250MB) exit code = %d, wanted = %d: %v", rr.ExitCode, wantCode, err) } - dctx, cancel := context.WithTimeout(ctx, 5*time.Second) + dctx, cancel := context.WithTimeout(ctx, Seconds(5)) defer cancel() startArgs = append([]string{"start", "-p", profile, "--dry-run", "--alsologtostderr", "-v=1"}, StartArgs()...) c = exec.CommandContext(dctx, Target(), startArgs...) diff --git a/test/integration/guest_env_test.go b/test/integration/guest_env_test.go index 8f57ac0ab..245cc92f7 100644 --- a/test/integration/guest_env_test.go +++ b/test/integration/guest_env_test.go @@ -32,7 +32,7 @@ func TestGuestEnvironment(t *testing.T) { MaybeParallel(t) profile := UniqueProfileName("guest") - ctx, cancel := context.WithTimeout(context.Background(), 15*time.Minute) + ctx, cancel := context.WithTimeout(context.Background(), Minutes(15)) defer CleanupWithLogs(t, profile, cancel) args := append([]string{"start", "-p", profile, "--install-addons=false", "--wait=false"}, StartArgs()...) diff --git a/test/integration/gvisor_addon_test.go b/test/integration/gvisor_addon_test.go index cd8051e4e..cda9e25af 100644 --- a/test/integration/gvisor_addon_test.go +++ b/test/integration/gvisor_addon_test.go @@ -36,7 +36,7 @@ func TestGvisorAddon(t *testing.T) { MaybeParallel(t) profile := UniqueProfileName("gvisor") - ctx, cancel := context.WithTimeout(context.Background(), 60*time.Minute) + ctx, cancel := context.WithTimeout(context.Background(), Minutes(60)) defer func() { if t.Failed() { rr, err := Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "logs", "gvisor", "-n", "kube-system")) diff --git a/test/integration/main.go b/test/integration/main.go index e484bf473..fdef8e093 100644 --- a/test/integration/main.go +++ b/test/integration/main.go @@ -34,7 +34,7 @@ var forceProfile = flag.String("profile", "", "force tests to run against a part var cleanup = flag.Bool("cleanup", true, "cleanup failed test run") var enableGvisor = flag.Bool("gvisor", false, "run gvisor integration test (slow)") var postMortemLogs = flag.Bool("postmortem-logs", true, "show logs after a failed test run") -var slowMachine = flag.Bool("slow-machine", false, "wait longer for tests to finish") +var slowMachine = flag.Bool("slow-machine", false, "double the timeout for tests to finish") // Paths to files - normally set for CI var binaryPath = flag.String("binary", "../../out/minikube", "path to minikube binary") @@ -81,8 +81,16 @@ func CanCleanup() bool { // Minutes will return timeout in minutes based on how slow the machine is func Minutes(n int) time.Duration { - if *slowMachine { + if *slowMachine { // double time out for slow machines return time.Duration(2) * time.Duration(n) * time.Minute } return time.Duration(n) * time.Minute } + +// Seconds will return timeout in minutes based on how slow the machine is +func Seconds(n int) time.Duration { + if *slowMachine { // double time out for slow machines + return time.Duration(3) * time.Duration(n) * time.Second + } + return time.Duration(n) * time.Second +} diff --git a/test/integration/none_test.go b/test/integration/none_test.go index 30c050c57..212cd0b60 100644 --- a/test/integration/none_test.go +++ b/test/integration/none_test.go @@ -41,7 +41,7 @@ func TestChangeNoneUser(t *testing.T) { MaybeParallel(t) profile := UniqueProfileName("none") - ctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute) + ctx, cancel := context.WithTimeout(context.Background(), Minutes(10)) defer CleanupWithLogs(t, profile, cancel) startArgs := append([]string{"CHANGE_MINIKUBE_NONE_USER=true", Target(), "start", "--wait=false"}, StartArgs()...) diff --git a/test/integration/start_stop_delete_test.go b/test/integration/start_stop_delete_test.go index 03fe3caa7..cde9f956a 100644 --- a/test/integration/start_stop_delete_test.go +++ b/test/integration/start_stop_delete_test.go @@ -84,7 +84,7 @@ func TestStartStop(t *testing.T) { } profile := UniqueProfileName(tc.name) - ctx, cancel := context.WithTimeout(context.Background(), 40*time.Minute) + ctx, cancel := context.WithTimeout(context.Background(), Minutes(40)) defer CleanupWithLogs(t, profile, cancel) startArgs := append([]string{"start", "-p", profile, "--alsologtostderr", "-v=3", "--wait=true"}, tc.args...) diff --git a/test/integration/version_upgrade_test.go b/test/integration/version_upgrade_test.go index 5c025309e..994dd9246 100644 --- a/test/integration/version_upgrade_test.go +++ b/test/integration/version_upgrade_test.go @@ -43,7 +43,7 @@ import ( func TestVersionUpgrade(t *testing.T) { MaybeParallel(t) profile := UniqueProfileName("vupgrade") - ctx, cancel := context.WithTimeout(context.Background(), 55*time.Minute) + ctx, cancel := context.WithTimeout(context.Background(), Minutes(55)) defer CleanupWithLogs(t, profile, cancel) -- GitLab