Skip to content

Commit 8e9d8a2

Browse files
authored
Merge pull request #7134 from tstromberg/test-download-only
download_only_test: Fix non-docker runtimes, remove expected-driver test
2 parents 78495e6 + 17e6d84 commit 8e9d8a2

5 files changed

+88
-122
lines changed

hack/jenkins/common.sh

-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,6 @@ fi
286286
touch "${TEST_OUT}"
287287
${SUDO_PREFIX}${E2E_BIN} \
288288
-minikube-start-args="--driver=${VM_DRIVER} ${EXTRA_START_ARGS}" \
289-
-expected-default-driver="${EXPECTED_DEFAULT_DRIVER}" \
290289
-test.timeout=70m -test.v \
291290
${EXTRA_TEST_ARGS} \
292291
-binary="${MINIKUBE_BIN}" 2>&1 | tee "${TEST_OUT}"

hack/jenkins/windows_integration_test_hyperv.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ gsutil.cmd -m cp -r gs://minikube-builds/$env:MINIKUBE_LOCATION/testdata .
1919

2020
./out/minikube-windows-amd64.exe delete
2121

22-
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
22+
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
2323
$env:result=$lastexitcode
2424
# If the last exit code was 0->success, x>0->error
2525
If($env:result -eq 0){$env:status="success"}

hack/jenkins/windows_integration_test_virtualbox.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ gsutil.cmd -m cp -r gs://minikube-builds/$env:MINIKUBE_LOCATION/testdata .
1919

2020
./out/minikube-windows-amd64.exe delete
2121

22-
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
22+
out/e2e-windows-amd64.exe -minikube-start-args="--driver=virtualbox" -binary=out/minikube-windows-amd64.exe -test.v -test.timeout=30m
2323
$env:result=$lastexitcode
2424
# If the last exit code was 0->success, x>0->error
2525
If($env:result -eq 0){$env:status="success"}

test/integration/aaa_download_only_test.go

+86-113
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ package integration
2121
import (
2222
"context"
2323
"crypto/md5"
24-
"encoding/json"
2524
"fmt"
2625
"io/ioutil"
2726
"os"
@@ -33,145 +32,119 @@ import (
3332
"time"
3433

3534
"k8s.io/minikube/pkg/minikube/bootstrapper/images"
36-
"k8s.io/minikube/pkg/minikube/config"
3735
"k8s.io/minikube/pkg/minikube/constants"
3836
"k8s.io/minikube/pkg/minikube/download"
3937
"k8s.io/minikube/pkg/minikube/localpath"
4038
)
4139

4240
func TestDownloadOnly(t *testing.T) {
43-
profile := UniqueProfileName("download")
44-
ctx, cancel := context.WithTimeout(context.Background(), Minutes(15))
45-
defer Cleanup(t, profile, cancel)
41+
for _, r := range []string{"crio", "docker", "containerd"} {
42+
t.Run(r, func(t *testing.T) {
43+
// Stores the startup run result for later error messages
44+
var rrr *RunResult
45+
var err error
46+
47+
profile := UniqueProfileName(r)
48+
ctx, cancel := context.WithTimeout(context.Background(), Minutes(30))
49+
defer Cleanup(t, profile, cancel)
50+
51+
versions := []string{
52+
constants.OldestKubernetesVersion,
53+
constants.DefaultKubernetesVersion,
54+
constants.NewestKubernetesVersion,
55+
}
4656

47-
// Stores the startup run result for later error messages
48-
var rrr *RunResult
49-
var err error
57+
for _, v := range versions {
58+
t.Run(v, func(t *testing.T) {
59+
// Explicitly does not pass StartArgs() to test driver default
60+
// --force to avoid uid check
61+
args := append([]string{"start", "--download-only", "-p", profile, "--force", "--alsologtostderr", fmt.Sprintf("--kubernetes-version=%s", v), fmt.Sprintf("--container-runtime=%s", r)}, StartArgs()...)
62+
63+
// Preserve the initial run-result for debugging
64+
if rrr == nil {
65+
rrr, err = Run(t, exec.CommandContext(ctx, Target(), args...))
66+
} else {
67+
_, err = Run(t, exec.CommandContext(ctx, Target(), args...))
68+
}
5069

51-
t.Run("group", func(t *testing.T) {
52-
versions := []string{
53-
constants.OldestKubernetesVersion,
54-
constants.DefaultKubernetesVersion,
55-
constants.NewestKubernetesVersion,
56-
}
57-
for _, v := range versions {
58-
t.Run(v, func(t *testing.T) {
59-
// Explicitly does not pass StartArgs() to test driver default
60-
// --force to avoid uid check
61-
args := append([]string{"start", "--download-only", "-p", profile, "--force", "--alsologtostderr", fmt.Sprintf("--kubernetes-version=%s", v)}, StartArgs()...)
62-
63-
// Preserve the initial run-result for debugging
64-
if rrr == nil {
65-
rrr, err = Run(t, exec.CommandContext(ctx, Target(), args...))
66-
} else {
67-
_, err = Run(t, exec.CommandContext(ctx, Target(), args...))
68-
}
70+
if err != nil {
71+
t.Errorf("%s failed: %v", args, err)
72+
}
6973

70-
if err != nil {
71-
t.Errorf("%s failed: %v", args, err)
72-
}
74+
if download.PreloadExists(v, r) {
75+
// Just make sure the tarball path exists
76+
if _, err := os.Stat(download.TarballPath(v)); err != nil {
77+
t.Errorf("preloaded tarball path doesn't exist: %v", err)
78+
}
79+
return
80+
}
7381

74-
if download.PreloadExists(v, "docker") {
75-
// Just make sure the tarball path exists
76-
if _, err := os.Stat(download.TarballPath(v)); err != nil {
77-
t.Errorf("preloaded tarball path doesn't exist: %v", err)
82+
imgs, err := images.Kubeadm("", v)
83+
if err != nil {
84+
t.Errorf("kubeadm images: %v %+v", v, err)
7885
}
79-
return
80-
}
8186

82-
imgs, err := images.Kubeadm("", v)
83-
if err != nil {
84-
t.Errorf("kubeadm images: %v %+v", v, err)
85-
}
87+
// skip verify for cache images if --driver=none
88+
if !NoneDriver() {
89+
for _, img := range imgs {
90+
img = strings.Replace(img, ":", "_", 1) // for example kube-scheduler:v1.15.2 --> kube-scheduler_v1.15.2
91+
fp := filepath.Join(localpath.MiniPath(), "cache", "images", img)
92+
_, err := os.Stat(fp)
93+
if err != nil {
94+
t.Errorf("expected image file exist at %q but got error: %v", fp, err)
95+
}
96+
}
97+
}
8698

87-
// skip verify for cache images if --driver=none
88-
if !NoneDriver() {
89-
for _, img := range imgs {
90-
img = strings.Replace(img, ":", "_", 1) // for example kube-scheduler:v1.15.2 --> kube-scheduler_v1.15.2
91-
fp := filepath.Join(localpath.MiniPath(), "cache", "images", img)
99+
// checking binaries downloaded (kubelet,kubeadm)
100+
for _, bin := range constants.KubernetesReleaseBinaries {
101+
fp := filepath.Join(localpath.MiniPath(), "cache", "linux", v, bin)
92102
_, err := os.Stat(fp)
93103
if err != nil {
94-
t.Errorf("expected image file exist at %q but got error: %v", fp, err)
104+
t.Errorf("expected the file for binary exist at %q but got error %v", fp, err)
95105
}
96106
}
97-
}
98107

99-
// checking binaries downloaded (kubelet,kubeadm)
100-
for _, bin := range constants.KubernetesReleaseBinaries {
101-
fp := filepath.Join(localpath.MiniPath(), "cache", "linux", v, bin)
102-
_, err := os.Stat(fp)
103-
if err != nil {
108+
// If we are on darwin/windows, check to make sure OS specific kubectl has been downloaded
109+
// as well for the `minikube kubectl` command
110+
if runtime.GOOS == "linux" {
111+
return
112+
}
113+
binary := "kubectl"
114+
if runtime.GOOS == "windows" {
115+
binary = "kubectl.exe"
116+
}
117+
fp := filepath.Join(localpath.MiniPath(), "cache", runtime.GOOS, v, binary)
118+
if _, err := os.Stat(fp); err != nil {
104119
t.Errorf("expected the file for binary exist at %q but got error %v", fp, err)
105120
}
106-
}
121+
})
122+
}
107123

108-
// If we are on darwin/windows, check to make sure OS specific kubectl has been downloaded
109-
// as well for the `minikube kubectl` command
110-
if runtime.GOOS == "linux" {
111-
return
112-
}
113-
binary := "kubectl"
114-
if runtime.GOOS == "windows" {
115-
binary = "kubectl.exe"
124+
// This is a weird place to test profile deletion, but this test is serial, and we have a profile to delete!
125+
t.Run("DeleteAll", func(t *testing.T) {
126+
if !CanCleanup() {
127+
t.Skip("skipping, as cleanup is disabled")
116128
}
117-
fp := filepath.Join(localpath.MiniPath(), "cache", runtime.GOOS, v, binary)
118-
if _, err := os.Stat(fp); err != nil {
119-
t.Errorf("expected the file for binary exist at %q but got error %v", fp, err)
129+
rr, err := Run(t, exec.CommandContext(ctx, Target(), "delete", "--all"))
130+
if err != nil {
131+
t.Errorf("%s failed: %v", rr.Args, err)
120132
}
121133
})
122-
}
123-
124-
// Check that the profile we've created has the expected driver
125-
t.Run("ExpectedDefaultDriver", func(t *testing.T) {
126-
if ExpectedDefaultDriver() == "" {
127-
t.Skipf("--expected-default-driver is unset, skipping test")
128-
return
129-
}
130-
rr, err := Run(t, exec.CommandContext(ctx, Target(), "profile", "list", "--output", "json"))
131-
if err != nil {
132-
t.Errorf("%s failed: %v", rr.Args, err)
133-
}
134-
var ps map[string][]config.Profile
135-
err = json.Unmarshal(rr.Stdout.Bytes(), &ps)
136-
if err != nil {
137-
t.Errorf("%s failed: %v", rr.Args, err)
138-
}
139-
140-
got := ""
141-
for _, p := range ps["valid"] {
142-
if p.Name == profile {
143-
got = p.Config.Driver
134+
// Delete should always succeed, even if previously partially or fully deleted.
135+
t.Run("DeleteAlwaysSucceeds", func(t *testing.T) {
136+
if !CanCleanup() {
137+
t.Skip("skipping, as cleanup is disabled")
144138
}
145-
}
146-
147-
if got != ExpectedDefaultDriver() {
148-
t.Errorf("got driver %q, expected %q\nstart output: %s", got, ExpectedDefaultDriver(), rrr.Output())
149-
}
150-
})
151-
152-
// This is a weird place to test profile deletion, but this test is serial, and we have a profile to delete!
153-
t.Run("DeleteAll", func(t *testing.T) {
154-
if !CanCleanup() {
155-
t.Skip("skipping, as cleanup is disabled")
156-
}
157-
rr, err := Run(t, exec.CommandContext(ctx, Target(), "delete", "--all"))
158-
if err != nil {
159-
t.Errorf("%s failed: %v", rr.Args, err)
160-
}
161-
})
162-
// Delete should always succeed, even if previously partially or fully deleted.
163-
t.Run("DeleteAlwaysSucceeds", func(t *testing.T) {
164-
if !CanCleanup() {
165-
t.Skip("skipping, as cleanup is disabled")
166-
}
167-
rr, err := Run(t, exec.CommandContext(ctx, Target(), "delete", "-p", profile))
168-
if err != nil {
169-
t.Errorf("%s failed: %v", rr.Args, err)
170-
}
139+
rr, err := Run(t, exec.CommandContext(ctx, Target(), "delete", "-p", profile))
140+
if err != nil {
141+
t.Errorf("%s failed: %v", rr.Args, err)
142+
}
143+
})
171144
})
172-
})
173-
145+
}
174146
}
147+
175148
func TestDownloadOnlyDocker(t *testing.T) {
176149
if !runningDockerDriver(StartArgs()) {
177150
t.Skip("this test only runs with the docker driver")

test/integration/main.go

-6
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import (
2727

2828
// General configuration: used to set the VM Driver
2929
var startArgs = flag.String("minikube-start-args", "", "Arguments to pass to minikube start")
30-
var defaultDriver = flag.String("expected-default-driver", "", "Expected default driver")
3130

3231
// Flags for faster local integration testing
3332
var forceProfile = flag.String("profile", "", "force tests to run against a particular profile")
@@ -69,11 +68,6 @@ func HyperVDriver() bool {
6968
return strings.Contains(*startArgs, "--driver=hyperv")
7069
}
7170

72-
// ExpectedDefaultDriver returns the expected default driver, if any
73-
func ExpectedDefaultDriver() string {
74-
return *defaultDriver
75-
}
76-
7771
// CanCleanup returns if cleanup is allowed
7872
func CanCleanup() bool {
7973
return *cleanup

0 commit comments

Comments
 (0)