Skip to content

Commit 416f132

Browse files
committed
Pass --expected-default-driver to the test rather than minikube
Improve VBoxManage detection on Windows Add missing install_test
1 parent d3618fb commit 416f132

File tree

4 files changed

+61
-6
lines changed

4 files changed

+61
-6
lines changed

cmd/minikube/cmd/start.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ func selectDriver(oldConfig *cfg.Config) string {
552552
}
553553

554554
if pick.Name == "" {
555-
exit.WithCodeT(exit.Config, "Unable to determine a default driver to use. Try specifying --vm-driver, or visiting https://minikube.sigs.k8s.io/docs/start/")
555+
exit.WithCodeT(exit.Config, "Unable to determine a default driver to use. Try specifying --vm-driver, or see https://minikube.sigs.k8s.io/docs/start/")
556556
}
557557

558558
name = pick.Name

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 -minikube-start-args="--vm-driver=hyperv --expected-default-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 --expected-default-driver=hyperv -minikube-start-args="--vm-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"}

pkg/minikube/driver/install_test.go

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
Copyright 2019 The Kubernetes Authors All rights reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package driver
18+
19+
import (
20+
"testing"
21+
)
22+
23+
func TestExtractVMDriverVersion(t *testing.T) {
24+
v := extractVMDriverVersion("")
25+
if len(v) != 0 {
26+
t.Error("Expected empty string")
27+
}
28+
29+
v = extractVMDriverVersion("random text")
30+
if len(v) != 0 {
31+
t.Error("Expected empty string")
32+
}
33+
34+
expectedVersion := "1.2.3"
35+
36+
v = extractVMDriverVersion("version: v1.2.3")
37+
if expectedVersion != v {
38+
t.Errorf("Expected version: %s, got: %s", expectedVersion, v)
39+
}
40+
41+
v = extractVMDriverVersion("version: 1.2.3")
42+
if expectedVersion != v {
43+
t.Errorf("Expected version: %s, got: %s", expectedVersion, v)
44+
}
45+
}

pkg/minikube/registry/drvs/virtualbox/virtualbox.go

+14-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323

2424
"github.com/docker/machine/drivers/virtualbox"
2525
"github.com/docker/machine/libmachine/drivers"
26-
"github.com/pkg/errors"
2726

2827
"k8s.io/minikube/pkg/minikube/config"
2928
"k8s.io/minikube/pkg/minikube/driver"
@@ -66,15 +65,26 @@ func configure(mc config.MachineConfig) interface{} {
6665
}
6766

6867
func status() registry.State {
69-
path, err := exec.LookPath("vboxmanage")
68+
// Re-use this function as it's particularly helpful for Windows
69+
tryPath := driver.VBoxManagePath()
70+
path, err := exec.LookPath(tryPath)
7071
if err != nil {
71-
return registry.State{Error: errors.Wrap(err, "vboxmanage path check"), Fix: "Install VirtualBox", Doc: docURL}
72+
return registry.State{
73+
Error: fmt.Errorf("unable to find VBoxManage in $PATH"),
74+
Fix: "Install VirtualBox",
75+
Doc: docURL,
76+
}
7277
}
7378

7479
cmd := exec.Command(path, "list", "hostinfo")
7580
out, err := cmd.CombinedOutput()
7681
if err != nil {
77-
return registry.State{Installed: true, Error: fmt.Errorf("%s failed:\n%s", strings.Join(cmd.Args, " "), out), Fix: "Install the latest version of VirtualBox", Doc: docURL}
82+
return registry.State{
83+
Installed: true,
84+
Error: fmt.Errorf("%s failed:\n%s", strings.Join(cmd.Args, " "), out),
85+
Fix: "Install the latest version of VirtualBox",
86+
Doc: docURL,
87+
}
7888
}
7989

8090
return registry.State{Installed: true, Healthy: true}

0 commit comments

Comments
 (0)