Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Chu Peng 楚鹏
minikube
提交
c42ecf95
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,发现更多精彩内容 >>
提交
c42ecf95
编写于
3月 21, 2020
作者:
T
Thomas Stromberg
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Download dependencies for non-Docker runtimes
上级
75f2f914
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
110 addition
and
107 deletion
+110
-107
test/integration/aaa_download_only_test.go
test/integration/aaa_download_only_test.go
+110
-107
未找到文件。
test/integration/aaa_download_only_test.go
浏览文件 @
c42ecf95
...
...
@@ -40,138 +40,141 @@ import (
)
func
TestDownloadOnly
(
t
*
testing
.
T
)
{
profile
:=
UniqueProfileName
(
"download"
)
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
Minutes
(
15
))
defer
Cleanup
(
t
,
profile
,
cancel
)
for
_
,
r
:=
range
[]
string
{
"crio"
,
"docker"
,
"containerd"
}
{
t
.
Run
(
r
,
func
(
t
*
testing
.
T
)
{
// Stores the startup run result for later error messages
var
rrr
*
RunResult
var
err
error
profile
:=
UniqueProfileName
(
r
)
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
Minutes
(
30
))
defer
Cleanup
(
t
,
profile
,
cancel
)
versions
:=
[]
string
{
constants
.
OldestKubernetesVersion
,
constants
.
DefaultKubernetesVersion
,
constants
.
NewestKubernetesVersion
,
}
// Stores the startup run result for later error messages
var
rrr
*
RunResult
var
err
error
for
_
,
v
:=
range
versions
{
t
.
Run
(
v
,
func
(
t
*
testing
.
T
)
{
// Explicitly does not pass StartArgs() to test driver default
// --force to avoid uid check
args
:=
append
([]
string
{
"start"
,
"--download-only"
,
"-p"
,
profile
,
"--force"
,
"--alsologtostderr"
,
fmt
.
Sprintf
(
"--kubernetes-version=%s"
,
v
),
fmt
.
Sprintf
(
"--container-runtime=%s"
,
r
)},
StartArgs
()
...
)
// Preserve the initial run-result for debugging
if
rrr
==
nil
{
rrr
,
err
=
Run
(
t
,
exec
.
CommandContext
(
ctx
,
Target
(),
args
...
))
}
else
{
_
,
err
=
Run
(
t
,
exec
.
CommandContext
(
ctx
,
Target
(),
args
...
))
}
t
.
Run
(
"group"
,
func
(
t
*
testing
.
T
)
{
versions
:=
[]
string
{
constants
.
OldestKubernetesVersion
,
constants
.
DefaultKubernetesVersion
,
constants
.
NewestKubernetesVersion
,
}
for
_
,
v
:=
range
versions
{
t
.
Run
(
v
,
func
(
t
*
testing
.
T
)
{
// Explicitly does not pass StartArgs() to test driver default
// --force to avoid uid check
args
:=
append
([]
string
{
"start"
,
"--download-only"
,
"-p"
,
profile
,
"--force"
,
"--alsologtostderr"
,
fmt
.
Sprintf
(
"--kubernetes-version=%s"
,
v
)},
StartArgs
()
...
)
// Preserve the initial run-result for debugging
if
rrr
==
nil
{
rrr
,
err
=
Run
(
t
,
exec
.
CommandContext
(
ctx
,
Target
(),
args
...
))
}
else
{
_
,
err
=
Run
(
t
,
exec
.
CommandContext
(
ctx
,
Target
(),
args
...
))
}
if
err
!=
nil
{
t
.
Errorf
(
"%s failed: %v"
,
args
,
err
)
}
if
err
!=
nil
{
t
.
Errorf
(
"%s failed: %v"
,
args
,
err
)
}
if
download
.
PreloadExists
(
v
,
"docker"
)
{
// Just make sure the tarball path exists
if
_
,
err
:=
os
.
Stat
(
download
.
TarballPath
(
v
));
err
!=
nil
{
t
.
Errorf
(
"preloaded tarball path doesn't exist: %v"
,
err
)
}
return
}
if
download
.
PreloadExists
(
v
,
"docker"
)
{
// Just make sure the tarball path exists
if
_
,
err
:=
os
.
Stat
(
download
.
TarballPath
(
v
));
err
!=
nil
{
t
.
Errorf
(
"preloaded tarball path doesn't exist: %v"
,
err
)
imgs
,
err
:=
images
.
Kubeadm
(
""
,
v
)
if
err
!=
nil
{
t
.
Errorf
(
"kubeadm images: %v %+v"
,
v
,
err
)
}
return
}
imgs
,
err
:=
images
.
Kubeadm
(
""
,
v
)
if
err
!=
nil
{
t
.
Errorf
(
"kubeadm images: %v %+v"
,
v
,
err
)
}
// skip verify for cache images if --driver=none
if
!
NoneDriver
()
{
for
_
,
img
:=
range
imgs
{
img
=
strings
.
Replace
(
img
,
":"
,
"_"
,
1
)
// for example kube-scheduler:v1.15.2 --> kube-scheduler_v1.15.2
fp
:=
filepath
.
Join
(
localpath
.
MiniPath
(),
"cache"
,
"images"
,
img
)
_
,
err
:=
os
.
Stat
(
fp
)
if
err
!=
nil
{
t
.
Errorf
(
"expected image file exist at %q but got error: %v"
,
fp
,
err
)
}
}
}
// skip verify for cache images if --driver=none
if
!
NoneDriver
()
{
for
_
,
img
:=
range
imgs
{
img
=
strings
.
Replace
(
img
,
":"
,
"_"
,
1
)
// for example kube-scheduler:v1.15.2 --> kube-scheduler_v1.15.2
fp
:=
filepath
.
Join
(
localpath
.
MiniPath
(),
"cache"
,
"images"
,
img
)
// checking binaries downloaded (kubelet,kubeadm)
for
_
,
bin
:=
range
constants
.
KubernetesReleaseBinaries
{
fp
:=
filepath
.
Join
(
localpath
.
MiniPath
(),
"cache"
,
"linux"
,
v
,
bin
)
_
,
err
:=
os
.
Stat
(
fp
)
if
err
!=
nil
{
t
.
Errorf
(
"expected
image file exist at %q but got error:
%v"
,
fp
,
err
)
t
.
Errorf
(
"expected
the file for binary exist at %q but got error
%v"
,
fp
,
err
)
}
}
}
// checking binaries downloaded (kubelet,kubeadm)
for
_
,
bin
:=
range
constants
.
KubernetesReleaseBinaries
{
fp
:=
filepath
.
Join
(
localpath
.
MiniPath
(),
"cache"
,
"linux"
,
v
,
bin
)
_
,
err
:=
os
.
Stat
(
fp
)
if
err
!=
nil
{
// If we are on darwin/windows, check to make sure OS specific kubectl has been downloaded
// as well for the `minikube kubectl` command
if
runtime
.
GOOS
==
"linux"
{
return
}
binary
:=
"kubectl"
if
runtime
.
GOOS
==
"windows"
{
binary
=
"kubectl.exe"
}
fp
:=
filepath
.
Join
(
localpath
.
MiniPath
(),
"cache"
,
runtime
.
GOOS
,
v
,
binary
)
if
_
,
err
:=
os
.
Stat
(
fp
);
err
!=
nil
{
t
.
Errorf
(
"expected the file for binary exist at %q but got error %v"
,
fp
,
err
)
}
}
})
}
// If we are on darwin/windows, check to make sure OS specific kubectl has been downloaded
// as well for the `minikube kubectl` command
if
runtime
.
GOOS
==
"linux"
{
// Check that the profile we've created has the expected driver
t
.
Run
(
"ExpectedDefaultDriver"
,
func
(
t
*
testing
.
T
)
{
if
ExpectedDefaultDriver
()
==
""
{
t
.
Skipf
(
"--expected-default-driver is unset, skipping test"
)
return
}
binary
:=
"kubectl"
if
runtime
.
GOOS
==
"windows"
{
binary
=
"kubectl.exe"
rr
,
err
:=
Run
(
t
,
exec
.
CommandContext
(
ctx
,
Target
(),
"profile"
,
"list"
,
"--output"
,
"json"
))
if
err
!=
nil
{
t
.
Errorf
(
"%s failed: %v"
,
rr
.
Args
,
err
)
}
fp
:=
filepath
.
Join
(
localpath
.
MiniPath
(),
"cache"
,
runtime
.
GOOS
,
v
,
binary
)
if
_
,
err
:=
os
.
Stat
(
fp
);
err
!=
nil
{
t
.
Errorf
(
"expected the file for binary exist at %q but got error %v"
,
fp
,
err
)
var
ps
map
[
string
][]
config
.
Profile
err
=
json
.
Unmarshal
(
rr
.
Stdout
.
Bytes
(),
&
ps
)
if
err
!=
nil
{
t
.
Errorf
(
"%s failed: %v"
,
rr
.
Args
,
err
)
}
})
}
// Check that the profile we've created has the expected driver
t
.
Run
(
"ExpectedDefaultDriver"
,
func
(
t
*
testing
.
T
)
{
if
ExpectedDefaultDriver
()
==
""
{
t
.
Skipf
(
"--expected-default-driver is unset, skipping test"
)
return
}
rr
,
err
:=
Run
(
t
,
exec
.
CommandContext
(
ctx
,
Target
(),
"profile"
,
"list"
,
"--output"
,
"json"
))
if
err
!=
nil
{
t
.
Errorf
(
"%s failed: %v"
,
rr
.
Args
,
err
)
}
var
ps
map
[
string
][]
config
.
Profile
err
=
json
.
Unmarshal
(
rr
.
Stdout
.
Bytes
(),
&
ps
)
if
err
!=
nil
{
t
.
Errorf
(
"%s failed: %v"
,
rr
.
Args
,
err
)
}
got
:=
""
for
_
,
p
:=
range
ps
[
"valid"
]
{
if
p
.
Name
==
profile
{
got
=
p
.
Config
.
Driver
got
:=
""
for
_
,
p
:=
range
ps
[
"valid"
]
{
if
p
.
Name
==
profile
{
got
=
p
.
Config
.
Driver
}
}
}
if
got
!=
ExpectedDefaultDriver
()
{
t
.
Errorf
(
"got driver %q, expected %q
\n
start output: %s"
,
got
,
ExpectedDefaultDriver
(),
rrr
.
Output
())
}
})
if
got
!=
ExpectedDefaultDriver
()
{
t
.
Errorf
(
"got driver %q, expected %q
\n
start output: %s"
,
got
,
ExpectedDefaultDriver
(),
rrr
.
Output
())
}
})
// This is a weird place to test profile deletion, but this test is serial, and we have a profile to delete!
t
.
Run
(
"DeleteAll"
,
func
(
t
*
testing
.
T
)
{
if
!
CanCleanup
()
{
t
.
Skip
(
"skipping, as cleanup is disabled"
)
}
rr
,
err
:=
Run
(
t
,
exec
.
CommandContext
(
ctx
,
Target
(),
"delete"
,
"--all"
))
if
err
!=
nil
{
t
.
Errorf
(
"%s failed: %v"
,
rr
.
Args
,
err
)
}
})
// Delete should always succeed, even if previously partially or fully deleted.
t
.
Run
(
"DeleteAlwaysSucceeds"
,
func
(
t
*
testing
.
T
)
{
if
!
CanCleanup
()
{
t
.
Skip
(
"skipping, as cleanup is disabled"
)
}
rr
,
err
:=
Run
(
t
,
exec
.
CommandContext
(
ctx
,
Target
(),
"delete"
,
"-p"
,
profile
))
if
err
!=
nil
{
t
.
Errorf
(
"%s failed: %v"
,
rr
.
Args
,
err
)
}
// This is a weird place to test profile deletion, but this test is serial, and we have a profile to delete!
t
.
Run
(
"DeleteAll"
,
func
(
t
*
testing
.
T
)
{
if
!
CanCleanup
()
{
t
.
Skip
(
"skipping, as cleanup is disabled"
)
}
rr
,
err
:=
Run
(
t
,
exec
.
CommandContext
(
ctx
,
Target
(),
"delete"
,
"--all"
))
if
err
!=
nil
{
t
.
Errorf
(
"%s failed: %v"
,
rr
.
Args
,
err
)
}
})
// Delete should always succeed, even if previously partially or fully deleted.
t
.
Run
(
"DeleteAlwaysSucceeds"
,
func
(
t
*
testing
.
T
)
{
if
!
CanCleanup
()
{
t
.
Skip
(
"skipping, as cleanup is disabled"
)
}
rr
,
err
:=
Run
(
t
,
exec
.
CommandContext
(
ctx
,
Target
(),
"delete"
,
"-p"
,
profile
))
if
err
!=
nil
{
t
.
Errorf
(
"%s failed: %v"
,
rr
.
Args
,
err
)
}
})
})
})
}
}
func
TestDownloadOnlyDocker
(
t
*
testing
.
T
)
{
if
!
runningDockerDriver
(
StartArgs
())
{
t
.
Skip
(
"this test only runs with the docker driver"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录