Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Chu Peng 楚鹏
minikube
提交
63933c1b
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,发现更多精彩内容 >>
未验证
提交
63933c1b
编写于
5月 14, 2020
作者:
M
Medya Ghazizadeh
提交者:
GitHub
5月 14, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #8024 from medyagh/breakdown_start_stop
integration test: break-down TestStartStop to sub-tests
上级
2e7d9d88
8b630c2c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
127 addition
and
68 deletion
+127
-68
test/integration/start_stop_delete_test.go
test/integration/start_stop_delete_test.go
+127
-68
未找到文件。
test/integration/start_stop_delete_test.go
浏览文件 @
63933c1b
...
...
@@ -80,15 +80,14 @@ func TestStartStop(t *testing.T) {
tc
:=
tc
t
.
Run
(
tc
.
name
,
func
(
t
*
testing
.
T
)
{
MaybeParallel
(
t
)
profile
:=
UniqueProfileName
(
tc
.
name
)
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
Minutes
(
40
))
defer
Cleanup
(
t
,
profile
,
cancel
)
type
validateStartStopFunc
func
(
context
.
Context
,
*
testing
.
T
,
string
,
string
,
string
,
[]
string
)
if
!
strings
.
Contains
(
tc
.
name
,
"docker"
)
&&
NoneDriver
()
{
t
.
Skipf
(
"skipping %s - incompatible with none driver"
,
t
.
Name
())
}
profile
:=
UniqueProfileName
(
tc
.
name
)
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
Minutes
(
40
))
defer
CleanupWithLogs
(
t
,
profile
,
cancel
)
waitFlag
:=
"--wait=true"
if
strings
.
Contains
(
tc
.
name
,
"cni"
)
{
// wait=app_running is broken for CNI https://github.com/kubernetes/minikube/issues/7354
waitFlag
=
"--wait=apiserver,system_pods,default_sa"
...
...
@@ -98,80 +97,140 @@ func TestStartStop(t *testing.T) {
startArgs
=
append
(
startArgs
,
StartArgs
()
...
)
startArgs
=
append
(
startArgs
,
fmt
.
Sprintf
(
"--kubernetes-version=%s"
,
tc
.
version
))
rr
,
err
:=
Run
(
t
,
exec
.
CommandContext
(
ctx
,
Target
(),
startArgs
...
))
if
err
!=
nil
{
t
.
Fatalf
(
"failed starting minikube -first start-. args %q: %v"
,
rr
.
Command
(),
err
)
}
t
.
Run
(
"serial"
,
func
(
t
*
testing
.
T
)
{
serialTests
:=
[]
struct
{
name
string
validator
validateStartStopFunc
}{
{
"FirstStart"
,
validateFirstStart
},
{
"DeployApp"
,
validateDeploying
},
{
"Stop"
,
validateStop
},
{
"EnableAddonAfterStop"
,
validateEnableAddonAfterStop
},
{
"SecondStart"
,
validateSecondStart
},
{
"UserAppExistsAfterStop"
,
validateAppExistsAfterStop
},
{
"AddonExistsAfterStop"
,
validateAddonAfterStop
},
{
"VerifyKubernetesImages"
,
validateKubernetesImages
},
{
"Pause"
,
validatePauseAfterSart
},
}
for
_
,
stc
:=
range
serialTests
{
tcName
:=
tc
.
name
tcVersion
:=
tc
.
version
stc
:=
stc
t
.
Run
(
stc
.
name
,
func
(
t
*
testing
.
T
)
{
stc
.
validator
(
ctx
,
t
,
profile
,
tcName
,
tcVersion
,
startArgs
)
})
}
if
!
strings
.
Contains
(
tc
.
name
,
"cni"
)
{
testPodScheduling
(
ctx
,
t
,
profile
)
}
if
*
cleanup
{
// Normally handled by cleanuprofile, but not fatal there
rr
,
err
:=
Run
(
t
,
exec
.
CommandContext
(
ctx
,
Target
(),
"delete"
,
"-p"
,
profile
))
if
err
!=
nil
{
t
.
Errorf
(
"failed to clean up: args %q: %v"
,
rr
.
Command
(),
err
)
}
rr
,
err
=
Run
(
t
,
exec
.
CommandContext
(
ctx
,
"kubectl"
,
"config"
,
"get-contexts"
,
profile
))
if
err
!=
nil
{
t
.
Logf
(
"config context error: %v (may be ok)"
,
err
)
}
if
rr
.
ExitCode
!=
1
{
t
.
Errorf
(
"expected exit code 1, got %d. output: %s"
,
rr
.
ExitCode
,
rr
.
Output
())
}
}
rr
,
err
=
Run
(
t
,
exec
.
CommandContext
(
ctx
,
Target
(),
"stop"
,
"-p"
,
profile
,
"--alsologtostderr"
,
"-v=3"
))
if
err
!=
nil
{
t
.
Fatalf
(
"failed stopping minikube - first stop-. args %q : %v"
,
rr
.
Command
(),
err
)
}
})
// The none driver never really stops
if
!
NoneDriver
()
{
got
:=
Status
(
ctx
,
t
,
Target
(),
profile
,
"Host"
)
if
got
!=
state
.
Stopped
.
String
()
{
t
.
Fatalf
(
"expected post-stop host status to be -%q- but got *%q*"
,
state
.
Stopped
,
got
)
}
}
})
}
})
}
// Enable an addon to assert it comes up afterwards
rr
,
err
=
Run
(
t
,
exec
.
CommandContext
(
ctx
,
Target
(),
"addons"
,
"enable"
,
"dashboard"
,
"-p"
,
profile
))
if
err
!=
nil
{
t
.
Fatalf
(
"failed to enable an addon post-stop. args %q: %v"
,
rr
.
Command
(),
err
)
}
func
validateFirstStart
(
ctx
context
.
Context
,
t
*
testing
.
T
,
profile
string
,
tcName
string
,
tcVersion
string
,
startArgs
[]
string
)
{
defer
PostMortemLogs
(
t
,
profile
)
rr
,
err
:=
Run
(
t
,
exec
.
CommandContext
(
ctx
,
Target
(),
startArgs
...
))
if
err
!=
nil
{
t
.
Fatalf
(
"failed starting minikube -first start-. args %q: %v"
,
rr
.
Command
(),
err
)
}
}
rr
,
err
=
Run
(
t
,
exec
.
CommandContext
(
ctx
,
Target
(),
startArgs
...
))
if
err
!=
nil
{
// Explicit fatal so that failures don't move directly to deletion
t
.
Fatalf
(
"failed to start minikube post-stop. args %q: %v"
,
rr
.
Command
(),
err
)
}
func
validateDeploying
(
ctx
context
.
Context
,
t
*
testing
.
T
,
profile
string
,
tcName
string
,
tcVersion
string
,
startArgs
[]
string
)
{
defer
PostMortemLogs
(
t
,
profile
)
if
!
strings
.
Contains
(
tcName
,
"cni"
)
{
testPodScheduling
(
ctx
,
t
,
profile
)
}
}
if
strings
.
Contains
(
tc
.
name
,
"cni"
)
{
t
.
Logf
(
"WARNING: cni mode requires additional setup before pods can schedule :("
)
}
else
{
if
_
,
err
:=
PodWait
(
ctx
,
t
,
profile
,
"default"
,
"integration-test=busybox"
,
Minutes
(
7
));
err
!=
nil
{
t
.
Fatalf
(
"failed waiting for pod 'busybox' post-stop-start: %v"
,
err
)
}
if
_
,
err
:=
PodWait
(
ctx
,
t
,
profile
,
"kubernetes-dashboard"
,
"k8s-app=kubernetes-dashboard"
,
Minutes
(
9
));
err
!=
nil
{
t
.
Fatalf
(
"failed waiting for 'addon dashboard' pod post-stop-start: %v"
,
err
)
}
}
func
validateStop
(
ctx
context
.
Context
,
t
*
testing
.
T
,
profile
string
,
tcName
string
,
tcVersion
string
,
startArgs
[]
string
)
{
defer
PostMortemLogs
(
t
,
profile
)
rr
,
err
:=
Run
(
t
,
exec
.
CommandContext
(
ctx
,
Target
(),
"stop"
,
"-p"
,
profile
,
"--alsologtostderr"
,
"-v=3"
))
if
err
!=
nil
{
t
.
Fatalf
(
"failed stopping minikube - first stop-. args %q : %v"
,
rr
.
Command
(),
err
)
}
}
got
:=
Status
(
ctx
,
t
,
Target
(),
profile
,
"Host"
)
if
got
!=
state
.
Running
.
String
()
{
t
.
Fatalf
(
"expected host status after start-stop-start to be -%q- but got *%q*"
,
state
.
Running
,
got
)
}
func
validateEnableAddonAfterStop
(
ctx
context
.
Context
,
t
*
testing
.
T
,
profile
string
,
tcName
string
,
tcVersion
string
,
startArgs
[]
string
)
{
defer
PostMortemLogs
(
t
,
profile
)
// The none driver never really stops
if
!
NoneDriver
()
{
got
:=
Status
(
ctx
,
t
,
Target
(),
profile
,
"Host"
)
if
got
!=
state
.
Stopped
.
String
()
{
t
.
Errorf
(
"expected post-stop host status to be -%q- but got *%q*"
,
state
.
Stopped
,
got
)
}
}
if
!
NoneDriver
()
{
testPulledImages
(
ctx
,
t
,
profile
,
tc
.
version
)
}
// Enable an addon to assert it comes up afterwards
rr
,
err
:=
Run
(
t
,
exec
.
CommandContext
(
ctx
,
Target
(),
"addons"
,
"enable"
,
"dashboard"
,
"-p"
,
profile
))
if
err
!=
nil
{
t
.
Errorf
(
"failed to enable an addon post-stop. args %q: %v"
,
rr
.
Command
(),
err
)
}
testPause
(
ctx
,
t
,
profile
)
}
if
*
cleanup
{
// Normally handled by cleanuprofile, but not fatal there
rr
,
err
=
Run
(
t
,
exec
.
CommandContext
(
ctx
,
Target
(),
"delete"
,
"-p"
,
profile
))
if
err
!=
nil
{
t
.
Errorf
(
"failed to clean up: args %q: %v"
,
rr
.
Command
(),
err
)
}
func
validateSecondStart
(
ctx
context
.
Context
,
t
*
testing
.
T
,
profile
string
,
tcName
string
,
tcVersion
string
,
startArgs
[]
string
)
{
defer
PostMortemLogs
(
t
,
profile
)
rr
,
err
:=
Run
(
t
,
exec
.
CommandContext
(
ctx
,
Target
(),
startArgs
...
))
if
err
!=
nil
{
// Explicit fatal so that failures don't move directly to deletion
t
.
Fatalf
(
"failed to start minikube post-stop. args %q: %v"
,
rr
.
Command
(),
err
)
}
rr
,
err
=
Run
(
t
,
exec
.
CommandContext
(
ctx
,
"kubectl"
,
"config"
,
"get-contexts"
,
profile
))
if
err
!=
nil
{
t
.
Logf
(
"config context error: %v (may be ok)"
,
err
)
}
if
rr
.
ExitCode
!=
1
{
t
.
Errorf
(
"expected exit code 1, got %d. output: %s"
,
rr
.
ExitCode
,
rr
.
Output
())
}
}
})
}
})
got
:=
Status
(
ctx
,
t
,
Target
(),
profile
,
"Host"
)
if
got
!=
state
.
Running
.
String
()
{
t
.
Errorf
(
"expected host status after start-stop-start to be -%q- but got *%q*"
,
state
.
Running
,
got
)
}
}
// validateAppExistsAfterStop verifies that a user's app will not vanish after a minikube stop
func
validateAppExistsAfterStop
(
ctx
context
.
Context
,
t
*
testing
.
T
,
profile
string
,
tcName
string
,
tcVersion
string
,
startArgs
[]
string
)
{
defer
PostMortemLogs
(
t
,
profile
)
if
strings
.
Contains
(
tcName
,
"cni"
)
{
t
.
Logf
(
"WARNING: cni mode requires additional setup before pods can schedule :("
)
}
else
if
_
,
err
:=
PodWait
(
ctx
,
t
,
profile
,
"kubernetes-dashboard"
,
"k8s-app=kubernetes-dashboard"
,
Minutes
(
9
));
err
!=
nil
{
t
.
Errorf
(
"failed waiting for 'addon dashboard' pod post-stop-start: %v"
,
err
)
}
}
// validateAddonAfterStop validates that an addon which was enabled when minikube is stopped will be enabled and working..
func
validateAddonAfterStop
(
ctx
context
.
Context
,
t
*
testing
.
T
,
profile
string
,
tcName
string
,
tcVersion
string
,
startArgs
[]
string
)
{
defer
PostMortemLogs
(
t
,
profile
)
if
strings
.
Contains
(
tcName
,
"cni"
)
{
t
.
Logf
(
"WARNING: cni mode requires additional setup before pods can schedule :("
)
}
else
if
_
,
err
:=
PodWait
(
ctx
,
t
,
profile
,
"kubernetes-dashboard"
,
"k8s-app=kubernetes-dashboard"
,
Minutes
(
9
));
err
!=
nil
{
t
.
Errorf
(
"failed waiting for 'addon dashboard' pod post-stop-start: %v"
,
err
)
}
}
func
validateKubernetesImages
(
ctx
context
.
Context
,
t
*
testing
.
T
,
profile
string
,
tcName
string
,
tcVersion
string
,
startArgs
[]
string
)
{
defer
PostMortemLogs
(
t
,
profile
)
if
!
NoneDriver
()
{
testPulledImages
(
ctx
,
t
,
profile
,
tcVersion
)
}
}
func
validatePauseAfterSart
(
ctx
context
.
Context
,
t
*
testing
.
T
,
profile
string
,
tcName
string
,
tcVersion
string
,
startArgs
[]
string
)
{
defer
PostMortemLogs
(
t
,
profile
)
testPause
(
ctx
,
t
,
profile
)
}
// testPodScheduling asserts that this configuration can schedule new pods
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录