提交 e30fe107 编写于 作者: J josedonizetti

Add debugging information

上级 44889de3
......@@ -17,6 +17,7 @@ limitations under the License.
package drivers
import (
"fmt"
"io"
"io/ioutil"
"os"
......@@ -168,6 +169,8 @@ func InstallOrUpdate(driver, destination string, minikubeVersion semver.Version)
v := ExtractVMDriverVersion(string(output))
fmt.Printf("InstallOrUpdate extracted version %s\n", v)
// if the driver doesn't return any version, download it
if len(v) == 0 {
return download(driver, destination)
......@@ -178,6 +181,7 @@ func InstallOrUpdate(driver, destination string, minikubeVersion semver.Version)
return errors.Wrap(err, "can't parse driver version")
}
fmt.Printf("InstallOrUpdate version %s\n", minikubeVersion.String())
// if the current driver version is older, download newer
if vmDriverVersion.LT(minikubeVersion) {
return download(driver, destination)
......
......@@ -20,7 +20,7 @@ import (
"fmt"
"io/ioutil"
"os"
"path"
"path/filepath"
"runtime"
"testing"
......@@ -42,8 +42,16 @@ func TestDriverInstallOrUpdate(t *testing.T) {
name string
path string
}{
{name: "driver-without-version-support", path: path.Join(*testdataDir, "kvm2-driver-without-version")},
{name: "driver-with-older-version", path: path.Join(*testdataDir, "kvm2-driver-without-version")},
{name: "driver-without-version-support", path: filepath.Join(*testdataDir, "kvm2-driver-without-version")},
{name: "driver-with-older-version", path: filepath.Join(*testdataDir, "kvm2-driver-without-version")},
}
ingressPath := filepath.Join(*testdataDir, "nginx-ing.yaml")
_, err := os.Stat(ingressPath)
if err != nil {
t.Fatalf("Expected ingress-ing to exist. test: %s, got: %v", "TestDriverInstallOrUpdate", err)
} else {
fmt.Printf("TestDriverInstallOrUpdate ingress exist at: %s\n", ingressPath)
}
for _, tc := range tests {
......@@ -53,6 +61,11 @@ func TestDriverInstallOrUpdate(t *testing.T) {
}
defer os.RemoveAll(dir)
_, err = os.Stat(filepath.Join(tc.path, "docker-machine-driver-kvm2"))
if err != nil {
t.Fatalf("Expected driver to exist. test: %s, got: %v", tc.name, err)
}
os.Setenv("PATH", fmt.Sprintf("%s:%s", tc.path, os.Getenv("PATH")))
newerVersion, err := semver.Make("1.1.3")
......@@ -65,7 +78,7 @@ func TestDriverInstallOrUpdate(t *testing.T) {
t.Fatalf("Expected to update driver. test: %s, got: %v", tc.name, err)
}
_, err = os.Stat(path.Join(dir, "docker-machine-driver-kvm2"))
_, err = os.Stat(filepath.Join(dir, "docker-machine-driver-kvm2"))
if err != nil {
t.Fatalf("Expected driver to be download. test: %s, got: %v", tc.name, err)
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册