Skip to content

Commit

Permalink
Pass --expected-default-driver to the test rather than minikube
Browse files Browse the repository at this point in the history
Improve VBoxManage detection on Windows

Add missing install_test
  • Loading branch information
tstromberg committed Oct 25, 2019
1 parent d3618fb commit 416f132
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ func selectDriver(oldConfig *cfg.Config) string {
}

if pick.Name == "" {
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/")
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/")
}

name = pick.Name
Expand Down
2 changes: 1 addition & 1 deletion hack/jenkins/windows_integration_test_hyperv.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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="--vm-driver=hyperv --expected-default-driver=hyperv --hyperv-virtual-switch=primary-virtual-switch" -binary=out/minikube-windows-amd64.exe -test.v -test.timeout=65m
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
$env:result=$lastexitcode
# If the last exit code was 0->success, x>0->error
If($env:result -eq 0){$env:status="success"}
Expand Down
45 changes: 45 additions & 0 deletions pkg/minikube/driver/install_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
Copyright 2019 The Kubernetes Authors All rights reserved.
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
http://www.apache.org/licenses/LICENSE-2.0
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 driver

import (
"testing"
)

func TestExtractVMDriverVersion(t *testing.T) {
v := extractVMDriverVersion("")
if len(v) != 0 {
t.Error("Expected empty string")
}

v = extractVMDriverVersion("random text")
if len(v) != 0 {
t.Error("Expected empty string")
}

expectedVersion := "1.2.3"

v = extractVMDriverVersion("version: v1.2.3")
if expectedVersion != v {
t.Errorf("Expected version: %s, got: %s", expectedVersion, v)
}

v = extractVMDriverVersion("version: 1.2.3")
if expectedVersion != v {
t.Errorf("Expected version: %s, got: %s", expectedVersion, v)
}
}
18 changes: 14 additions & 4 deletions pkg/minikube/registry/drvs/virtualbox/virtualbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (

"github.com/docker/machine/drivers/virtualbox"
"github.com/docker/machine/libmachine/drivers"
"github.com/pkg/errors"

"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/driver"
Expand Down Expand Up @@ -66,15 +65,26 @@ func configure(mc config.MachineConfig) interface{} {
}

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

cmd := exec.Command(path, "list", "hostinfo")
out, err := cmd.CombinedOutput()
if err != nil {
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}
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,
}
}

return registry.State{Installed: true, Healthy: true}
Expand Down

0 comments on commit 416f132

Please sign in to comment.