minikube/test/integration/start_stop_delete_test.go

109 lines
3.0 KiB
Go
Raw Normal View History

2016-04-29 23:18:49 +00:00
// +build integration
/*
2016-05-01 15:49:51 +00:00
Copyright 2016 The Kubernetes Authors All rights reserved.
2016-04-29 23:18:49 +00:00
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
2016-04-29 23:18:49 +00:00
http://www.apache.org/licenses/LICENSE-2.0
2016-04-29 23:18:49 +00:00
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 (
"fmt"
2016-05-17 15:48:57 +00:00
"net"
"strings"
2016-04-29 23:18:49 +00:00
"testing"
"time"
2017-02-22 03:27:51 +00:00
"github.com/docker/machine/libmachine/state"
"k8s.io/minikube/pkg/minikube/constants"
"k8s.io/minikube/test/integration/util"
2016-04-29 23:18:49 +00:00
)
func TestStartStop(t *testing.T) {
tests := []struct {
name string
args []string
}{
2019-03-26 04:02:44 +00:00
{"nocache_oldest", []string{
"--cache-images=false",
fmt.Sprintf("--kubernetes-version=%s", constants.OldestKubernetesVersion),
}},
2019-03-27 03:26:47 +00:00
{"feature_gates_newest_cni", []string{
"--feature-gates",
2019-03-26 04:02:44 +00:00
"ServerSideApply=true",
2019-03-27 03:26:47 +00:00
"--network-plugin=cni",
"--extra-config=kubelet.network-plugin=cni",
fmt.Sprintf("--kubernetes-version=%s", constants.NewestKubernetesVersion),
}},
{"containerd_and_non_default_apiserver_port", []string{
"--container-runtime=containerd",
"--docker-opt containerd=/var/run/containerd/containerd.sock",
"--apiserver-port=8444",
}},
2019-03-26 04:02:44 +00:00
{"crio_ignore_preflights", []string{
"--container-runtime=crio",
2019-03-26 04:02:44 +00:00
"--extra-config",
"kubeadm.ignore-preflight-errors=SystemVerification",
}},
}
2016-04-29 23:18:49 +00:00
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
r := NewMinikubeRunner(t)
if !strings.Contains(test.name, "docker") && usingNoneDriver(r) {
t.Skipf("skipping %s - incompatible with none driver", test.name)
}
2016-04-29 23:18:49 +00:00
r.RunCommand("config set WantReportErrorPrompt false", true)
r.RunCommand("delete", false)
r.CheckStatus(state.None.String())
r.Start(test.args...)
r.CheckStatus(state.Running.String())
2016-04-29 23:18:49 +00:00
ip := r.RunCommand("ip", true)
ip = strings.TrimRight(ip, "\n")
if net.ParseIP(ip) == nil {
t.Fatalf("IP command returned an invalid address: %s", ip)
}
// check for the context
kubeRunner = util.NewKubeCtlRunner()
currentContext = kubeRunner.RunCommand("config", "current-context")
if currentContext != "minikube" {
t.Fatalf("current-context not set to minikube")
}
checkStop := func() error {
r.RunCommand("stop", true)
return r.CheckStatusNoFail(state.Stopped.String())
}
currentContext = kubeRunner.RunCommand("config", "current-context")
if currentContext != "" {
t.Fatalf("Failed to unset the current-context")
}
if err := util.Retry(t, checkStop, 5*time.Second, 6); err != nil {
t.Fatalf("timed out while checking stopped status: %v", err)
}
2016-04-29 23:18:49 +00:00
r.Start(test.args...)
r.CheckStatus(state.Running.String())
2016-04-29 23:18:49 +00:00
r.RunCommand("delete", true)
r.CheckStatus(state.None.String())
})
}
2016-04-29 23:18:49 +00:00
}