Pass --expected-default-driver to the test rather than minikube

Improve VBoxManage detection on Windows

Add missing install_test
pull/5700/head
tstromberg 2019-10-25 10:05:43 -07:00
parent d3618fb94c
commit 416f132ebb
4 changed files with 61 additions and 6 deletions

View File

@ -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

View File

@ -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"}

View File

@ -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)
}
}

View File

@ -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"
@ -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}