Add a "--minikube-args" flag to the integration tests.

This flag lets you pass arbitrary flags to minikube start. For now,
this is useful for testing different iso URLs and VM drivers.
pull/249/head
dlorenc 2016-06-30 14:11:37 -07:00
parent edec7b3656
commit 37ea2f0eea
9 changed files with 75 additions and 21 deletions

View File

@ -36,7 +36,11 @@ var (
)
func TestAddons(t *testing.T) {
minikubeRunner := util.MinikubeRunner{BinaryPath: *binaryPath, T: t}
minikubeRunner := util.MinikubeRunner{
BinaryPath: *binaryPath,
Args: *args,
T: t}
minikubeRunner.EnsureRunning()
kubectlRunner := util.NewKubectlRunner(t)
@ -58,8 +62,11 @@ func TestAddons(t *testing.T) {
}
func TestDashboard(t *testing.T) {
minikubeRunner := util.MinikubeRunner{BinaryPath: *binaryPath, T: t}
minikubeRunner.RunCommand("start", true)
minikubeRunner := util.MinikubeRunner{
BinaryPath: *binaryPath,
Args: *args,
T: t}
minikubeRunner.Start()
minikubeRunner.CheckStatus("Running")
kubectlRunner := util.NewKubectlRunner(t)

View File

@ -31,7 +31,10 @@ import (
)
func TestClusterDNS(t *testing.T) {
minikubeRunner := util.MinikubeRunner{BinaryPath: *binaryPath, T: t}
minikubeRunner := util.MinikubeRunner{
BinaryPath: *binaryPath,
Args: *args,
T: t}
minikubeRunner.EnsureRunning()
kubectlRunner := util.NewKubectlRunner(t)

View File

@ -28,7 +28,10 @@ import (
)
func TestClusterEnv(t *testing.T) {
minikubeRunner := util.MinikubeRunner{BinaryPath: *binaryPath, T: t}
minikubeRunner := util.MinikubeRunner{
Args: *args,
BinaryPath: *binaryPath,
T: t}
minikubeRunner.EnsureRunning()
dockerEnvVars := minikubeRunner.RunCommand("docker-env", true)

View File

@ -26,7 +26,10 @@ import (
)
func TestClusterLogs(t *testing.T) {
minikubeRunner := util.MinikubeRunner{BinaryPath: *binaryPath, T: t}
minikubeRunner := util.MinikubeRunner{
Args: *args,
BinaryPath: *binaryPath,
T: t}
minikubeRunner.EnsureRunning()
logsCmdOutput := minikubeRunner.RunCommand("logs", true)

View File

@ -25,7 +25,10 @@ import (
)
func TestClusterSSH(t *testing.T) {
minikubeRunner := util.MinikubeRunner{BinaryPath: *binaryPath, T: t}
minikubeRunner := util.MinikubeRunner{
Args: *args,
BinaryPath: *binaryPath,
T: t}
minikubeRunner.EnsureRunning()
expectedStr := "hello"

View File

@ -29,7 +29,10 @@ import (
)
func TestClusterStatus(t *testing.T) {
minikubeRunner := util.MinikubeRunner{BinaryPath: *binaryPath, T: t}
minikubeRunner := util.MinikubeRunner{
Args: *args,
BinaryPath: *binaryPath,
T: t}
minikubeRunner.EnsureRunning()
kubectlRunner := util.NewKubectlRunner(t)

33
test/integration/flags.go Normal file
View File

@ -0,0 +1,33 @@
// +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 (
"flag"
"os"
"testing"
)
func TestMain(m *testing.M) {
flag.Parse()
os.Exit(m.Run())
}
var binaryPath = flag.String("binary", "../../out/minikube", "path to minikube binary")
var args = flag.String("minikube-args", "", "Arguments to pass to minikube")

View File

@ -19,24 +19,23 @@ limitations under the License.
package integration
import (
"flag"
"net"
"os"
"strings"
"testing"
"k8s.io/minikube/test/integration/util"
)
var binaryPath = flag.String("binary", "../../out/minikube", "path to minikube binary")
func TestStartStop(t *testing.T) {
runner := util.MinikubeRunner{T: t, BinaryPath: *binaryPath}
runner := util.MinikubeRunner{
Args: *args,
BinaryPath: *binaryPath,
T: t}
runner.RunCommand("delete", false)
runner.CheckStatus("Does Not Exist")
runner.RunCommand("start", true)
runner.Start()
runner.CheckStatus("Running")
ip := runner.RunCommand("ip", true)
@ -48,14 +47,9 @@ func TestStartStop(t *testing.T) {
runner.RunCommand("stop", true)
runner.CheckStatus("Stopped")
runner.RunCommand("start", true)
runner.Start()
runner.CheckStatus("Running")
runner.RunCommand("delete", true)
runner.CheckStatus("Does Not Exist")
}
func TestMain(m *testing.M) {
flag.Parse()
os.Exit(m.Run())
}

View File

@ -34,6 +34,7 @@ import (
type MinikubeRunner struct {
T *testing.T
BinaryPath string
Args string
}
func (m *MinikubeRunner) RunCommand(command string, checkError bool) string {
@ -52,9 +53,13 @@ func (m *MinikubeRunner) RunCommand(command string, checkError bool) string {
return string(stdout)
}
func (m *MinikubeRunner) Start() {
m.RunCommand(fmt.Sprintf("start %s", m.Args), true)
}
func (m *MinikubeRunner) EnsureRunning() {
if m.GetStatus() != "Running" {
m.RunCommand("start", true)
m.Start()
}
m.CheckStatus("Running")
}