final touch on parallel integration

pull/4948/head
Medya Gh 2019-08-01 16:42:29 -07:00
parent 4b03e68366
commit e6079dc358
11 changed files with 50 additions and 41 deletions

View File

@ -34,13 +34,13 @@ import (
"k8s.io/minikube/test/integration/util"
)
// Note this test runs before all because filename is alpahbetically first
// Note this test runs before all because filename is alphabetically first
// is used to cache images and binaries used by other parallel tests to avoid redownloading.
// TestDownloadOnly tests the --download-only option
func TestDownloadOnly(t *testing.T) {
p := profileName(t)
mk := NewMinikubeRunner(t, p)
if !isTestNoneDriver() { // none driver doesnt need to be deleted
if !isTestNoneDriver(t) { // none driver doesnt need to be deleted
defer mk.TearDown(t)
}
@ -61,7 +61,7 @@ func TestDownloadOnly(t *testing.T) {
t.Run("DownloadLatestRelease", func(t *testing.T) {
dest := filepath.Join(*testdataDir, fmt.Sprintf("minikube-%s-%s-latest-stable", runtime.GOOS, runtime.GOARCH))
err := downloadMinikubeBinary(dest, "latest")
err := downloadMinikubeBinary(t, dest, "latest")
if err != nil {
t.Errorf("erorr downloading the latest minikube release %v", err)
}
@ -70,7 +70,8 @@ func TestDownloadOnly(t *testing.T) {
// downloadMinikubeBinary downloads the minikube binary from github used by TestVersionUpgrade
// acts as a test setup for TestVersionUpgrade
func downloadMinikubeBinary(dest string, version string) error {
func downloadMinikubeBinary(t *testing.T, dest string, version string) error {
t.Helper()
// Grab latest release binary
url := pkgutil.GetBinaryDownloadURL(version, runtime.GOOS)
download := func() error {

View File

@ -30,10 +30,10 @@ import (
)
func TestContainerd(t *testing.T) {
if isTestNoneDriver() {
if isTestNoneDriver(t) {
t.Skip("Can't run containerd backend with none driver")
}
if toParallel() {
if shouldRunInParallel(t) {
t.Parallel()
}
@ -42,7 +42,7 @@ func TestContainerd(t *testing.T) {
func testGvisorRestart(t *testing.T) {
p := profileName(t)
if toParallel() {
if shouldRunInParallel(t) {
t.Parallel()
}
mk := NewMinikubeRunner(t, p, "--wait=false")
@ -57,13 +57,13 @@ func testGvisorRestart(t *testing.T) {
t.Log("waiting for gvisor controller to come up")
if err := waitForGvisorControllerRunning(p); err != nil {
t.Fatalf("waiting for gvisor controller to be up: %v", err)
t.Errorf("waiting for gvisor controller to be up: %v", err)
}
createUntrustedWorkload(t, p)
t.Log("making sure untrusted workload is Running")
if err := waitForUntrustedNginxRunning(p); err != nil {
t.Fatalf("waiting for nginx to be up: %v", err)
t.Errorf("waiting for nginx to be up: %v", err)
}
deleteUntrustedWorkload(t, p)
@ -76,13 +76,13 @@ func testGvisorRestart(t *testing.T) {
t.Log("waiting for gvisor controller to come up")
if err := waitForGvisorControllerRunning(p); err != nil {
t.Fatalf("waiting for gvisor controller to be up: %v", err)
t.Errorf("waiting for gvisor controller to be up: %v", err)
}
createUntrustedWorkload(t, p)
t.Log("making sure untrusted workload is Running")
if err := waitForUntrustedNginxRunning(p); err != nil {
t.Fatalf("waiting for nginx to be up: %v", err)
t.Errorf("waiting for nginx to be up: %v", err)
}
deleteUntrustedWorkload(t, p)
}

View File

@ -28,11 +28,11 @@ import (
)
func TestDocker(t *testing.T) {
if isTestNoneDriver() {
if isTestNoneDriver(t) {
t.Skip("skipping test as none driver does not bundle docker")
}
p := profileName(t)
if toParallel() {
if shouldRunInParallel(t) {
t.Parallel()
}
mk := NewMinikubeRunner(t, p, "--wait=false")

View File

@ -38,7 +38,7 @@ var globalArgs = flag.String("minikube-args", "", "Arguments to pass to minikube
var startArgs = flag.String("minikube-start-args", "", "Arguments to pass to minikube start")
var mountArgs = flag.String("minikube-mount-args", "", "Arguments to pass to minikube mount")
var testdataDir = flag.String("testdata-dir", "testdata", "the directory relative to test/integration where the testdata lives")
var disableParallel = flag.Bool("disable-parallel", false, "run the tests squentially and disable all parallel runs")
var parallel = flag.Bool("parallel", true, "run the tests in parallel, set false for run sequentially")
// NewMinikubeRunner creates a new MinikubeRunner
func NewMinikubeRunner(t *testing.T, profile string, extraStartArgs ...string) util.MinikubeRunner {
@ -54,33 +54,34 @@ func NewMinikubeRunner(t *testing.T, profile string, extraStartArgs ...string) u
}
// isTestNoneDriver checks if the current test is for none driver
func isTestNoneDriver() bool {
func isTestNoneDriver(t *testing.T) bool {
t.Helper()
return strings.Contains(*startArgs, "--vm-driver=none")
}
// profileName chooses a profile name based on the test name
// to be used in minikube and kubecontext across that test
func profileName(t *testing.T) string {
if isTestNoneDriver() {
t.Helper()
if isTestNoneDriver(t) {
return "minikube"
}
p := t.Name()
if strings.Contains(p, "/") { // for i.e, TestFunctional/SSH returns TestFunctional
p = strings.Split(p, "/")[0]
}
p := strings.Split(t.Name(), "/")[0] // for i.e, TestFunctional/SSH returns TestFunctional
if p == "TestFunctional" {
return "minikube"
}
return p
}
// toParallel deterimines if test should run in parallel or not
func toParallel() bool {
if *disableParallel {
// shouldRunInParallel deterimines if test should run in parallel or not
func shouldRunInParallel(t *testing.T) bool {
t.Helper()
if !*parallel {
return false
}
if isTestNoneDriver() {
if isTestNoneDriver(t) {
return false
}
return true
p := strings.Split(t.Name(), "/")[0] // for i.e, TestFunctional/SSH returns TestFunctional
return p != "TestFunctional" // gosimple lint: https://staticcheck.io/docs/checks#S1008
}

View File

@ -37,7 +37,7 @@ func testMounting(t *testing.T) {
if runtime.GOOS == "darwin" {
t.Skip("mount tests disabled in darwin due to timeout (issue#3200)")
}
if isTestNoneDriver() {
if isTestNoneDriver(t) {
t.Skip("skipping test for none driver as it does not need mount")
}

View File

@ -29,7 +29,7 @@ func TestFunctional(t *testing.T) {
if err != nil {
t.Fatalf("failed to start minikube failed : %v\nstdout: %s\nstderr: %s", err, stdout, stderr)
}
if !isTestNoneDriver() { // none driver doesn't need to be deleted
if !isTestNoneDriver(t) { // none driver doesn't need to be deleted
defer mk.TearDown(t)
}
@ -49,7 +49,7 @@ func TestFunctional(t *testing.T) {
t.Run("Provisioning", testProvisioning)
t.Run("Tunnel", testTunnel)
if !isTestNoneDriver() {
if !isTestNoneDriver(t) {
t.Run("EnvVars", testClusterEnv)
t.Run("SSH", testClusterSSH)
t.Run("IngressController", testIngressController)

View File

@ -26,7 +26,7 @@ import (
func TestISO(t *testing.T) {
p := profileName(t)
if toParallel() {
if shouldRunInParallel(t) {
t.Parallel()
}
@ -36,7 +36,7 @@ func TestISO(t *testing.T) {
if err != nil {
t.Fatalf("failed to start minikube (for profile %s) %s) failed : %v\nstdout: %s\nstderr: %s", t.Name(), err, stdout, stderr)
}
if !isTestNoneDriver() { // none driver doesn't need to be deleted
if !isTestNoneDriver(t) { // none driver doesn't need to be deleted
defer mk.TearDown(t)
}

View File

@ -27,11 +27,11 @@ import (
)
func TestPersistence(t *testing.T) {
if isTestNoneDriver() {
if isTestNoneDriver(t) {
t.Skip("skipping test as none driver does not support persistence")
}
p := profileName(t)
if toParallel() {
if shouldRunInParallel(t) {
t.Parallel()
}

View File

@ -32,12 +32,12 @@ import (
func TestStartStop(t *testing.T) {
p := profileName(t) // gets profile name used for minikube and kube context
if toParallel() {
if shouldRunInParallel(t) {
t.Parallel()
}
t.Run("group", func(t *testing.T) {
if toParallel() {
if shouldRunInParallel(t) {
t.Parallel()
}
tests := []struct {
@ -75,14 +75,14 @@ func TestStartStop(t *testing.T) {
for _, tc := range tests {
n := tc.name // because similar to https://golang.org/doc/faq#closures_and_goroutines
t.Run(tc.name, func(t *testing.T) {
if toParallel() {
if shouldRunInParallel(t) {
t.Parallel()
}
pn := p + n // TestStartStopoldest
mk := NewMinikubeRunner(t, pn, "--wait=false")
// TODO : redundant first clause ? never happens?
if !strings.Contains(pn, "docker") && isTestNoneDriver() {
if !strings.Contains(pn, "docker") && isTestNoneDriver(t) {
t.Skipf("skipping %s - incompatible with none driver", t.Name())
}

View File

@ -54,14 +54,19 @@ func fileExists(fname string) error {
// and it tries to upgrade from the older supported k8s to news supported k8s
func TestVersionUpgrade(t *testing.T) {
p := profileName(t)
if toParallel() {
if shouldRunInParallel(t) {
t.Parallel()
}
// fname is the filename for the minikube's latetest binary. this file been pre-downloaded before test by hacks/jenkins/common.sh
fname := filepath.Join(*testdataDir, fmt.Sprintf("minikube-%s-%s-latest-stable", runtime.GOOS, runtime.GOARCH))
err := fileExists(fname)
if err != nil {
t.Fail()
if err != nil { // download file if it is not downloaded by other test
dest := filepath.Join(*testdataDir, fmt.Sprintf("minikube-%s-%s-latest-stable", runtime.GOOS, runtime.GOARCH))
err := downloadMinikubeBinary(t, dest, "latest")
if err != nil {
// binary is needed for the test
t.Fatalf("erorr downloading the latest minikube release %v", err)
}
}
defer os.Remove(fname)

View File

@ -17,6 +17,8 @@ limitations under the License.
*/
// the name of this file starts with z intentionally to make it run last after all other tests
// the intent is to make sure os env proxy settings be done after all other tests.
// for example in the case the test proxy clean up gets killed or fails
package integration
import (
@ -69,7 +71,7 @@ func TestProxy(t *testing.T) {
origNP := os.Getenv("NO_PROXY")
p := profileName(t) // profile name
if isTestNoneDriver() {
if isTestNoneDriver(t) {
// TODO fix this later
t.Skip("Skipping proxy warning for none")
}
@ -96,7 +98,7 @@ func TestProxy(t *testing.T) {
if err != nil {
t.Errorf("Error shutting down the http proxy")
}
if !isTestNoneDriver() {
if !isTestNoneDriver(t) {
mk.TearDown(t)
}