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-05-02 17:37:01 +00:00
|
|
|
|
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-05-02 17:37:01 +00:00
|
|
|
|
2016-04-29 23:18:49 +00:00
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
2016-05-02 17:37:01 +00:00
|
|
|
|
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 (
|
2019-03-26 01:25:01 +00:00
|
|
|
"fmt"
|
2016-05-17 15:48:57 +00:00
|
|
|
"net"
|
|
|
|
"strings"
|
2016-04-29 23:18:49 +00:00
|
|
|
"testing"
|
2016-11-04 16:43:40 +00:00
|
|
|
"time"
|
2016-05-14 01:47:43 +00:00
|
|
|
|
2017-02-22 03:27:51 +00:00
|
|
|
"github.com/docker/machine/libmachine/state"
|
2019-03-26 01:25:01 +00:00
|
|
|
"k8s.io/minikube/pkg/minikube/constants"
|
2016-05-14 01:47:43 +00:00
|
|
|
"k8s.io/minikube/test/integration/util"
|
2016-04-29 23:18:49 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestStartStop(t *testing.T) {
|
2019-08-01 19:44:41 +00:00
|
|
|
p := profileName(t) // gets profile name used for minikube and kube context
|
2019-08-01 23:42:29 +00:00
|
|
|
if shouldRunInParallel(t) {
|
2019-07-26 22:27:05 +00:00
|
|
|
t.Parallel()
|
|
|
|
}
|
2019-08-01 05:50:04 +00:00
|
|
|
|
2019-07-30 20:20:44 +00:00
|
|
|
t.Run("group", func(t *testing.T) {
|
2019-08-01 23:42:29 +00:00
|
|
|
if shouldRunInParallel(t) {
|
2019-07-30 23:36:53 +00:00
|
|
|
t.Parallel()
|
|
|
|
}
|
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
args []string
|
|
|
|
}{
|
2019-08-09 00:12:33 +00:00
|
|
|
{"oldest", []string{
|
2019-07-30 23:36:53 +00:00
|
|
|
"--cache-images=false",
|
|
|
|
fmt.Sprintf("--kubernetes-version=%s", constants.OldestKubernetesVersion),
|
|
|
|
// default is the network created by libvirt, if we change the name minikube won't boot
|
|
|
|
// because the given network doesn't exist
|
|
|
|
"--kvm-network=default",
|
|
|
|
"--kvm-qemu-uri=qemu:///system",
|
|
|
|
}},
|
2019-08-09 00:12:33 +00:00
|
|
|
{"cni", []string{
|
2019-07-30 23:36:53 +00:00
|
|
|
"--feature-gates",
|
|
|
|
"ServerSideApply=true",
|
|
|
|
"--network-plugin=cni",
|
|
|
|
"--extra-config=kubelet.network-plugin=cni",
|
|
|
|
"--extra-config=kubeadm.pod-network-cidr=192.168.111.111/16",
|
|
|
|
fmt.Sprintf("--kubernetes-version=%s", constants.NewestKubernetesVersion),
|
|
|
|
}},
|
2019-08-09 00:12:33 +00:00
|
|
|
{"containerd", []string{
|
2019-07-30 23:36:53 +00:00
|
|
|
"--container-runtime=containerd",
|
|
|
|
"--docker-opt containerd=/var/run/containerd/containerd.sock",
|
|
|
|
"--apiserver-port=8444",
|
|
|
|
}},
|
2019-08-09 00:12:33 +00:00
|
|
|
{"crio", []string{
|
2019-07-30 23:36:53 +00:00
|
|
|
"--container-runtime=crio",
|
|
|
|
"--extra-config",
|
2019-08-09 00:12:33 +00:00
|
|
|
"--disable-driver-mounts",
|
2019-07-30 23:36:53 +00:00
|
|
|
"kubeadm.ignore-preflight-errors=SystemVerification",
|
|
|
|
}},
|
|
|
|
}
|
|
|
|
|
2019-07-30 20:20:44 +00:00
|
|
|
for _, tc := range tests {
|
2019-07-30 22:38:46 +00:00
|
|
|
n := tc.name // because similar to https://golang.org/doc/faq#closures_and_goroutines
|
2019-07-30 20:20:44 +00:00
|
|
|
t.Run(tc.name, func(t *testing.T) {
|
2019-08-01 23:42:29 +00:00
|
|
|
if shouldRunInParallel(t) {
|
2019-08-01 05:50:04 +00:00
|
|
|
t.Parallel()
|
|
|
|
}
|
|
|
|
|
2019-08-01 06:05:43 +00:00
|
|
|
pn := p + n // TestStartStopoldest
|
|
|
|
mk := NewMinikubeRunner(t, pn, "--wait=false")
|
|
|
|
// TODO : redundant first clause ? never happens?
|
2019-08-01 23:42:29 +00:00
|
|
|
if !strings.Contains(pn, "docker") && isTestNoneDriver(t) {
|
2019-07-30 22:38:46 +00:00
|
|
|
t.Skipf("skipping %s - incompatible with none driver", t.Name())
|
2019-07-30 20:20:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
mk.RunCommand("config set WantReportErrorPrompt false", true)
|
|
|
|
stdout, stderr, err := mk.Start(tc.args...)
|
|
|
|
if err != nil {
|
2019-07-31 19:05:57 +00:00
|
|
|
t.Fatalf("failed to start minikube (for profile %s) failed : %v\nstdout: %s\nstderr: %s", pn, err, stdout, stderr)
|
2019-07-30 20:20:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
mk.CheckStatus(state.Running.String())
|
|
|
|
|
2019-07-31 18:32:49 +00:00
|
|
|
ip, stderr := mk.RunCommand("ip", true)
|
2019-07-30 20:20:44 +00:00
|
|
|
ip = strings.TrimRight(ip, "\n")
|
|
|
|
if net.ParseIP(ip) == nil {
|
2019-07-31 18:32:49 +00:00
|
|
|
t.Fatalf("IP command returned an invalid address: %s \n %s", ip, stderr)
|
2019-07-30 20:20:44 +00:00
|
|
|
}
|
|
|
|
|
2019-08-01 07:31:38 +00:00
|
|
|
stop := func() error {
|
|
|
|
stdout, stderr, err = mk.RunCommandRetriable("stop")
|
2019-07-30 20:20:44 +00:00
|
|
|
return mk.CheckStatusNoFail(state.Stopped.String())
|
|
|
|
}
|
|
|
|
|
2019-08-01 07:31:38 +00:00
|
|
|
err = util.RetryX(stop, 10*time.Second, 2*time.Minute)
|
|
|
|
mk.CheckStatus(state.Stopped.String())
|
2019-07-30 20:20:44 +00:00
|
|
|
|
2019-08-01 07:31:38 +00:00
|
|
|
// TODO medyagh:
|
2019-07-30 20:20:44 +00:00
|
|
|
// https://github.com/kubernetes/minikube/issues/4854
|
|
|
|
|
|
|
|
stdout, stderr, err = mk.Start(tc.args...)
|
|
|
|
if err != nil {
|
2019-07-31 19:05:57 +00:00
|
|
|
t.Fatalf("failed to start minikube (for profile %s) failed : %v\nstdout: %s\nstderr: %s", t.Name(), err, stdout, stderr)
|
2019-07-30 20:20:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
mk.CheckStatus(state.Running.String())
|
|
|
|
|
|
|
|
mk.RunCommand("delete", true)
|
|
|
|
mk.CheckStatus(state.None.String())
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
2016-04-29 23:18:49 +00:00
|
|
|
}
|