提交 6e0aeda4 编写于 作者: M Medya Gh

change all time durations

上级 ef43e63e
......@@ -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}
......
......@@ -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()...)
......
......@@ -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.
......
......@@ -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...))
......
......@@ -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 {
......
......@@ -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" {
......
......@@ -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...)
......
......@@ -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()...)
......
......@@ -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"))
......
......@@ -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
}
......@@ -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()...)
......
......@@ -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...)
......
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册