Merge pull request #891 from dlorenc/subtest

Move some integration tests to the subtest framework, and run them in…
pull/895/head
dlorenc 2016-12-06 12:15:18 -08:00 committed by GitHub
commit bf563b7adc
8 changed files with 79 additions and 43 deletions

View File

@ -38,13 +38,8 @@ var (
dashboardSvcCmd = []string{"get", "svc", "kubernetes-dashboard", "--namespace=kube-system"}
)
func TestAddons(t *testing.T) {
minikubeRunner := util.MinikubeRunner{
BinaryPath: *binaryPath,
Args: *args,
T: t}
minikubeRunner.EnsureRunning()
func testAddons(t *testing.T) {
t.Parallel()
kubectlRunner := util.NewKubectlRunner(t)
checkAddon := func() error {
@ -70,23 +65,23 @@ func TestAddons(t *testing.T) {
}
}
func TestDashboard(t *testing.T) {
func testDashboard(t *testing.T) {
t.Parallel()
kubectlRunner := util.NewKubectlRunner(t)
minikubeRunner := util.MinikubeRunner{
BinaryPath: *binaryPath,
Args: *args,
T: t}
minikubeRunner.EnsureRunning()
kubectlRunner := util.NewKubectlRunner(t)
checkDashboard := func() error {
rc := api.ReplicationController{}
svc := api.Service{}
if err := kubectlRunner.RunCommandParseOutput(dashboardRcCmd, &rc); err != nil {
return err
return &commonutil.RetriableError{Err: err}
}
if err := kubectlRunner.RunCommandParseOutput(dashboardSvcCmd, &svc); err != nil {
return err
return &commonutil.RetriableError{Err: err}
}
if rc.Status.Replicas != rc.Status.FullyLabeledReplicas {
@ -100,7 +95,7 @@ func TestDashboard(t *testing.T) {
return nil
}
if err := commonutil.RetryAfter(10, checkDashboard, 5*time.Second); err != nil {
if err := commonutil.RetryAfter(60, checkDashboard, 5*time.Second); err != nil {
t.Fatalf("Dashboard is unhealthy: %s", err)
}
@ -121,17 +116,23 @@ func TestDashboard(t *testing.T) {
}
}
func TestServicesList(t *testing.T) {
func testServicesList(t *testing.T) {
t.Parallel()
minikubeRunner := util.MinikubeRunner{
BinaryPath: *binaryPath,
Args: *args,
T: t}
minikubeRunner.EnsureRunning()
output := minikubeRunner.RunCommand("service list", true)
for _, svc := range []string{"kubernetes", "kube-dns", "kubernetes-dashboard"} {
if !strings.Contains(output, svc) {
t.Errorf("Error, service %s missing from output %s", svc, output)
checkServices := func() error {
output := minikubeRunner.RunCommand("service list", false)
if !strings.Contains(output, "kubernetes") {
return &commonutil.RetriableError{
Err: fmt.Errorf("Error, kubernetes service missing from output %s", output),
}
}
return nil
}
if err := commonutil.RetryAfter(5, checkServices, 2*time.Second); err != nil {
t.Fatalf(err.Error())
}
}

View File

@ -30,13 +30,8 @@ import (
"k8s.io/minikube/test/integration/util"
)
func TestClusterDNS(t *testing.T) {
minikubeRunner := util.MinikubeRunner{
BinaryPath: *binaryPath,
Args: *args,
T: t}
minikubeRunner.EnsureRunning()
func testClusterDNS(t *testing.T) {
t.Parallel()
kubectlRunner := util.NewKubectlRunner(t)
podName := "busybox"
podPath, _ := filepath.Abs("testdata/busybox.yaml")
@ -68,7 +63,7 @@ func TestClusterDNS(t *testing.T) {
return nil
}
if err := commonutil.RetryAfter(4, dnsTest, 1*time.Second); err != nil {
if err := commonutil.RetryAfter(40, dnsTest, 5*time.Second); err != nil {
t.Fatalf("DNS lookup failed with error:", err)
}
}

View File

@ -27,12 +27,12 @@ import (
"k8s.io/minikube/test/integration/util"
)
func TestClusterEnv(t *testing.T) {
func testClusterEnv(t *testing.T) {
t.Parallel()
minikubeRunner := util.MinikubeRunner{
Args: *args,
BinaryPath: *binaryPath,
T: t}
minikubeRunner.EnsureRunning()
dockerEnvVars := minikubeRunner.RunCommand("docker-env", true)
if err := minikubeRunner.SetEnvFromEnvCmdOutput(dockerEnvVars); err != nil {

View File

@ -19,13 +19,15 @@ limitations under the License.
package integration
import (
"k8s.io/minikube/pkg/minikube/constants"
"k8s.io/minikube/test/integration/util"
"strings"
"testing"
"k8s.io/minikube/pkg/minikube/constants"
"k8s.io/minikube/test/integration/util"
)
func TestClusterLogs(t *testing.T) {
func testClusterLogs(t *testing.T) {
t.Parallel()
minikubeRunner := util.MinikubeRunner{
Args: *args,
BinaryPath: *binaryPath,

View File

@ -19,17 +19,18 @@ limitations under the License.
package integration
import (
"k8s.io/minikube/test/integration/util"
"strings"
"testing"
"k8s.io/minikube/test/integration/util"
)
func TestClusterSSH(t *testing.T) {
func testClusterSSH(t *testing.T) {
t.Parallel()
minikubeRunner := util.MinikubeRunner{
Args: *args,
BinaryPath: *binaryPath,
T: t}
minikubeRunner.EnsureRunning()
expectedStr := "hello"
sshCmdOutput := minikubeRunner.RunCommand("ssh echo "+expectedStr, true)

View File

@ -28,13 +28,8 @@ import (
"k8s.io/minikube/test/integration/util"
)
func TestClusterStatus(t *testing.T) {
minikubeRunner := util.MinikubeRunner{
Args: *args,
BinaryPath: *binaryPath,
T: t}
minikubeRunner.EnsureRunning()
func testClusterStatus(t *testing.T) {
t.Parallel()
kubectlRunner := util.NewKubectlRunner(t)
cs := api.ComponentStatusList{}

View File

@ -32,7 +32,7 @@ func TestDockerEnv(t *testing.T) {
BinaryPath: *binaryPath,
T: t}
minikubeRunner.RunCommand("delete", true)
minikubeRunner.RunCommand("delete", false)
startCmd := fmt.Sprintf("start %s %s", minikubeRunner.Args, "--docker-env=FOO=BAR --docker-env=BAZ=BAT")
minikubeRunner.RunCommand(startCmd, true)

View File

@ -0,0 +1,42 @@
// +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"
"k8s.io/minikube/test/integration/util"
)
func TestFunctional(t *testing.T) {
minikubeRunner := util.MinikubeRunner{
BinaryPath: *binaryPath,
Args: *args,
T: t}
minikubeRunner.EnsureRunning()
t.Run("DNS", testClusterDNS)
t.Run("EnvVars", testClusterEnv)
t.Run("Logs", testClusterLogs)
t.Run("SSH", testClusterSSH)
t.Run("Status", testClusterStatus)
t.Run("Addons", testAddons)
t.Run("Dashboard", testDashboard)
t.Run("ServicesList", testServicesList)
}