提交 fff8f5cb 编写于 作者: T Thomas Stromberg

Offset integration tests which start clusters by 5s

上级 062c4727
......@@ -36,7 +36,7 @@ import (
// TestAddons tests addons that require no special environment -- in parallel
func TestAddons(t *testing.T) {
MaybeParallel(t)
MaybeSlowParallel(t)
profile := UniqueProfileName("addons")
ctx, cancel := context.WithTimeout(context.Background(), 40*time.Minute)
......
......@@ -30,7 +30,7 @@ func TestDockerFlags(t *testing.T) {
if NoneDriver() {
t.Skip("skipping: none driver does not support ssh or bundle docker")
}
MaybeParallel(t)
MaybeSlowParallel(t)
profile := UniqueProfileName("docker-flags")
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Minute)
......
......@@ -27,7 +27,7 @@ import (
)
func TestGuestEnvironment(t *testing.T) {
MaybeParallel(t)
MaybeSlowParallel(t)
profile := UniqueProfileName("guest")
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Minute)
defer CleanupWithLogs(t, profile, cancel)
......
......@@ -33,7 +33,7 @@ func TestGvisorAddon(t *testing.T) {
if NoneDriver() {
t.Skip("Can't run containerd backend with none driver")
}
MaybeParallel(t)
MaybeSlowParallel(t)
profile := UniqueProfileName("gvisor")
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Minute)
......
......@@ -30,6 +30,7 @@ import (
"io/ioutil"
"os/exec"
"strings"
"sync"
"testing"
"time"
......@@ -40,6 +41,11 @@ import (
"k8s.io/minikube/pkg/kapi"
)
var (
antiRaceCounter = 0
antiRaceMutex = &sync.Mutex{}
)
// RunResult stores the result of an cmd.Run call
type RunResult struct {
Stdout *bytes.Buffer
......@@ -62,6 +68,7 @@ func (rr RunResult) Command() string {
return sb.String()
}
// Output returns human-readable output for an execution result
func (rr RunResult) Output() string {
var sb strings.Builder
if rr.Stdout.Len() > 0 {
......@@ -324,6 +331,27 @@ func MaybeParallel(t *testing.T) {
t.Parallel()
}
// MaybeSlowParallel is a terrible workaround for tests which start clusters in a race-filled world
// TODO: Try removing this hack once certificates are deployed per-profile
func MaybeSlowParallel(t *testing.T) {
// NoneDriver shouldn't parallelize "minikube start"
if NoneDriver() {
return
}
antiRaceMutex.Lock()
antiRaceCounter++
antiRaceMutex.Unlock()
if antiRaceCounter > 0 {
// Slow enough to offset start, but not slow to be a major source of delay
penalty := time.Duration(5*antiRaceCounter) * time.Second
t.Logf("MaybeSlowParallel: Sleeping %s to avoid start race ...", penalty)
time.Sleep(penalty)
}
t.Parallel()
}
// killProcessFamily kills a pid and all of its children
func killProcessFamily(t *testing.T, pid int) {
parent, err := process.NewProcess(int32(pid))
......
......@@ -74,7 +74,7 @@ func TestStartStop(t *testing.T) {
for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
MaybeParallel(t)
MaybeSlowParallel(t)
if !strings.Contains(tc.name, "docker") && NoneDriver() {
t.Skipf("skipping %s - incompatible with none driver", t.Name())
......
......@@ -41,7 +41,7 @@ import (
func TestVersionUpgrade(t *testing.T) {
profile := UniqueProfileName("vupgrade")
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Minute)
MaybeParallel(t)
MaybeSlowParallel(t)
defer CleanupWithLogs(t, profile, cancel)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册