decouple isNoneDriver from minikube driver for more reusability

pull/4946/head
Medya Gh 2019-07-26 15:27:05 -07:00
parent 25bc27e170
commit e3db9a41ba
10 changed files with 95 additions and 42 deletions

View File

@ -74,7 +74,6 @@ gsutil -qm cp \
"gs://minikube-builds/${MINIKUBE_LOCATION}/e2e-${OS_ARCH}" out
gsutil -qm cp "gs://minikube-builds/${MINIKUBE_LOCATION}/testdata"/* testdata/
gsutil -qm cp "gs://minikube-builds/${MINIKUBE_LOCATION}/testdata"/* testdata/
# to be used by TestVersionUpgrade
gsutil -qm cp gs://minikube/releases/latest/minikube-${OS_ARCH} testdata/minikube-${OS_ARCH}-latest-stable

View File

@ -0,0 +1,47 @@
// +build integration
/*
Copyright 2016 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package integration
import (
"testing"
"github.com/docker/machine/libmachine/state"
)
func TestContainerd(t *testing.T) {
p := t.Name()
if isTestNoneDriver() {
p = "minikube"
} else {
t.Parallel()
}
mk := NewMinikubeRunner(t, p)
if isTestNoneDriver() {
t.Skip("Can't run containerd backend with none driver")
}
if mk.GetStatus() != state.None.String() {
mk.RunCommand("delete", true)
}
mk.Start("--container-runtime=containerd", "--docker-opt containerd=/var/run/containerd/containerd.sock")
t.Run("Gvisor", testGvisor)
t.Run("GvisorRestart", testGvisorRestart)
mk.RunCommand("delete", true)
}

View File

@ -27,10 +27,14 @@ import (
)
func TestDocker(t *testing.T) {
t.Parallel()
p := t.Name()
if isTestNoneDriver() {
p = "minikube"
} else {
t.Parallel()
}
mk := NewMinikubeRunner(t, p, "--wait=false")
if usingNoneDriver(mk) {
if isTestNoneDriver() {
t.Skip("skipping test as none driver does not bundle docker")
}

View File

@ -48,3 +48,8 @@ func NewMinikubeRunner(t *testing.T, profile string, extraArgs ...string) util.M
T: t,
}
}
// isTestNoneDriver checks if the current test is for none driver
func isTestNoneDriver() bool {
return strings.Contains(*startArgs, "--vm-driver=none")
}

View File

@ -19,20 +19,18 @@ limitations under the License.
package integration
import (
"strings"
"testing"
"github.com/docker/machine/libmachine/state"
"k8s.io/minikube/test/integration/util"
)
func TestFunctional(t *testing.T) {
p := "minikube"
mk := NewMinikubeRunner(t, p)
if !usingNoneDriver(mk) {
p := "minikube" // for functional test we use default profile name
if isTestNoneDriver() {
p = "minikube"
} else {
t.Parallel()
}
mk := NewMinikubeRunner(t, p)
mk.EnsureRunning()
// This one is not parallel, and ensures the cluster comes up
// before we run any other tests.
@ -47,32 +45,10 @@ func TestFunctional(t *testing.T) {
t.Run("Provisioning", testProvisioning)
t.Run("Tunnel", testTunnel)
if !usingNoneDriver(mk) {
if !isTestNoneDriver() {
t.Run("EnvVars", testClusterEnv)
t.Run("SSH", testClusterSSH)
t.Run("IngressController", testIngressController)
t.Run("Mounting", testMounting)
}
}
func TestFunctionalContainerd(t *testing.T) {
p := "minikube"
mk := NewMinikubeRunner(t, p)
if usingNoneDriver(mk) {
t.Skip("Can't run containerd backend with none driver")
}
if mk.GetStatus() != state.None.String() {
mk.RunCommand("delete", true)
}
mk.Start("--container-runtime=containerd", "--docker-opt containerd=/var/run/containerd/containerd.sock")
t.Run("Gvisor", testGvisor)
t.Run("GvisorRestart", testGvisorRestart)
mk.RunCommand("delete", true)
}
// usingNoneDriver returns true if using the none driver
func usingNoneDriver(r util.MinikubeRunner) bool {
return strings.Contains(r.StartArgs, "--vm-driver=none")
}

View File

@ -26,11 +26,13 @@ import (
func TestISO(t *testing.T) {
p := t.Name()
if !usingNoneDriver(mk) {
if isTestNoneDriver() {
p = "minikube"
} else {
t.Parallel()
}
mk := NewMinikubeRunner(t, p, "--wait=false")
mk := NewMinikubeRunner(t, p, "--wait=false")
mk.RunCommand("delete", false)
mk.Start()

View File

@ -30,8 +30,13 @@ import (
func TestPersistence(t *testing.T) {
p := t.Name() // profile name
if isTestNoneDriver() {
p = "minikube"
} else {
t.Parallel()
}
mk := NewMinikubeRunner(t, p, "--wait=false")
if usingNoneDriver(mk) {
if isTestNoneDriver() {
t.Skip("skipping test as none driver does not support persistence")
}
mk.EnsureRunning()

View File

@ -135,6 +135,11 @@ func testProxyWarning(t *testing.T) {
// testProxyDashboard checks if dashboard URL is accessible if proxy is set
func testProxyDashboard(t *testing.T) {
p := "TestProxy" // profile name
if isTestNoneDriver() {
p = "minikube"
} else {
t.Parallel()
}
mk := NewMinikubeRunner(t, p)
cmd, out := mk.RunDaemon("dashboard --url")
defer func() {

View File

@ -32,7 +32,11 @@ import (
func TestStartStop(t *testing.T) {
p := "TestStartStop" // profile name
t.Parallel()
if isTestNoneDriver() {
p = "minikube"
} else {
t.Parallel()
}
tests := []struct {
name string
@ -68,8 +72,9 @@ func TestStartStop(t *testing.T) {
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
mk := NewMinikubeRunner(t, p+tc.name)
if !strings.Contains(tc.name, "docker") && usingNoneDriver(mk) {
mk := NewMinikubeRunner(t, p)
// TODO : check does this ever happen ?
if !strings.Contains(tc.name, "docker") && isTestNoneDriver() {
t.Skipf("skipping %s - incompatible with none driver", tc.name)
}
@ -101,7 +106,7 @@ func TestStartStop(t *testing.T) {
return mk.CheckStatusNoFail(state.Stopped.String())
}
if err := util.Retry(t, checkStop, 5*time.Second, 6); err != nil {
if err := util.Retry(t, checkStop, 10*time.Second, 3); err != nil {
t.Fatalf("timed out while checking stopped status: %v", err)
}

View File

@ -73,7 +73,12 @@ 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 := t.Name()
// this gets downloaded by common.sh in the CI
if isTestNoneDriver() {
p = "minikube"
} else {
t.Parallel()
}
// 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 {
@ -81,7 +86,7 @@ func TestVersionUpgrade(t *testing.T) {
}
mkCurrent := NewMinikubeRunner(t, p)
if usingNoneDriver(mkCurrent) { // TODO (medyagh@): bring back once soled https://github.com/kubernetes/minikube/issues/4418
if isTestNoneDriver() { // TODO (medyagh@): bring back once solved https://github.com/kubernetes/minikube/issues/4418
t.Skip("skipping test as none driver does not support persistence")
}
mkCurrent.RunCommand("delete", true)