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
b7dc1175
Commit
b7dc1175
authored
Dec 07, 2015
by
Fabio Yeon
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #18220 from yujuhong/increase_timeout
e2e: increase the container probing test timeout
parents
5457f5ac
0ae1d548
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
13 deletions
+45
-13
container_probe.go
test/e2e/container_probe.go
+45
-13
No files found.
test/e2e/container_probe.go
View file @
b7dc1175
...
@@ -17,6 +17,7 @@ limitations under the License.
...
@@ -17,6 +17,7 @@ limitations under the License.
package
e2e
package
e2e
import
(
import
(
"fmt"
"time"
"time"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
...
@@ -29,6 +30,11 @@ import (
...
@@ -29,6 +30,11 @@ import (
.
"github.com/onsi/gomega"
.
"github.com/onsi/gomega"
)
)
const
(
probTestContainerName
=
"test-webserber"
probTestInitialDelaySeconds
=
30
)
var
_
=
Describe
(
"Probing container"
,
func
()
{
var
_
=
Describe
(
"Probing container"
,
func
()
{
framework
:=
NewFramework
(
"container-probe"
)
framework
:=
NewFramework
(
"container-probe"
)
var
podClient
client
.
PodInterface
var
podClient
client
.
PodInterface
...
@@ -41,9 +47,8 @@ var _ = Describe("Probing container", func() {
...
@@ -41,9 +47,8 @@ var _ = Describe("Probing container", func() {
It
(
"with readiness probe should not be ready before initial delay and never restart [Conformance]"
,
func
()
{
It
(
"with readiness probe should not be ready before initial delay and never restart [Conformance]"
,
func
()
{
p
,
err
:=
podClient
.
Create
(
makePodSpec
(
probe
.
withInitialDelay
()
.
build
(),
nil
))
p
,
err
:=
podClient
.
Create
(
makePodSpec
(
probe
.
withInitialDelay
()
.
build
(),
nil
))
expectNoError
(
err
)
expectNoError
(
err
)
startTime
:=
time
.
Now
()
Expect
(
wait
.
Poll
(
poll
,
9
0
*
time
.
Second
,
func
()
(
bool
,
error
)
{
Expect
(
wait
.
Poll
(
poll
,
12
0
*
time
.
Second
,
func
()
(
bool
,
error
)
{
p
,
err
:=
podClient
.
Get
(
p
.
Name
)
p
,
err
:=
podClient
.
Get
(
p
.
Name
)
if
err
!=
nil
{
if
err
!=
nil
{
return
false
,
err
return
false
,
err
...
@@ -56,17 +61,25 @@ var _ = Describe("Probing container", func() {
...
@@ -56,17 +61,25 @@ var _ = Describe("Probing container", func() {
return
true
,
nil
return
true
,
nil
}))
.
NotTo
(
HaveOccurred
(),
"pod never became ready"
)
}))
.
NotTo
(
HaveOccurred
(),
"pod never became ready"
)
if
time
.
Since
(
startTime
)
<
30
*
time
.
Second
{
Failf
(
"Pod became ready before it's initial delay"
)
}
p
,
err
=
podClient
.
Get
(
p
.
Name
)
p
,
err
=
podClient
.
Get
(
p
.
Name
)
expectNoError
(
err
)
expectNoError
(
err
)
isReady
,
err
:=
podRunningReady
(
p
)
isReady
,
err
:=
podRunningReady
(
p
)
expectNoError
(
err
)
expectNoError
(
err
)
Expect
(
isReady
)
.
To
(
BeTrue
(),
"pod should be ready"
)
Expect
(
isReady
)
.
To
(
BeTrue
(),
"pod should be ready"
)
// We assume the pod became ready when the container became ready. This
// is true for a single container pod.
readyTime
,
err
:=
getTransitionTimeForReadyCondition
(
p
)
expectNoError
(
err
)
startedTime
,
err
:=
getContainerStartedTime
(
p
,
probTestContainerName
)
expectNoError
(
err
)
Logf
(
"Container started at %v, pod became ready at %v"
,
startedTime
,
readyTime
)
initialDelay
:=
probTestInitialDelaySeconds
*
time
.
Second
if
readyTime
.
Sub
(
startedTime
)
<
initialDelay
{
Failf
(
"Pod became ready before it's %v initial delay"
,
initialDelay
)
}
restartCount
:=
getRestartCount
(
p
)
restartCount
:=
getRestartCount
(
p
)
Expect
(
restartCount
==
0
)
.
To
(
BeTrue
(),
"pod should have a restart count of 0 but got %v"
,
restartCount
)
Expect
(
restartCount
==
0
)
.
To
(
BeTrue
(),
"pod should have a restart count of 0 but got %v"
,
restartCount
)
})
})
...
@@ -75,7 +88,7 @@ var _ = Describe("Probing container", func() {
...
@@ -75,7 +88,7 @@ var _ = Describe("Probing container", func() {
p
,
err
:=
podClient
.
Create
(
makePodSpec
(
probe
.
withFailing
()
.
build
(),
nil
))
p
,
err
:=
podClient
.
Create
(
makePodSpec
(
probe
.
withFailing
()
.
build
(),
nil
))
expectNoError
(
err
)
expectNoError
(
err
)
err
=
wait
.
Poll
(
poll
,
9
0
*
time
.
Second
,
func
()
(
bool
,
error
)
{
err
=
wait
.
Poll
(
poll
,
12
0
*
time
.
Second
,
func
()
(
bool
,
error
)
{
p
,
err
:=
podClient
.
Get
(
p
.
Name
)
p
,
err
:=
podClient
.
Get
(
p
.
Name
)
if
err
!=
nil
{
if
err
!=
nil
{
return
false
,
err
return
false
,
err
...
@@ -98,6 +111,28 @@ var _ = Describe("Probing container", func() {
...
@@ -98,6 +111,28 @@ var _ = Describe("Probing container", func() {
})
})
func
getContainerStartedTime
(
p
*
api
.
Pod
,
containerName
string
)
(
time
.
Time
,
error
)
{
for
_
,
status
:=
range
p
.
Status
.
ContainerStatuses
{
if
status
.
Name
!=
containerName
{
continue
}
if
status
.
State
.
Running
==
nil
{
return
time
.
Time
{},
fmt
.
Errorf
(
"Container is not running"
)
}
return
status
.
State
.
Running
.
StartedAt
.
Time
,
nil
}
return
time
.
Time
{},
fmt
.
Errorf
(
"cannot find container named %q"
,
containerName
)
}
func
getTransitionTimeForReadyCondition
(
p
*
api
.
Pod
)
(
time
.
Time
,
error
)
{
for
_
,
cond
:=
range
p
.
Status
.
Conditions
{
if
cond
.
Type
==
api
.
PodReady
{
return
cond
.
LastTransitionTime
.
Time
,
nil
}
}
return
time
.
Time
{},
fmt
.
Errorf
(
"No ready condition can be found for pod"
)
}
func
getRestartCount
(
p
*
api
.
Pod
)
int
{
func
getRestartCount
(
p
*
api
.
Pod
)
int
{
count
:=
0
count
:=
0
for
_
,
containerStatus
:=
range
p
.
Status
.
ContainerStatuses
{
for
_
,
containerStatus
:=
range
p
.
Status
.
ContainerStatuses
{
...
@@ -112,13 +147,10 @@ func makePodSpec(readinessProbe, livenessProbe *api.Probe) *api.Pod {
...
@@ -112,13 +147,10 @@ func makePodSpec(readinessProbe, livenessProbe *api.Probe) *api.Pod {
Spec
:
api
.
PodSpec
{
Spec
:
api
.
PodSpec
{
Containers
:
[]
api
.
Container
{
Containers
:
[]
api
.
Container
{
{
{
Name
:
"test-webserver"
,
Name
:
probTestContainerName
,
Image
:
"gcr.io/google_containers/test-webserver"
,
Image
:
"gcr.io/google_containers/test-webserver"
,
LivenessProbe
:
livenessProbe
,
LivenessProbe
:
livenessProbe
,
ReadinessProbe
:
readinessProbe
,
ReadinessProbe
:
readinessProbe
,
},
{
Name
:
"test-noprobe"
,
Image
:
"gcr.io/google_containers/pause:2.0"
,
},
},
},
},
},
},
...
@@ -151,7 +183,7 @@ func (b webserverProbeBuilder) build() *api.Probe {
...
@@ -151,7 +183,7 @@ func (b webserverProbeBuilder) build() *api.Probe {
},
},
}
}
if
b
.
initialDelay
{
if
b
.
initialDelay
{
probe
.
InitialDelaySeconds
=
30
probe
.
InitialDelaySeconds
=
probTestInitialDelaySeconds
}
}
if
b
.
failing
{
if
b
.
failing
{
probe
.
HTTPGet
.
Port
=
intstr
.
FromInt
(
81
)
probe
.
HTTPGet
.
Port
=
intstr
.
FromInt
(
81
)
...
...
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