Skip to content

Commit bf563b7

Browse files
authored
Merge pull request #891 from dlorenc/subtest
Move some integration tests to the subtest framework, and run them in…
2 parents fc1fbce + 35acd21 commit bf563b7

8 files changed

+79
-43
lines changed

test/integration/addons_test.go

+20-19
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,8 @@ var (
3838
dashboardSvcCmd = []string{"get", "svc", "kubernetes-dashboard", "--namespace=kube-system"}
3939
)
4040

41-
func TestAddons(t *testing.T) {
42-
minikubeRunner := util.MinikubeRunner{
43-
BinaryPath: *binaryPath,
44-
Args: *args,
45-
T: t}
46-
47-
minikubeRunner.EnsureRunning()
41+
func testAddons(t *testing.T) {
42+
t.Parallel()
4843
kubectlRunner := util.NewKubectlRunner(t)
4944

5045
checkAddon := func() error {
@@ -70,23 +65,23 @@ func TestAddons(t *testing.T) {
7065
}
7166
}
7267

73-
func TestDashboard(t *testing.T) {
68+
func testDashboard(t *testing.T) {
69+
t.Parallel()
70+
kubectlRunner := util.NewKubectlRunner(t)
7471
minikubeRunner := util.MinikubeRunner{
7572
BinaryPath: *binaryPath,
7673
Args: *args,
7774
T: t}
78-
minikubeRunner.EnsureRunning()
79-
kubectlRunner := util.NewKubectlRunner(t)
8075

8176
checkDashboard := func() error {
8277
rc := api.ReplicationController{}
8378
svc := api.Service{}
8479
if err := kubectlRunner.RunCommandParseOutput(dashboardRcCmd, &rc); err != nil {
85-
return err
80+
return &commonutil.RetriableError{Err: err}
8681
}
8782

8883
if err := kubectlRunner.RunCommandParseOutput(dashboardSvcCmd, &svc); err != nil {
89-
return err
84+
return &commonutil.RetriableError{Err: err}
9085
}
9186

9287
if rc.Status.Replicas != rc.Status.FullyLabeledReplicas {
@@ -100,7 +95,7 @@ func TestDashboard(t *testing.T) {
10095
return nil
10196
}
10297

103-
if err := commonutil.RetryAfter(10, checkDashboard, 5*time.Second); err != nil {
98+
if err := commonutil.RetryAfter(60, checkDashboard, 5*time.Second); err != nil {
10499
t.Fatalf("Dashboard is unhealthy: %s", err)
105100
}
106101

@@ -121,17 +116,23 @@ func TestDashboard(t *testing.T) {
121116
}
122117
}
123118

124-
func TestServicesList(t *testing.T) {
119+
func testServicesList(t *testing.T) {
120+
t.Parallel()
125121
minikubeRunner := util.MinikubeRunner{
126122
BinaryPath: *binaryPath,
127123
Args: *args,
128124
T: t}
129-
minikubeRunner.EnsureRunning()
130125

131-
output := minikubeRunner.RunCommand("service list", true)
132-
for _, svc := range []string{"kubernetes", "kube-dns", "kubernetes-dashboard"} {
133-
if !strings.Contains(output, svc) {
134-
t.Errorf("Error, service %s missing from output %s", svc, output)
126+
checkServices := func() error {
127+
output := minikubeRunner.RunCommand("service list", false)
128+
if !strings.Contains(output, "kubernetes") {
129+
return &commonutil.RetriableError{
130+
Err: fmt.Errorf("Error, kubernetes service missing from output %s", output),
131+
}
135132
}
133+
return nil
134+
}
135+
if err := commonutil.RetryAfter(5, checkServices, 2*time.Second); err != nil {
136+
t.Fatalf(err.Error())
136137
}
137138
}

test/integration/cluster_dns_test.go

+3-8
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,8 @@ import (
3030
"k8s.io/minikube/test/integration/util"
3131
)
3232

33-
func TestClusterDNS(t *testing.T) {
34-
minikubeRunner := util.MinikubeRunner{
35-
BinaryPath: *binaryPath,
36-
Args: *args,
37-
T: t}
38-
minikubeRunner.EnsureRunning()
39-
33+
func testClusterDNS(t *testing.T) {
34+
t.Parallel()
4035
kubectlRunner := util.NewKubectlRunner(t)
4136
podName := "busybox"
4237
podPath, _ := filepath.Abs("testdata/busybox.yaml")
@@ -68,7 +63,7 @@ func TestClusterDNS(t *testing.T) {
6863
return nil
6964
}
7065

71-
if err := commonutil.RetryAfter(4, dnsTest, 1*time.Second); err != nil {
66+
if err := commonutil.RetryAfter(40, dnsTest, 5*time.Second); err != nil {
7267
t.Fatalf("DNS lookup failed with error:", err)
7368
}
7469
}

test/integration/cluster_env_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ import (
2727
"k8s.io/minikube/test/integration/util"
2828
)
2929

30-
func TestClusterEnv(t *testing.T) {
30+
func testClusterEnv(t *testing.T) {
31+
t.Parallel()
3132
minikubeRunner := util.MinikubeRunner{
3233
Args: *args,
3334
BinaryPath: *binaryPath,
3435
T: t}
35-
minikubeRunner.EnsureRunning()
3636

3737
dockerEnvVars := minikubeRunner.RunCommand("docker-env", true)
3838
if err := minikubeRunner.SetEnvFromEnvCmdOutput(dockerEnvVars); err != nil {

test/integration/cluster_logs_test.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@ limitations under the License.
1919
package integration
2020

2121
import (
22-
"k8s.io/minikube/pkg/minikube/constants"
23-
"k8s.io/minikube/test/integration/util"
2422
"strings"
2523
"testing"
24+
25+
"k8s.io/minikube/pkg/minikube/constants"
26+
"k8s.io/minikube/test/integration/util"
2627
)
2728

28-
func TestClusterLogs(t *testing.T) {
29+
func testClusterLogs(t *testing.T) {
30+
t.Parallel()
2931
minikubeRunner := util.MinikubeRunner{
3032
Args: *args,
3133
BinaryPath: *binaryPath,

test/integration/cluster_ssh_test.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,18 @@ limitations under the License.
1919
package integration
2020

2121
import (
22-
"k8s.io/minikube/test/integration/util"
2322
"strings"
2423
"testing"
24+
25+
"k8s.io/minikube/test/integration/util"
2526
)
2627

27-
func TestClusterSSH(t *testing.T) {
28+
func testClusterSSH(t *testing.T) {
29+
t.Parallel()
2830
minikubeRunner := util.MinikubeRunner{
2931
Args: *args,
3032
BinaryPath: *binaryPath,
3133
T: t}
32-
minikubeRunner.EnsureRunning()
3334

3435
expectedStr := "hello"
3536
sshCmdOutput := minikubeRunner.RunCommand("ssh echo "+expectedStr, true)

test/integration/cluster_status_test.go

+2-7
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,8 @@ import (
2828
"k8s.io/minikube/test/integration/util"
2929
)
3030

31-
func TestClusterStatus(t *testing.T) {
32-
minikubeRunner := util.MinikubeRunner{
33-
Args: *args,
34-
BinaryPath: *binaryPath,
35-
T: t}
36-
minikubeRunner.EnsureRunning()
37-
31+
func testClusterStatus(t *testing.T) {
32+
t.Parallel()
3833
kubectlRunner := util.NewKubectlRunner(t)
3934
cs := api.ComponentStatusList{}
4035

test/integration/docker_env_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func TestDockerEnv(t *testing.T) {
3232
BinaryPath: *binaryPath,
3333
T: t}
3434

35-
minikubeRunner.RunCommand("delete", true)
35+
minikubeRunner.RunCommand("delete", false)
3636

3737
startCmd := fmt.Sprintf("start %s %s", minikubeRunner.Args, "--docker-env=FOO=BAR --docker-env=BAZ=BAT")
3838
minikubeRunner.RunCommand(startCmd, true)

test/integration/functional_test.go

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// +build integration
2+
3+
/*
4+
Copyright 2016 The Kubernetes Authors All rights reserved.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
*/
18+
19+
package integration
20+
21+
import (
22+
"testing"
23+
24+
"k8s.io/minikube/test/integration/util"
25+
)
26+
27+
func TestFunctional(t *testing.T) {
28+
minikubeRunner := util.MinikubeRunner{
29+
BinaryPath: *binaryPath,
30+
Args: *args,
31+
T: t}
32+
minikubeRunner.EnsureRunning()
33+
34+
t.Run("DNS", testClusterDNS)
35+
t.Run("EnvVars", testClusterEnv)
36+
t.Run("Logs", testClusterLogs)
37+
t.Run("SSH", testClusterSSH)
38+
t.Run("Status", testClusterStatus)
39+
t.Run("Addons", testAddons)
40+
t.Run("Dashboard", testDashboard)
41+
t.Run("ServicesList", testServicesList)
42+
}

0 commit comments

Comments
 (0)