Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Chu Peng 楚鹏
minikube
提交
0cf4921c
M
minikube
项目概览
Chu Peng 楚鹏
/
minikube
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
minikube
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
0cf4921c
编写于
9月 04, 2019
作者:
J
josedonizetti
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add drivers.InstallOrUpdate acceptance tests
上级
30e75c3c
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
72 addition
and
3 deletion
+72
-3
cmd/minikube/cmd/start.go
cmd/minikube/cmd/start.go
+1
-1
pkg/drivers/drivers.go
pkg/drivers/drivers.go
+2
-2
test/integration/driver_update_test.go
test/integration/driver_update_test.go
+69
-0
test/integration/testdata/kvm2-driver-older-version/docker-machine-driver-kvm2
...data/kvm2-driver-older-version/docker-machine-driver-kvm2
+0
-0
test/integration/testdata/kvm2-driver-without-version/docker-machine-driver-kvm2
...ta/kvm2-driver-without-version/docker-machine-driver-kvm2
+0
-0
未找到文件。
cmd/minikube/cmd/start.go
浏览文件 @
0cf4921c
...
...
@@ -1038,7 +1038,7 @@ func validateDriverVersion(vmDriver string) {
case
constants
.
DriverKvm2
:
driverExecutable
=
fmt
.
Sprintf
(
"docker-machine-driver-%s"
,
constants
.
DriverKvm2
)
targetDir
:=
constants
.
MakeMiniPath
(
"bin"
)
err
:=
drivers
.
Download
(
driverExecutable
,
targetDir
,
minikubeVersion
)
err
:=
drivers
.
InstallOrUpdate
(
driverExecutable
,
targetDir
,
minikubeVersion
)
if
err
!=
nil
{
out
.
WarningT
(
"Error downloading driver: {{.error}}"
,
out
.
V
{
"error"
:
err
})
}
...
...
pkg/drivers/drivers.go
浏览文件 @
0cf4921c
...
...
@@ -151,8 +151,8 @@ func fixPermissions(path string) error {
return
nil
}
//
Download downloads driver if it is not present, or if the version is old
func
Download
(
driver
,
destination
string
,
minikubeVersion
semver
.
Version
)
error
{
//
InstallOrUpdate downloads driver if it is not present, or updates it if there's a newer version
func
InstallOrUpdate
(
driver
,
destination
string
,
minikubeVersion
semver
.
Version
)
error
{
_
,
err
:=
exec
.
LookPath
(
driver
)
// if file driver doesn't exist, download it
if
err
!=
nil
{
...
...
test/integration/driver_update_test.go
0 → 100644
浏览文件 @
0cf4921c
/*
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
integration
import
(
"fmt"
"io/ioutil"
"os"
"path"
"runtime"
"testing"
"github.com/blang/semver"
"k8s.io/minikube/pkg/drivers"
)
func
TestDriverInstallOrUpdate
(
t
*
testing
.
T
)
{
if
runtime
.
GOOS
!=
"linux"
{
t
.
Skip
()
}
tests
:=
[]
struct
{
name
string
path
string
}{
{
name
:
"driver-without-version-support"
,
path
:
"./testdata/kvm2-driver-without-version"
},
{
name
:
"driver-with-older-version"
,
path
:
"./testdata/kvm2-driver-without-version"
},
}
for
_
,
tc
:=
range
tests
{
dir
,
err
:=
ioutil
.
TempDir
(
""
,
tc
.
name
)
if
err
!=
nil
{
t
.
Fatalf
(
"Expected to create tempdir. test: %s, got: %v"
,
tc
.
name
,
err
)
}
defer
os
.
RemoveAll
(
dir
)
os
.
Setenv
(
"PATH"
,
fmt
.
Sprintf
(
"%s:%s"
,
tc
.
path
,
os
.
Getenv
(
"PATH"
)))
newerVersion
,
err
:=
semver
.
Make
(
"1.1.3"
)
if
err
!=
nil
{
t
.
Fatalf
(
"Expected new semver. test: %v, got: %v"
,
tc
.
name
,
err
)
}
err
=
drivers
.
InstallOrUpdate
(
"docker-machine-driver-kvm2"
,
dir
,
newerVersion
)
if
err
!=
nil
{
t
.
Fatalf
(
"Expected to update driver. test: %s, got: %v"
,
tc
.
name
,
err
)
}
_
,
err
=
os
.
Stat
(
path
.
Join
(
dir
,
"docker-machine-driver-kvm2"
))
if
err
!=
nil
{
t
.
Fatalf
(
"Expected driver to be download. test: %s, got: %v"
,
tc
.
name
,
err
)
}
}
}
test/integration/testdata/kvm2-driver-older-version/docker-machine-driver-kvm2
0 → 100755
浏览文件 @
0cf4921c
文件已添加
test/integration/testdata/kvm2-driver-without-version/docker-machine-driver-kvm2
0 → 100755
浏览文件 @
0cf4921c
文件已添加
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录