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
1a6572fc
Commit
1a6572fc
authored
May 24, 2017
by
David Ashpole
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
summary test now tests a pod that has containers that have restarted
parent
9a9a2965
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
26 deletions
+34
-26
garbage_collector_test.go
test/e2e_node/garbage_collector_test.go
+19
-14
summary_test.go
test/e2e_node/summary_test.go
+15
-12
No files found.
test/e2e_node/garbage_collector_test.go
View file @
1a6572fc
...
@@ -18,6 +18,7 @@ package e2e_node
...
@@ -18,6 +18,7 @@ package e2e_node
import
(
import
(
"fmt"
"fmt"
"strconv"
"strings"
"strings"
"time"
"time"
...
@@ -289,20 +290,9 @@ func getPods(specs []*testPodSpec) (pods []*v1.Pod) {
...
@@ -289,20 +290,9 @@ func getPods(specs []*testPodSpec) (pods []*v1.Pod) {
containers
:=
[]
v1
.
Container
{}
containers
:=
[]
v1
.
Container
{}
for
i
:=
0
;
i
<
spec
.
numContainers
;
i
++
{
for
i
:=
0
;
i
<
spec
.
numContainers
;
i
++
{
containers
=
append
(
containers
,
v1
.
Container
{
containers
=
append
(
containers
,
v1
.
Container
{
Image
:
"gcr.io/google_containers/busybox:1.24"
,
Image
:
"gcr.io/google_containers/busybox:1.24"
,
Name
:
spec
.
getContainerName
(
i
),
Name
:
spec
.
getContainerName
(
i
),
Command
:
[]
string
{
Command
:
getRestartingContainerCommand
(
"/test-empty-dir-mnt"
,
i
,
int
(
spec
.
restartCount
),
""
),
"sh"
,
"-c"
,
fmt
.
Sprintf
(
`
f=/test-empty-dir-mnt/countfile%d
count=$(echo 'hello' >> $f ; wc -l $f | awk {'print $1'})
if [ $count -lt %d ]; then
exit 0
fi
while true; do sleep 1; done
`
,
i
,
spec
.
restartCount
+
1
),
},
VolumeMounts
:
[]
v1
.
VolumeMount
{
VolumeMounts
:
[]
v1
.
VolumeMount
{
{
MountPath
:
"/test-empty-dir-mnt"
,
Name
:
"test-empty-dir"
},
{
MountPath
:
"/test-empty-dir-mnt"
,
Name
:
"test-empty-dir"
},
},
},
...
@@ -321,3 +311,18 @@ func getPods(specs []*testPodSpec) (pods []*v1.Pod) {
...
@@ -321,3 +311,18 @@ func getPods(specs []*testPodSpec) (pods []*v1.Pod) {
}
}
return
return
}
}
func
getRestartingContainerCommand
(
path
string
,
containerNum
,
restarts
int
,
loopingCommand
string
)
[]
string
{
return
[]
string
{
"sh"
,
"-c"
,
fmt
.
Sprintf
(
`
f=%s/countfile%s
count=$(echo 'hello' >> $f ; wc -l $f | awk {'print $1'})
if [ $count -lt %d ]; then
exit 0
fi
while true; do %s sleep 10; done`
,
path
,
strconv
.
Itoa
(
containerNum
),
restarts
+
1
,
loopingCommand
),
}
}
test/e2e_node/summary_test.go
View file @
1a6572fc
...
@@ -35,6 +35,8 @@ import (
...
@@ -35,6 +35,8 @@ import (
"github.com/onsi/gomega/types"
"github.com/onsi/gomega/types"
)
)
const
restartCount
=
3
var
_
=
framework
.
KubeDescribe
(
"Summary API"
,
func
()
{
var
_
=
framework
.
KubeDescribe
(
"Summary API"
,
func
()
{
f
:=
framework
.
NewDefaultFramework
(
"summary-test"
)
f
:=
framework
.
NewDefaultFramework
(
"summary-test"
)
Context
(
"when querying /stats/summary"
,
func
()
{
Context
(
"when querying /stats/summary"
,
func
()
{
...
@@ -53,9 +55,10 @@ var _ = framework.KubeDescribe("Summary API", func() {
...
@@ -53,9 +55,10 @@ var _ = framework.KubeDescribe("Summary API", func() {
const
pod1
=
"stats-busybox-1"
const
pod1
=
"stats-busybox-1"
By
(
"Creating test pods"
)
By
(
"Creating test pods"
)
createSummaryTestPods
(
f
,
pod0
,
pod1
)
pods
:=
getSummaryTestPods
(
f
,
pod0
,
pod1
)
// Wait for cAdvisor to collect 2 stats points
f
.
PodClient
()
.
CreateBatch
(
pods
)
time
.
Sleep
(
15
*
time
.
Second
)
// Wait for cAdvisor to collect 2 stats points, and for pods to restart
time
.
Sleep
(
45
*
time
.
Second
)
// Setup expectations.
// Setup expectations.
const
(
const
(
...
@@ -131,16 +134,16 @@ var _ = framework.KubeDescribe("Summary API", func() {
...
@@ -131,16 +134,16 @@ var _ = framework.KubeDescribe("Summary API", func() {
"StartTime"
:
recent
(
maxStartAge
),
"StartTime"
:
recent
(
maxStartAge
),
"CPU"
:
ptrMatchAllFields
(
gstruct
.
Fields
{
"CPU"
:
ptrMatchAllFields
(
gstruct
.
Fields
{
"Time"
:
recent
(
maxStatsAge
),
"Time"
:
recent
(
maxStatsAge
),
"UsageNanoCores"
:
bounded
(
100000
,
100000000
),
"UsageNanoCores"
:
bounded
(
100000
,
100000000
0
),
"UsageCoreNanoSeconds"
:
bounded
(
10000000
,
1000000000
),
"UsageCoreNanoSeconds"
:
bounded
(
10000000
,
1000000000
00
),
}),
}),
"Memory"
:
ptrMatchAllFields
(
gstruct
.
Fields
{
"Memory"
:
ptrMatchAllFields
(
gstruct
.
Fields
{
"Time"
:
recent
(
maxStatsAge
),
"Time"
:
recent
(
maxStatsAge
),
"AvailableBytes"
:
bounded
(
1
*
m
b
,
10
*
mb
),
"AvailableBytes"
:
bounded
(
1
0
*
k
b
,
10
*
mb
),
"UsageBytes"
:
bounded
(
10
*
kb
,
5
*
mb
),
"UsageBytes"
:
bounded
(
10
*
kb
,
20
*
mb
),
"WorkingSetBytes"
:
bounded
(
10
*
kb
,
2
*
mb
),
"WorkingSetBytes"
:
bounded
(
10
*
kb
,
2
0
*
mb
),
"RSSBytes"
:
bounded
(
1
*
kb
,
mb
),
"RSSBytes"
:
bounded
(
1
*
kb
,
mb
),
"PageFaults"
:
bounded
(
100
,
100000
),
"PageFaults"
:
bounded
(
100
,
100000
0
),
"MajorPageFaults"
:
bounded
(
0
,
10
),
"MajorPageFaults"
:
bounded
(
0
,
10
),
}),
}),
"Rootfs"
:
ptrMatchAllFields
(
gstruct
.
Fields
{
"Rootfs"
:
ptrMatchAllFields
(
gstruct
.
Fields
{
...
@@ -259,7 +262,7 @@ var _ = framework.KubeDescribe("Summary API", func() {
...
@@ -259,7 +262,7 @@ var _ = framework.KubeDescribe("Summary API", func() {
})
})
})
})
func
createSummaryTestPods
(
f
*
framework
.
Framework
,
names
...
string
)
{
func
getSummaryTestPods
(
f
*
framework
.
Framework
,
names
...
string
)
[]
*
v1
.
Pod
{
pods
:=
make
([]
*
v1
.
Pod
,
0
,
len
(
names
))
pods
:=
make
([]
*
v1
.
Pod
,
0
,
len
(
names
))
for
_
,
name
:=
range
names
{
for
_
,
name
:=
range
names
{
pods
=
append
(
pods
,
&
v1
.
Pod
{
pods
=
append
(
pods
,
&
v1
.
Pod
{
...
@@ -272,7 +275,7 @@ func createSummaryTestPods(f *framework.Framework, names ...string) {
...
@@ -272,7 +275,7 @@ func createSummaryTestPods(f *framework.Framework, names ...string) {
{
{
Name
:
"busybox-container"
,
Name
:
"busybox-container"
,
Image
:
"gcr.io/google_containers/busybox:1.24"
,
Image
:
"gcr.io/google_containers/busybox:1.24"
,
Command
:
[]
string
{
"sh"
,
"-c"
,
"ping -c 1 google.com; while true; do echo 'hello world' >> /test-empty-dir-mnt/file ; sleep 1; done"
}
,
Command
:
getRestartingContainerCommand
(
"/test-empty-dir-mnt"
,
0
,
restartCount
,
"ping -c 1 google.com; echo 'hello world' >> /test-empty-dir-mnt/file"
)
,
Resources
:
v1
.
ResourceRequirements
{
Resources
:
v1
.
ResourceRequirements
{
Limits
:
v1
.
ResourceList
{
Limits
:
v1
.
ResourceList
{
// Must set memory limit to get MemoryStats.AvailableBytes
// Must set memory limit to get MemoryStats.AvailableBytes
...
@@ -297,7 +300,7 @@ func createSummaryTestPods(f *framework.Framework, names ...string) {
...
@@ -297,7 +300,7 @@ func createSummaryTestPods(f *framework.Framework, names ...string) {
},
},
})
})
}
}
f
.
PodClient
()
.
CreateBatch
(
pods
)
return
pods
}
}
// Mapping function for gstruct.MatchAllElements
// Mapping function for gstruct.MatchAllElements
...
...
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