Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
1817f746
Commit
1817f746
authored
Jul 06, 2015
by
Yu-Ju Hong
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #10758 from mikedanese/test-server
deflake container_probe test by using test-webserver from gcr.io
parents
b9cc5487
1f59d793
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
15 deletions
+22
-15
container_probe.go
test/e2e/container_probe.go
+22
-15
No files found.
test/e2e/container_probe.go
View file @
1817f746
...
...
@@ -31,7 +31,7 @@ import (
var
_
=
Describe
(
"Probing container"
,
func
()
{
framework
:=
Framework
{
BaseName
:
"container-probe"
}
var
podClient
client
.
PodInterface
probe
:=
nginx
ProbeBuilder
{}
probe
:=
webserver
ProbeBuilder
{}
BeforeEach
(
func
()
{
framework
.
beforeEach
()
...
...
@@ -45,13 +45,18 @@ var _ = Describe("Probing container", func() {
expectNoError
(
err
)
startTime
:=
time
.
Now
()
expectNoError
(
wait
.
Poll
(
poll
,
90
*
time
.
Second
,
func
()
(
bool
,
error
)
{
Expect
(
wait
.
Poll
(
poll
,
90
*
time
.
Second
,
func
()
(
bool
,
error
)
{
p
,
err
:=
podClient
.
Get
(
p
.
Name
)
if
err
!=
nil
{
return
false
,
err
}
return
api
.
IsPodReady
(
p
),
nil
}))
ready
:=
api
.
IsPodReady
(
p
)
if
!
ready
{
Logf
(
"pod is not yet ready; pod has phase %q."
,
p
.
Status
.
Phase
)
return
false
,
nil
}
return
true
,
nil
}))
.
NotTo
(
HaveOccurred
(),
"pod never became ready"
)
if
time
.
Since
(
startTime
)
<
30
*
time
.
Second
{
Failf
(
"Pod became ready before it's initial delay"
)
...
...
@@ -62,9 +67,10 @@ var _ = Describe("Probing container", func() {
isReady
,
err
:=
podRunningReady
(
p
)
expectNoError
(
err
)
Expect
(
isReady
)
.
To
(
BeTrue
())
Expect
(
isReady
)
.
To
(
BeTrue
()
,
"pod should be ready"
)
Expect
(
getRestartCount
(
p
)
==
0
)
.
To
(
BeTrue
())
restartCount
:=
getRestartCount
(
p
)
Expect
(
restartCount
==
0
)
.
To
(
BeTrue
(),
"pod should have a restart count of 0 but got %v"
,
restartCount
)
})
It
(
"with readiness probe that fails should never be ready and never restart"
,
func
()
{
...
...
@@ -86,9 +92,10 @@ var _ = Describe("Probing container", func() {
expectNoError
(
err
)
isReady
,
err
:=
podRunningReady
(
p
)
Expect
(
isReady
)
.
NotTo
(
BeTrue
())
Expect
(
isReady
)
.
NotTo
(
BeTrue
()
,
"pod should be not ready"
)
Expect
(
getRestartCount
(
p
)
==
0
)
.
To
(
BeTrue
())
restartCount
:=
getRestartCount
(
p
)
Expect
(
restartCount
==
0
)
.
To
(
BeTrue
(),
"pod should have a restart count of 0 but got %v"
,
restartCount
)
})
})
...
...
@@ -103,12 +110,12 @@ func getRestartCount(p *api.Pod) int {
func
makePodSpec
(
readinessProbe
,
livenessProbe
*
api
.
Probe
)
*
api
.
Pod
{
pod
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"
nginx
-"
+
string
(
util
.
NewUUID
())},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"
test-webserver
-"
+
string
(
util
.
NewUUID
())},
Spec
:
api
.
PodSpec
{
Containers
:
[]
api
.
Container
{
{
Name
:
"
nginx
"
,
Image
:
"
nginx
"
,
Name
:
"
test-webserver
"
,
Image
:
"
gcr.io/google_containers/test-webserver
"
,
LivenessProbe
:
livenessProbe
,
ReadinessProbe
:
readinessProbe
,
},
...
...
@@ -118,22 +125,22 @@ func makePodSpec(readinessProbe, livenessProbe *api.Probe) *api.Pod {
return
pod
}
type
nginx
ProbeBuilder
struct
{
type
webserver
ProbeBuilder
struct
{
failing
bool
initialDelay
bool
}
func
(
b
nginxProbeBuilder
)
withFailing
()
nginx
ProbeBuilder
{
func
(
b
webserverProbeBuilder
)
withFailing
()
webserver
ProbeBuilder
{
b
.
failing
=
true
return
b
}
func
(
b
nginxProbeBuilder
)
withInitialDelay
()
nginx
ProbeBuilder
{
func
(
b
webserverProbeBuilder
)
withInitialDelay
()
webserver
ProbeBuilder
{
b
.
initialDelay
=
true
return
b
}
func
(
b
nginx
ProbeBuilder
)
build
()
*
api
.
Probe
{
func
(
b
webserver
ProbeBuilder
)
build
()
*
api
.
Probe
{
probe
:=
&
api
.
Probe
{
Handler
:
api
.
Handler
{
HTTPGet
:
&
api
.
HTTPGetAction
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment