Offset integration tests which start clusters by 5s
parent
062c472737
commit
fff8f5cbec
|
@ -36,7 +36,7 @@ import (
|
||||||
|
|
||||||
// TestAddons tests addons that require no special environment -- in parallel
|
// TestAddons tests addons that require no special environment -- in parallel
|
||||||
func TestAddons(t *testing.T) {
|
func TestAddons(t *testing.T) {
|
||||||
MaybeParallel(t)
|
MaybeSlowParallel(t)
|
||||||
|
|
||||||
profile := UniqueProfileName("addons")
|
profile := UniqueProfileName("addons")
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 40*time.Minute)
|
ctx, cancel := context.WithTimeout(context.Background(), 40*time.Minute)
|
||||||
|
|
|
@ -30,7 +30,7 @@ func TestDockerFlags(t *testing.T) {
|
||||||
if NoneDriver() {
|
if NoneDriver() {
|
||||||
t.Skip("skipping: none driver does not support ssh or bundle docker")
|
t.Skip("skipping: none driver does not support ssh or bundle docker")
|
||||||
}
|
}
|
||||||
MaybeParallel(t)
|
MaybeSlowParallel(t)
|
||||||
|
|
||||||
profile := UniqueProfileName("docker-flags")
|
profile := UniqueProfileName("docker-flags")
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Minute)
|
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Minute)
|
||||||
|
|
|
@ -27,7 +27,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestGuestEnvironment(t *testing.T) {
|
func TestGuestEnvironment(t *testing.T) {
|
||||||
MaybeParallel(t)
|
MaybeSlowParallel(t)
|
||||||
profile := UniqueProfileName("guest")
|
profile := UniqueProfileName("guest")
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Minute)
|
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Minute)
|
||||||
defer CleanupWithLogs(t, profile, cancel)
|
defer CleanupWithLogs(t, profile, cancel)
|
||||||
|
|
|
@ -33,7 +33,7 @@ func TestGvisorAddon(t *testing.T) {
|
||||||
if NoneDriver() {
|
if NoneDriver() {
|
||||||
t.Skip("Can't run containerd backend with none driver")
|
t.Skip("Can't run containerd backend with none driver")
|
||||||
}
|
}
|
||||||
MaybeParallel(t)
|
MaybeSlowParallel(t)
|
||||||
|
|
||||||
profile := UniqueProfileName("gvisor")
|
profile := UniqueProfileName("gvisor")
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Minute)
|
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Minute)
|
||||||
|
|
|
@ -30,6 +30,7 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -40,6 +41,11 @@ import (
|
||||||
"k8s.io/minikube/pkg/kapi"
|
"k8s.io/minikube/pkg/kapi"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
antiRaceCounter = 0
|
||||||
|
antiRaceMutex = &sync.Mutex{}
|
||||||
|
)
|
||||||
|
|
||||||
// RunResult stores the result of an cmd.Run call
|
// RunResult stores the result of an cmd.Run call
|
||||||
type RunResult struct {
|
type RunResult struct {
|
||||||
Stdout *bytes.Buffer
|
Stdout *bytes.Buffer
|
||||||
|
@ -62,6 +68,7 @@ func (rr RunResult) Command() string {
|
||||||
return sb.String()
|
return sb.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Output returns human-readable output for an execution result
|
||||||
func (rr RunResult) Output() string {
|
func (rr RunResult) Output() string {
|
||||||
var sb strings.Builder
|
var sb strings.Builder
|
||||||
if rr.Stdout.Len() > 0 {
|
if rr.Stdout.Len() > 0 {
|
||||||
|
@ -324,6 +331,27 @@ func MaybeParallel(t *testing.T) {
|
||||||
t.Parallel()
|
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
|
// killProcessFamily kills a pid and all of its children
|
||||||
func killProcessFamily(t *testing.T, pid int) {
|
func killProcessFamily(t *testing.T, pid int) {
|
||||||
parent, err := process.NewProcess(int32(pid))
|
parent, err := process.NewProcess(int32(pid))
|
||||||
|
|
|
@ -74,7 +74,7 @@ func TestStartStop(t *testing.T) {
|
||||||
for _, tc := range tests {
|
for _, tc := range tests {
|
||||||
tc := tc
|
tc := tc
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
MaybeParallel(t)
|
MaybeSlowParallel(t)
|
||||||
|
|
||||||
if !strings.Contains(tc.name, "docker") && NoneDriver() {
|
if !strings.Contains(tc.name, "docker") && NoneDriver() {
|
||||||
t.Skipf("skipping %s - incompatible with none driver", t.Name())
|
t.Skipf("skipping %s - incompatible with none driver", t.Name())
|
||||||
|
|
|
@ -41,7 +41,7 @@ import (
|
||||||
func TestVersionUpgrade(t *testing.T) {
|
func TestVersionUpgrade(t *testing.T) {
|
||||||
profile := UniqueProfileName("vupgrade")
|
profile := UniqueProfileName("vupgrade")
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Minute)
|
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Minute)
|
||||||
MaybeParallel(t)
|
MaybeSlowParallel(t)
|
||||||
|
|
||||||
defer CleanupWithLogs(t, profile, cancel)
|
defer CleanupWithLogs(t, profile, cancel)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue