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
652f7966
Commit
652f7966
authored
Jun 01, 2017
by
zhengjiajin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve code coverage for kubelet
parent
7043372d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
0 deletions
+60
-0
image_gc_manager_test.go
pkg/kubelet/images/image_gc_manager_test.go
+60
-0
No files found.
pkg/kubelet/images/image_gc_manager_test.go
View file @
652f7966
...
...
@@ -463,3 +463,63 @@ func TestGarbageCollectImageNotOldEnough(t *testing.T) {
assert
.
EqualValues
(
1024
,
spaceFreed
)
assert
.
Len
(
fakeRuntime
.
ImageList
,
1
)
}
func
TestValidateImageGCPolicy
(
t
*
testing
.
T
)
{
testCases
:=
[]
struct
{
name
string
imageGCPolicy
ImageGCPolicy
expectErr
string
}{
{
name
:
"Test for LowThresholdPercent < HighThresholdPercent"
,
imageGCPolicy
:
ImageGCPolicy
{
HighThresholdPercent
:
2
,
LowThresholdPercent
:
1
,
},
},
{
name
:
"Test for HighThresholdPercent < 0,"
,
imageGCPolicy
:
ImageGCPolicy
{
HighThresholdPercent
:
-
1
,
},
expectErr
:
"invalid HighThresholdPercent -1, must be in range [0-100]"
,
},
{
name
:
"Test for HighThresholdPercent > 100"
,
imageGCPolicy
:
ImageGCPolicy
{
HighThresholdPercent
:
101
,
},
expectErr
:
"invalid HighThresholdPercent 101, must be in range [0-100]"
,
},
{
name
:
"Test for LowThresholdPercent < 0"
,
imageGCPolicy
:
ImageGCPolicy
{
LowThresholdPercent
:
-
1
,
},
expectErr
:
"invalid LowThresholdPercent -1, must be in range [0-100]"
,
},
{
name
:
"Test for LowThresholdPercent > 100"
,
imageGCPolicy
:
ImageGCPolicy
{
LowThresholdPercent
:
101
,
},
expectErr
:
"invalid LowThresholdPercent 101, must be in range [0-100]"
,
},
{
name
:
"Test for LowThresholdPercent > HighThresholdPercent"
,
imageGCPolicy
:
ImageGCPolicy
{
HighThresholdPercent
:
1
,
LowThresholdPercent
:
2
,
},
expectErr
:
"LowThresholdPercent 2 can not be higher than HighThresholdPercent 1"
,
},
}
for
_
,
tc
:=
range
testCases
{
if
_
,
err
:=
NewImageGCManager
(
nil
,
nil
,
nil
,
nil
,
tc
.
imageGCPolicy
);
err
!=
nil
{
if
err
.
Error
()
!=
tc
.
expectErr
{
t
.
Errorf
(
"[%s:]Expected err:%v, but got:%v"
,
tc
.
name
,
tc
.
expectErr
,
err
.
Error
())
}
}
}
}
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