Add integration test
parent
650c26309c
commit
32e0732e15
|
@ -40,7 +40,7 @@ func Auxiliary(mirror string) []string {
|
|||
}
|
||||
}
|
||||
|
||||
// Pause returns the image name for the pause image
|
||||
// Pause returns the image name for thoß… pause image
|
||||
func Pause(mirror string) string {
|
||||
// Should match `PauseVersion` in:
|
||||
// https://github.com/kubernetes/kubernetes/blob/master/cmd/kubeadm/app/constants/constants.go
|
||||
|
|
|
@ -47,13 +47,13 @@ func Kubeadm(mirror string, version string) ([]string, error) {
|
|||
|
||||
// componentImage returns a Kubernetes component image to pull
|
||||
func componentImage(name string, v semver.Version, mirror string) string {
|
||||
hasTag := false
|
||||
needsArchSuffix := false
|
||||
ancient := semver.MustParseRange("<1.12.0")
|
||||
if ancient(v) {
|
||||
hasTag = true
|
||||
needsArchSuffix = true
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%sv%s", path.Join(KubernetesRepo(mirror), name+ArchTag(hasTag)), v)
|
||||
return fmt.Sprintf("%sv%s", path.Join(KubernetesRepo(mirror), name+ArchTag(needsArchSuffix)), v)
|
||||
}
|
||||
|
||||
// coreDNS returns the images used for CoreDNS
|
||||
|
@ -78,6 +78,12 @@ func coreDNS(v semver.Version, mirror string) string {
|
|||
|
||||
// etcd returns the image used for etcd
|
||||
func etcd(v semver.Version, mirror string) string {
|
||||
needsArchSuffix := false
|
||||
ancient := semver.MustParseRange("<1.12.0")
|
||||
if ancient(v) {
|
||||
needsArchSuffix = true
|
||||
}
|
||||
|
||||
// Should match `DefaultEtcdVersion` in:
|
||||
// https://github.com/kubernetes/kubernetes/blob/master/cmd/kubeadm/app/constants/constants.go
|
||||
ev := "3.4.3-0"
|
||||
|
@ -91,5 +97,5 @@ func etcd(v semver.Version, mirror string) string {
|
|||
case 11:
|
||||
ev = "3.2.18"
|
||||
}
|
||||
return path.Join(KubernetesRepo(mirror), "etcd"+ArchTag(false)+ev)
|
||||
return path.Join(KubernetesRepo(mirror), "etcd"+ArchTag(needsArchSuffix)+ev)
|
||||
}
|
||||
|
|
|
@ -39,8 +39,8 @@ func TestKubeadmImages(t *testing.T) {
|
|||
"k8s.gcr.io/pause:3.1",
|
||||
"k8s.gcr.io/kube-addon-manager:v9.0.2",
|
||||
"gcr.io/k8s-minikube/storage-provisioner:v1.8.1",
|
||||
"kubernetesui/dashboard:v2.0.0-beta8",
|
||||
"kubernetesui/metrics-scraper:v1.0.2",
|
||||
"docker.io/kubernetesui/dashboard:v2.0.0-beta8",
|
||||
"docker.io/kubernetesui/metrics-scraper:v1.0.2",
|
||||
}},
|
||||
{"v1.16.1", "mirror.k8s.io", []string{
|
||||
"mirror.k8s.io/kube-proxy:v1.16.1",
|
||||
|
@ -65,8 +65,8 @@ func TestKubeadmImages(t *testing.T) {
|
|||
"k8s.gcr.io/pause:3.1",
|
||||
"k8s.gcr.io/kube-addon-manager:v9.0.2",
|
||||
"gcr.io/k8s-minikube/storage-provisioner:v1.8.1",
|
||||
"kubernetesui/dashboard:v2.0.0-beta8",
|
||||
"kubernetesui/metrics-scraper:v1.0.2",
|
||||
"docker.io/kubernetesui/dashboard:v2.0.0-beta8",
|
||||
"docker.io/kubernetesui/metrics-scraper:v1.0.2",
|
||||
}},
|
||||
{"v1.14.0", "", []string{
|
||||
"k8s.gcr.io/kube-proxy:v1.14.0",
|
||||
|
@ -78,8 +78,8 @@ func TestKubeadmImages(t *testing.T) {
|
|||
"k8s.gcr.io/pause:3.1",
|
||||
"k8s.gcr.io/kube-addon-manager:v9.0.2",
|
||||
"gcr.io/k8s-minikube/storage-provisioner:v1.8.1",
|
||||
"kubernetesui/dashboard:v2.0.0-beta8",
|
||||
"kubernetesui/metrics-scraper:v1.0.2",
|
||||
"docker.io/kubernetesui/dashboard:v2.0.0-beta8",
|
||||
"docker.io/kubernetesui/metrics-scraper:v1.0.2",
|
||||
}},
|
||||
{"v1.13.0", "", []string{
|
||||
"k8s.gcr.io/kube-proxy:v1.13.0",
|
||||
|
@ -91,8 +91,8 @@ func TestKubeadmImages(t *testing.T) {
|
|||
"k8s.gcr.io/pause:3.1",
|
||||
"k8s.gcr.io/kube-addon-manager:v9.0.2",
|
||||
"gcr.io/k8s-minikube/storage-provisioner:v1.8.1",
|
||||
"kubernetesui/dashboard:v2.0.0-beta8",
|
||||
"kubernetesui/metrics-scraper:v1.0.2",
|
||||
"docker.io/kubernetesui/dashboard:v2.0.0-beta8",
|
||||
"docker.io/kubernetesui/metrics-scraper:v1.0.2",
|
||||
}},
|
||||
{"v1.12.0", "", []string{
|
||||
"k8s.gcr.io/kube-proxy:v1.12.0",
|
||||
|
@ -104,21 +104,21 @@ func TestKubeadmImages(t *testing.T) {
|
|||
"k8s.gcr.io/pause:3.1",
|
||||
"k8s.gcr.io/kube-addon-manager:v9.0.2",
|
||||
"gcr.io/k8s-minikube/storage-provisioner:v1.8.1",
|
||||
"kubernetesui/dashboard:v2.0.0-beta8",
|
||||
"kubernetesui/metrics-scraper:v1.0.2",
|
||||
"docker.io/kubernetesui/dashboard:v2.0.0-beta8",
|
||||
"docker.io/kubernetesui/metrics-scraper:v1.0.2",
|
||||
}},
|
||||
{"v1.11.0", "", []string{
|
||||
"k8s.gcr.io/kube-proxy-amd64:v1.11.0",
|
||||
"k8s.gcr.io/kube-scheduler-amd64:v1.11.0",
|
||||
"k8s.gcr.io/kube-controller-manager-amd64:v1.11.0",
|
||||
"k8s.gcr.io/kube-apiserver-amd64:v1.11.0",
|
||||
{"v1.11.10", "", []string{
|
||||
"k8s.gcr.io/kube-proxy-amd64:v1.11.10",
|
||||
"k8s.gcr.io/kube-scheduler-amd64:v1.11.10",
|
||||
"k8s.gcr.io/kube-controller-manager-amd64:v1.11.10",
|
||||
"k8s.gcr.io/kube-apiserver-amd64:v1.11.10",
|
||||
"k8s.gcr.io/coredns:1.1.3",
|
||||
"k8s.gcr.io/etcd:3.2.18",
|
||||
"k8s.gcr.io/etcd-amd64:3.2.18",
|
||||
"k8s.gcr.io/pause:3.1",
|
||||
"k8s.gcr.io/kube-addon-manager:v9.0.2",
|
||||
"gcr.io/k8s-minikube/storage-provisioner:v1.8.1",
|
||||
"kubernetesui/dashboard:v2.0.0-beta8",
|
||||
"kubernetesui/metrics-scraper:v1.0.2",
|
||||
"docker.io/kubernetesui/dashboard:v2.0.0-beta8",
|
||||
"docker.io/kubernetesui/metrics-scraper:v1.0.2",
|
||||
}},
|
||||
}
|
||||
for _, tc := range tests {
|
||||
|
|
|
@ -38,7 +38,7 @@ func TestDockerFlags(t *testing.T) {
|
|||
defer CleanupWithLogs(t, profile, cancel)
|
||||
|
||||
// Use the most verbose logging for the simplest test. If it fails, something is very wrong.
|
||||
args := append([]string{"start", "-p", profile, "--wait=false", "--docker-env=FOO=BAR", "--docker-env=BAZ=BAT", "--docker-opt=debug", "--docker-opt=icc=true", "--alsologtostderr", "-v=5"}, StartArgs()...)
|
||||
args := append([]string{"start", "-p", profile, "--cache-images=false", "--wait=false", "--docker-env=FOO=BAR", "--docker-env=BAZ=BAT", "--docker-opt=debug", "--docker-opt=icc=true", "--alsologtostderr", "-v=5"}, StartArgs()...)
|
||||
rr, err := Run(t, exec.CommandContext(ctx, Target(), args...))
|
||||
if err != nil {
|
||||
t.Errorf("%s failed: %v", rr.Args, err)
|
||||
|
|
|
@ -20,15 +20,19 @@ package integration
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/docker/machine/libmachine/state"
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"k8s.io/minikube/pkg/minikube/bootstrapper/images"
|
||||
"k8s.io/minikube/pkg/minikube/constants"
|
||||
)
|
||||
|
||||
|
@ -37,12 +41,11 @@ func TestStartStop(t *testing.T) {
|
|||
|
||||
t.Run("group", func(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
args []string
|
||||
name string
|
||||
version string
|
||||
args []string
|
||||
}{
|
||||
{"docker", []string{
|
||||
"--cache-images=false",
|
||||
fmt.Sprintf("--kubernetes-version=%s", constants.OldestKubernetesVersion),
|
||||
{"old-docker", constants.OldestKubernetesVersion, []string{
|
||||
// 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",
|
||||
|
@ -51,21 +54,20 @@ func TestStartStop(t *testing.T) {
|
|||
"--keep-context=false",
|
||||
"--container-runtime=docker",
|
||||
}},
|
||||
{"cni", []string{
|
||||
{"newest-cni", constants.NewestKubernetesVersion, []string{
|
||||
"--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),
|
||||
}},
|
||||
{"containerd", []string{
|
||||
{"containerd", constants.DefaultKubernetesVersion, []string{
|
||||
"--container-runtime=containerd",
|
||||
"--docker-opt",
|
||||
"containerd=/var/run/containerd/containerd.sock",
|
||||
"--apiserver-port=8444",
|
||||
}},
|
||||
{"crio", []string{
|
||||
{"crio", "v1.15.0", []string{
|
||||
"--container-runtime=crio",
|
||||
"--disable-driver-mounts",
|
||||
"--extra-config=kubeadm.ignore-preflight-errors=SystemVerification",
|
||||
|
@ -88,6 +90,7 @@ func TestStartStop(t *testing.T) {
|
|||
|
||||
startArgs := append([]string{"start", "-p", profile, "--alsologtostderr", "-v=3", "--wait=true"}, tc.args...)
|
||||
startArgs = append(startArgs, StartArgs()...)
|
||||
startArgs = append(startArgs, fmt.Sprintf("--kubernetes-version=%s", tc.version))
|
||||
rr, err := Run(t, exec.CommandContext(ctx, Target(), startArgs...))
|
||||
if err != nil {
|
||||
// Fatal so that we may collect logs before stop/delete steps
|
||||
|
@ -144,6 +147,34 @@ func TestStartStop(t *testing.T) {
|
|||
t.Fatalf("%s failed: %v", rr.Args, err)
|
||||
}
|
||||
|
||||
// Make sure that kubeadm did not need to pull in additional images
|
||||
rr, err = Run(t, exec.CommandContext(ctx, Target(), "ssh", "-p", profile, "sudo crictl images -o json"))
|
||||
if err != nil {
|
||||
t.Errorf("%s failed: %v", rr.Args, err)
|
||||
}
|
||||
jv := map[string][]struct {
|
||||
Tags []string `json:"repoTags"`
|
||||
}{}
|
||||
err = json.Unmarshal(rr.Stdout.Bytes(), &jv)
|
||||
gotImages := []string{}
|
||||
for _, img := range jv["images"] {
|
||||
for _, i := range img.Tags {
|
||||
// Ignore non-Kubernetes images
|
||||
if !strings.Contains(i, "ingress") && !strings.Contains(i, "busybox") {
|
||||
gotImages = append(gotImages, i)
|
||||
}
|
||||
}
|
||||
}
|
||||
want, err := images.Kubeadm("", tc.version)
|
||||
if err != nil {
|
||||
t.Errorf("kubeadm images: %v", tc.version)
|
||||
}
|
||||
sort.Strings(want)
|
||||
sort.Strings(gotImages)
|
||||
if diff := cmp.Diff(want, gotImages); diff != "" {
|
||||
t.Errorf("%s images mismatch (-want +got):\n%s", tc.version, diff)
|
||||
}
|
||||
|
||||
if strings.Contains(tc.name, "cni") {
|
||||
t.Logf("WARNING: cni mode requires additional setup before pods can schedule :(")
|
||||
} else if _, err := PodWait(ctx, t, profile, "default", "integration-test=busybox", 2*time.Minute); err != nil {
|
||||
|
@ -155,7 +186,7 @@ func TestStartStop(t *testing.T) {
|
|||
t.Errorf("status = %q; want = %q", got, state.Running)
|
||||
}
|
||||
|
||||
if !*cleanup {
|
||||
if *cleanup {
|
||||
// Normally handled by cleanuprofile, but not fatal there
|
||||
rr, err = Run(t, exec.CommandContext(ctx, Target(), "delete", "-p", profile))
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue