Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Chu Peng 楚鹏
minikube
提交
e2ec890c
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,发现更多精彩内容 >>
提交
e2ec890c
编写于
5月 27, 2020
作者:
S
Sharif Elgamal
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of github.com:kubernetes/minikube into native-ssh
上级
ee764c8d
c77959a0
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
61 addition
and
57 deletion
+61
-57
test/integration/addons_test.go
test/integration/addons_test.go
+5
-44
test/integration/functional_test.go
test/integration/functional_test.go
+56
-13
未找到文件。
test/integration/addons_test.go
浏览文件 @
e2ec890c
...
...
@@ -40,7 +40,7 @@ func TestAddons(t *testing.T) {
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
Minutes
(
40
))
defer
Cleanup
(
t
,
profile
,
cancel
)
args
:=
append
([]
string
{
"start"
,
"-p"
,
profile
,
"--wait=false"
,
"--memory=2600"
,
"--alsologtostderr"
,
"--addons=ingress"
,
"--addons=registry"
,
"--addons=metrics-server"
,
"--addons=helm-tiller"
},
StartArgs
()
...
)
args
:=
append
([]
string
{
"start"
,
"-p"
,
profile
,
"--wait=false"
,
"--memory=2600"
,
"--alsologtostderr"
,
"--addons=ingress"
,
"--addons=registry"
,
"--addons=metrics-server"
,
"--addons=helm-tiller"
,
"--addons=olm"
},
StartArgs
()
...
)
rr
,
err
:=
Run
(
t
,
exec
.
CommandContext
(
ctx
,
Target
(),
args
...
))
if
err
!=
nil
{
t
.
Fatalf
(
"%s failed: %v"
,
rr
.
Command
(),
err
)
...
...
@@ -56,6 +56,7 @@ func TestAddons(t *testing.T) {
{
"Ingress"
,
validateIngressAddon
},
{
"MetricsServer"
,
validateMetricsServerAddon
},
{
"HelmTiller"
,
validateHelmTillerAddon
},
{
"Olm"
,
validateOlmAddon
},
}
for
_
,
tc
:=
range
tests
{
tc
:=
tc
...
...
@@ -329,50 +330,10 @@ func validateHelmTillerAddon(ctx context.Context, t *testing.T, profile string)
}
}
func
TestOlmAddon
(
t
*
testing
.
T
)
{
profile
:=
UniqueProfileName
(
"addons"
)
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
Minutes
(
40
))
defer
Cleanup
(
t
,
profile
,
cancel
)
args
:=
append
([]
string
{
"start"
,
"-p"
,
profile
,
"--wait=false"
,
"--memory=2600"
,
"--alsologtostderr"
,
"--addons=olm"
},
StartArgs
()
...
)
rr
,
err
:=
Run
(
t
,
exec
.
CommandContext
(
ctx
,
Target
(),
args
...
))
if
err
!=
nil
{
t
.
Fatalf
(
"%s failed: %v"
,
rr
.
Command
(),
err
)
}
// Parallelized tests
t
.
Run
(
"parallel"
,
func
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
name
string
validator
validateFunc
}{
{
"Olm"
,
validateOlmAddon
},
}
for
_
,
tc
:=
range
tests
{
tc
:=
tc
t
.
Run
(
tc
.
name
,
func
(
t
*
testing
.
T
)
{
MaybeParallel
(
t
)
tc
.
validator
(
ctx
,
t
,
profile
)
})
}
})
// Assert that disable/enable works offline
rr
,
err
=
Run
(
t
,
exec
.
CommandContext
(
ctx
,
Target
(),
"stop"
,
"-p"
,
profile
))
if
err
!=
nil
{
t
.
Errorf
(
"failed to stop minikube. args %q : %v"
,
rr
.
Command
(),
err
)
}
rr
,
err
=
Run
(
t
,
exec
.
CommandContext
(
ctx
,
Target
(),
"addons"
,
"enable"
,
"dashboard"
,
"-p"
,
profile
))
if
err
!=
nil
{
t
.
Errorf
(
"failed to enable dashboard addon: args %q : %v"
,
rr
.
Command
(),
err
)
}
rr
,
err
=
Run
(
t
,
exec
.
CommandContext
(
ctx
,
Target
(),
"addons"
,
"disable"
,
"dashboard"
,
"-p"
,
profile
))
if
err
!=
nil
{
t
.
Errorf
(
"failed to disable dashboard addon: args %q : %v"
,
rr
.
Command
(),
err
)
}
}
func
validateOlmAddon
(
ctx
context
.
Context
,
t
*
testing
.
T
,
profile
string
)
{
if
NoneDriver
()
{
t
.
Skipf
(
"Skipping none driver, olm addon is not supported on none driver"
)
}
defer
PostMortemLogs
(
t
,
profile
)
client
,
err
:=
kapi
.
Client
(
profile
)
...
...
test/integration/functional_test.go
浏览文件 @
e2ec890c
...
...
@@ -154,24 +154,43 @@ func validateNodeLabels(ctx context.Context, t *testing.T, profile string) {
// check functionality of minikube after evaling docker-env
func
validateDockerEnv
(
ctx
context
.
Context
,
t
*
testing
.
T
,
profile
string
)
{
defer
PostMortemLogs
(
t
,
profile
)
mctx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
Seconds
(
13
))
mctx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
Seconds
(
30
))
defer
cancel
()
// we should be able to get minikube status with a bash which evaled docker-env
var
rr
*
RunResult
var
err
error
if
runtime
.
GOOS
==
"windows"
{
c
:=
exec
.
CommandContext
(
mctx
,
"powershell.exe"
,
"-NoProfile"
,
"-NonInteractive"
,
Target
()
+
" -p "
+
profile
+
" docker-env | Invoke-Expression ;"
+
Target
()
+
" status -p "
+
profile
)
rr
,
err
=
Run
(
t
,
c
)
}
else
{
c
:=
exec
.
CommandContext
(
mctx
,
"/bin/bash"
,
"-c"
,
"eval $("
+
Target
()
+
" -p "
+
profile
+
" docker-env) && "
+
Target
()
+
" status -p "
+
profile
)
rr
,
err
:=
Run
(
t
,
c
)
// we should be able to get minikube status with a bash which evaled docker-env
rr
,
err
=
Run
(
t
,
c
)
}
if
mctx
.
Err
()
==
context
.
DeadlineExceeded
{
t
.
Errorf
(
"failed to run the command by deadline. exceeded timeout. %s"
,
rr
.
Command
())
}
if
err
!=
nil
{
t
.
Fatalf
(
"failed to do
minikube status after eval-ing docker-env %s
"
,
err
)
t
.
Fatalf
(
"failed to do
status after eval-ing docker-env. error: %v
"
,
err
)
}
if
!
strings
.
Contains
(
rr
.
Output
(),
"Running"
)
{
t
.
Fatalf
(
"expected status output to include 'Running' after eval docker-env but got: *%s*"
,
rr
.
Output
())
}
mctx
,
cancel
=
context
.
WithTimeout
(
ctx
,
Seconds
(
13
))
mctx
,
cancel
=
context
.
WithTimeout
(
ctx
,
Seconds
(
30
))
defer
cancel
()
// do a eval $(minikube -p profile docker-env) and check if we are point to docker inside minikube
c
=
exec
.
CommandContext
(
mctx
,
"/bin/bash"
,
"-c"
,
"eval $("
+
Target
()
+
" -p "
+
profile
+
" docker-env) && docker images"
)
if
runtime
.
GOOS
==
"windows"
{
// testing docker-env eval in powershell
c
:=
exec
.
CommandContext
(
mctx
,
"powershell.exe"
,
"-NoProfile"
,
"-NonInteractive"
,
Target
(),
"-p "
+
profile
+
" docker-env | Invoke-Expression ; docker images"
)
rr
,
err
=
Run
(
t
,
c
)
}
else
{
c
:=
exec
.
CommandContext
(
mctx
,
"/bin/bash"
,
"-c"
,
"eval $("
+
Target
()
+
" -p "
+
profile
+
" docker-env) && docker images"
)
rr
,
err
=
Run
(
t
,
c
)
}
if
mctx
.
Err
()
==
context
.
DeadlineExceeded
{
t
.
Errorf
(
"failed to run the command in 30 seconds. exceeded 30s timeout. %s"
,
rr
.
Command
())
}
if
err
!=
nil
{
t
.
Fatalf
(
"failed to run minikube docker-env. args %q : %v "
,
rr
.
Command
(),
err
)
}
...
...
@@ -319,7 +338,6 @@ func validateComponentHealth(ctx context.Context, t *testing.T, profile string)
func
validateStatusCmd
(
ctx
context
.
Context
,
t
*
testing
.
T
,
profile
string
)
{
defer
PostMortemLogs
(
t
,
profile
)
rr
,
err
:=
Run
(
t
,
exec
.
CommandContext
(
ctx
,
Target
(),
"-p"
,
profile
,
"status"
))
if
err
!=
nil
{
t
.
Errorf
(
"failed to run minikube status. args %q : %v"
,
rr
.
Command
(),
err
)
...
...
@@ -507,7 +525,8 @@ func validateCacheCmd(ctx context.Context, t *testing.T, profile string) {
t
.
Run
(
"cache_reload"
,
func
(
t
*
testing
.
T
)
{
// deleting image inside minikube node manually and expecting reload to bring it back
img
:=
"busybox:latest"
// deleting image inside minikube node manually
rr
,
err
:=
Run
(
t
,
exec
.
CommandContext
(
ctx
,
Target
(),
"-p"
,
profile
,
"ssh"
,
"sudo"
,
"docker"
,
"rmi"
,
img
))
// for some reason crictl rmi doesn't work
rr
,
err
:=
Run
(
t
,
exec
.
CommandContext
(
ctx
,
Target
(),
"-p"
,
profile
,
"ssh"
,
"sudo"
,
"docker"
,
"rmi"
,
img
))
if
err
!=
nil
{
t
.
Errorf
(
"failed to delete inside the node %q : %v"
,
rr
.
Command
(),
err
)
}
...
...
@@ -812,12 +831,36 @@ func validateAddonsCmd(ctx context.Context, t *testing.T, profile string) {
// validateSSHCmd asserts basic "ssh" command functionality
func
validateSSHCmd
(
ctx
context
.
Context
,
t
*
testing
.
T
,
profile
string
)
{
defer
PostMortemLogs
(
t
,
profile
)
if
NoneDriver
()
{
t
.
Skipf
(
"skipping: ssh unsupported by none"
)
}
mctx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
Minutes
(
1
))
defer
cancel
()
want
:=
"hello"
rr
,
err
:=
Run
(
t
,
exec
.
CommandContext
(
ctx
,
Target
(),
"-p"
,
profile
,
"ssh"
,
fmt
.
Sprintf
(
"echo hello"
)))
rr
,
err
:=
Run
(
t
,
exec
.
CommandContext
(
mctx
,
Target
(),
"-p"
,
profile
,
"ssh"
,
"echo hello"
))
if
mctx
.
Err
()
==
context
.
DeadlineExceeded
{
t
.
Errorf
(
"failed to run command by deadline. exceeded timeout : %s"
,
rr
.
Command
())
}
if
err
!=
nil
{
t
.
Errorf
(
"failed to run an ssh command. args %q : %v"
,
rr
.
Command
(),
err
)
}
// trailing whitespace differs between native and external SSH clients, so let's trim it and call it a day
if
rr
.
Stdout
.
String
()
!=
want
{
t
.
Errorf
(
"expected minikube ssh command output to be -%q- but got *%q*. args %q"
,
want
,
rr
.
Stdout
.
String
(),
rr
.
Command
())
}
// testing hostname as well because testing something like "minikube ssh echo" could be confusing
// because it is not clear if echo was run inside minikube on the powershell
// so better to test something inside minikube, that is meaningful per profile
// in this case /etc/hostname is same as the profile name
want
=
profile
rr
,
err
=
Run
(
t
,
exec
.
CommandContext
(
mctx
,
Target
(),
"-p"
,
profile
,
"ssh"
,
"cat /etc/hostname"
))
if
mctx
.
Err
()
==
context
.
DeadlineExceeded
{
t
.
Errorf
(
"failed to run command by deadline. exceeded timeout : %s"
,
rr
.
Command
())
}
if
err
!=
nil
{
t
.
Errorf
(
"failed to run an ssh command. args %q : %v"
,
rr
.
Command
(),
err
)
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录