未验证 提交 8e9d8a22 编写于 作者: T Thomas Strömberg 提交者: GitHub

Merge pull request #7134 from tstromberg/test-download-only

download_only_test: Fix non-docker runtimes, remove expected-driver test
......@@ -286,7 +286,6 @@ fi
touch "${TEST_OUT}"
${SUDO_PREFIX}${E2E_BIN} \
-minikube-start-args="--driver=${VM_DRIVER} ${EXTRA_START_ARGS}" \
-expected-default-driver="${EXPECTED_DEFAULT_DRIVER}" \
-test.timeout=70m -test.v \
${EXTRA_TEST_ARGS} \
-binary="${MINIKUBE_BIN}" 2>&1 | tee "${TEST_OUT}"
......
......@@ -19,7 +19,7 @@ gsutil.cmd -m cp -r gs://minikube-builds/$env:MINIKUBE_LOCATION/testdata .
./out/minikube-windows-amd64.exe delete
out/e2e-windows-amd64.exe --expected-default-driver=hyperv -minikube-start-args="--driver=hyperv --hyperv-virtual-switch=primary-virtual-switch" -binary=out/minikube-windows-amd64.exe -test.v -test.timeout=65m
out/e2e-windows-amd64.exe -minikube-start-args="--driver=hyperv --hyperv-virtual-switch=primary-virtual-switch" -binary=out/minikube-windows-amd64.exe -test.v -test.timeout=65m
$env:result=$lastexitcode
# If the last exit code was 0->success, x>0->error
If($env:result -eq 0){$env:status="success"}
......
......@@ -19,7 +19,7 @@ gsutil.cmd -m cp -r gs://minikube-builds/$env:MINIKUBE_LOCATION/testdata .
./out/minikube-windows-amd64.exe delete
out/e2e-windows-amd64.exe -minikube-start-args="--driver=virtualbox" -expected-default-driver=hyperv -binary=out/minikube-windows-amd64.exe -test.v -test.timeout=30m
out/e2e-windows-amd64.exe -minikube-start-args="--driver=virtualbox" -binary=out/minikube-windows-amd64.exe -test.v -test.timeout=30m
$env:result=$lastexitcode
# If the last exit code was 0->success, x>0->error
If($env:result -eq 0){$env:status="success"}
......
......@@ -21,7 +21,6 @@ package integration
import (
"context"
"crypto/md5"
"encoding/json"
"fmt"
"io/ioutil"
"os"
......@@ -33,145 +32,119 @@ import (
"time"
"k8s.io/minikube/pkg/minikube/bootstrapper/images"
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/constants"
"k8s.io/minikube/pkg/minikube/download"
"k8s.io/minikube/pkg/minikube/localpath"
)
func TestDownloadOnly(t *testing.T) {
profile := UniqueProfileName("download")
ctx, cancel := context.WithTimeout(context.Background(), Minutes(15))
defer Cleanup(t, profile, cancel)
for _, r := range []string{"crio", "docker", "containerd"} {
t.Run(r, func(t *testing.T) {
// Stores the startup run result for later error messages
var rrr *RunResult
var err error
profile := UniqueProfileName(r)
ctx, cancel := context.WithTimeout(context.Background(), Minutes(30))
defer Cleanup(t, profile, cancel)
versions := []string{
constants.OldestKubernetesVersion,
constants.DefaultKubernetesVersion,
constants.NewestKubernetesVersion,
}
// Stores the startup run result for later error messages
var rrr *RunResult
var err error
for _, v := range versions {
t.Run(v, func(t *testing.T) {
// Explicitly does not pass StartArgs() to test driver default
// --force to avoid uid check
args := append([]string{"start", "--download-only", "-p", profile, "--force", "--alsologtostderr", fmt.Sprintf("--kubernetes-version=%s", v), fmt.Sprintf("--container-runtime=%s", r)}, StartArgs()...)
// Preserve the initial run-result for debugging
if rrr == nil {
rrr, err = Run(t, exec.CommandContext(ctx, Target(), args...))
} else {
_, err = Run(t, exec.CommandContext(ctx, Target(), args...))
}
t.Run("group", func(t *testing.T) {
versions := []string{
constants.OldestKubernetesVersion,
constants.DefaultKubernetesVersion,
constants.NewestKubernetesVersion,
}
for _, v := range versions {
t.Run(v, func(t *testing.T) {
// Explicitly does not pass StartArgs() to test driver default
// --force to avoid uid check
args := append([]string{"start", "--download-only", "-p", profile, "--force", "--alsologtostderr", fmt.Sprintf("--kubernetes-version=%s", v)}, StartArgs()...)
// Preserve the initial run-result for debugging
if rrr == nil {
rrr, err = Run(t, exec.CommandContext(ctx, Target(), args...))
} else {
_, err = Run(t, exec.CommandContext(ctx, Target(), args...))
}
if err != nil {
t.Errorf("%s failed: %v", args, err)
}
if err != nil {
t.Errorf("%s failed: %v", args, err)
}
if download.PreloadExists(v, r) {
// Just make sure the tarball path exists
if _, err := os.Stat(download.TarballPath(v)); err != nil {
t.Errorf("preloaded tarball path doesn't exist: %v", err)
}
return
}
if download.PreloadExists(v, "docker") {
// Just make sure the tarball path exists
if _, err := os.Stat(download.TarballPath(v)); err != nil {
t.Errorf("preloaded tarball path doesn't exist: %v", err)
imgs, err := images.Kubeadm("", v)
if err != nil {
t.Errorf("kubeadm images: %v %+v", v, err)
}
return
}
imgs, err := images.Kubeadm("", v)
if err != nil {
t.Errorf("kubeadm images: %v %+v", v, err)
}
// skip verify for cache images if --driver=none
if !NoneDriver() {
for _, img := range imgs {
img = strings.Replace(img, ":", "_", 1) // for example kube-scheduler:v1.15.2 --> kube-scheduler_v1.15.2
fp := filepath.Join(localpath.MiniPath(), "cache", "images", img)
_, err := os.Stat(fp)
if err != nil {
t.Errorf("expected image file exist at %q but got error: %v", fp, err)
}
}
}
// skip verify for cache images if --driver=none
if !NoneDriver() {
for _, img := range imgs {
img = strings.Replace(img, ":", "_", 1) // for example kube-scheduler:v1.15.2 --> kube-scheduler_v1.15.2
fp := filepath.Join(localpath.MiniPath(), "cache", "images", img)
// checking binaries downloaded (kubelet,kubeadm)
for _, bin := range constants.KubernetesReleaseBinaries {
fp := filepath.Join(localpath.MiniPath(), "cache", "linux", v, bin)
_, err := os.Stat(fp)
if err != nil {
t.Errorf("expected image file exist at %q but got error: %v", fp, err)
t.Errorf("expected the file for binary exist at %q but got error %v", fp, err)
}
}
}
// checking binaries downloaded (kubelet,kubeadm)
for _, bin := range constants.KubernetesReleaseBinaries {
fp := filepath.Join(localpath.MiniPath(), "cache", "linux", v, bin)
_, err := os.Stat(fp)
if err != nil {
// If we are on darwin/windows, check to make sure OS specific kubectl has been downloaded
// as well for the `minikube kubectl` command
if runtime.GOOS == "linux" {
return
}
binary := "kubectl"
if runtime.GOOS == "windows" {
binary = "kubectl.exe"
}
fp := filepath.Join(localpath.MiniPath(), "cache", runtime.GOOS, v, binary)
if _, err := os.Stat(fp); err != nil {
t.Errorf("expected the file for binary exist at %q but got error %v", fp, err)
}
}
})
}
// If we are on darwin/windows, check to make sure OS specific kubectl has been downloaded
// as well for the `minikube kubectl` command
if runtime.GOOS == "linux" {
return
}
binary := "kubectl"
if runtime.GOOS == "windows" {
binary = "kubectl.exe"
// This is a weird place to test profile deletion, but this test is serial, and we have a profile to delete!
t.Run("DeleteAll", func(t *testing.T) {
if !CanCleanup() {
t.Skip("skipping, as cleanup is disabled")
}
fp := filepath.Join(localpath.MiniPath(), "cache", runtime.GOOS, v, binary)
if _, err := os.Stat(fp); err != nil {
t.Errorf("expected the file for binary exist at %q but got error %v", fp, err)
rr, err := Run(t, exec.CommandContext(ctx, Target(), "delete", "--all"))
if err != nil {
t.Errorf("%s failed: %v", rr.Args, err)
}
})
}
// Check that the profile we've created has the expected driver
t.Run("ExpectedDefaultDriver", func(t *testing.T) {
if ExpectedDefaultDriver() == "" {
t.Skipf("--expected-default-driver is unset, skipping test")
return
}
rr, err := Run(t, exec.CommandContext(ctx, Target(), "profile", "list", "--output", "json"))
if err != nil {
t.Errorf("%s failed: %v", rr.Args, err)
}
var ps map[string][]config.Profile
err = json.Unmarshal(rr.Stdout.Bytes(), &ps)
if err != nil {
t.Errorf("%s failed: %v", rr.Args, err)
}
got := ""
for _, p := range ps["valid"] {
if p.Name == profile {
got = p.Config.Driver
// Delete should always succeed, even if previously partially or fully deleted.
t.Run("DeleteAlwaysSucceeds", func(t *testing.T) {
if !CanCleanup() {
t.Skip("skipping, as cleanup is disabled")
}
}
if got != ExpectedDefaultDriver() {
t.Errorf("got driver %q, expected %q\nstart output: %s", got, ExpectedDefaultDriver(), rrr.Output())
}
})
// This is a weird place to test profile deletion, but this test is serial, and we have a profile to delete!
t.Run("DeleteAll", func(t *testing.T) {
if !CanCleanup() {
t.Skip("skipping, as cleanup is disabled")
}
rr, err := Run(t, exec.CommandContext(ctx, Target(), "delete", "--all"))
if err != nil {
t.Errorf("%s failed: %v", rr.Args, err)
}
})
// Delete should always succeed, even if previously partially or fully deleted.
t.Run("DeleteAlwaysSucceeds", func(t *testing.T) {
if !CanCleanup() {
t.Skip("skipping, as cleanup is disabled")
}
rr, err := Run(t, exec.CommandContext(ctx, Target(), "delete", "-p", profile))
if err != nil {
t.Errorf("%s failed: %v", rr.Args, err)
}
rr, err := Run(t, exec.CommandContext(ctx, Target(), "delete", "-p", profile))
if err != nil {
t.Errorf("%s failed: %v", rr.Args, err)
}
})
})
})
}
}
func TestDownloadOnlyDocker(t *testing.T) {
if !runningDockerDriver(StartArgs()) {
t.Skip("this test only runs with the docker driver")
......
......@@ -27,7 +27,6 @@ import (
// General configuration: used to set the VM Driver
var startArgs = flag.String("minikube-start-args", "", "Arguments to pass to minikube start")
var defaultDriver = flag.String("expected-default-driver", "", "Expected default driver")
// Flags for faster local integration testing
var forceProfile = flag.String("profile", "", "force tests to run against a particular profile")
......@@ -69,11 +68,6 @@ func HyperVDriver() bool {
return strings.Contains(*startArgs, "--driver=hyperv")
}
// ExpectedDefaultDriver returns the expected default driver, if any
func ExpectedDefaultDriver() string {
return *defaultDriver
}
// CanCleanup returns if cleanup is allowed
func CanCleanup() bool {
return *cleanup
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册