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
a04e6f86
Commit
a04e6f86
authored
Jun 22, 2016
by
derekwaynecarr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add additional testing scenarios for compute resource requests=0
parent
444ce193
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
6 deletions
+17
-6
defaults_test.go
pkg/api/v1/defaults_test.go
+11
-6
qos_test.go
pkg/kubelet/qos/qos_test.go
+6
-0
No files found.
pkg/api/v1/defaults_test.go
View file @
a04e6f86
...
@@ -509,13 +509,17 @@ func TestSetDefaultObjectFieldSelectorAPIVersion(t *testing.T) {
...
@@ -509,13 +509,17 @@ func TestSetDefaultObjectFieldSelectorAPIVersion(t *testing.T) {
}
}
func
TestSetDefaultRequestsPod
(
t
*
testing
.
T
)
{
func
TestSetDefaultRequestsPod
(
t
*
testing
.
T
)
{
// verify we default if limits are specified
// verify we default if limits are specified
(and that request=0 is preserved)
s
:=
versioned
.
PodSpec
{}
s
:=
versioned
.
PodSpec
{}
s
.
Containers
=
[]
versioned
.
Container
{
s
.
Containers
=
[]
versioned
.
Container
{
{
{
Resources
:
versioned
.
ResourceRequirements
{
Resources
:
versioned
.
ResourceRequirements
{
Requests
:
versioned
.
ResourceList
{
versioned
.
ResourceMemory
:
resource
.
MustParse
(
"0"
),
},
Limits
:
versioned
.
ResourceList
{
Limits
:
versioned
.
ResourceList
{
versioned
.
ResourceCPU
:
resource
.
MustParse
(
"100m"
),
versioned
.
ResourceCPU
:
resource
.
MustParse
(
"100m"
),
versioned
.
ResourceMemory
:
resource
.
MustParse
(
"1Gi"
),
},
},
},
},
},
},
...
@@ -526,10 +530,12 @@ func TestSetDefaultRequestsPod(t *testing.T) {
...
@@ -526,10 +530,12 @@ func TestSetDefaultRequestsPod(t *testing.T) {
output
:=
roundTrip
(
t
,
runtime
.
Object
(
pod
))
output
:=
roundTrip
(
t
,
runtime
.
Object
(
pod
))
pod2
:=
output
.
(
*
versioned
.
Pod
)
pod2
:=
output
.
(
*
versioned
.
Pod
)
defaultRequest
:=
pod2
.
Spec
.
Containers
[
0
]
.
Resources
.
Requests
defaultRequest
:=
pod2
.
Spec
.
Containers
[
0
]
.
Resources
.
Requests
requestValue
:=
defaultRequest
[
versioned
.
ResourceCPU
]
if
requestValue
:=
defaultRequest
[
versioned
.
ResourceCPU
];
requestValue
.
String
()
!=
"100m"
{
if
requestValue
.
String
()
!=
"100m"
{
t
.
Errorf
(
"Expected request cpu: %s, got: %s"
,
"100m"
,
requestValue
.
String
())
t
.
Errorf
(
"Expected request cpu: %s, got: %s"
,
"100m"
,
requestValue
.
String
())
}
}
if
requestValue
:=
defaultRequest
[
versioned
.
ResourceMemory
];
requestValue
.
String
()
!=
"0"
{
t
.
Errorf
(
"Expected request memory: %s, got: %s"
,
"0"
,
requestValue
.
String
())
}
// verify we do nothing if no limits are specified
// verify we do nothing if no limits are specified
s
=
versioned
.
PodSpec
{}
s
=
versioned
.
PodSpec
{}
...
@@ -540,8 +546,7 @@ func TestSetDefaultRequestsPod(t *testing.T) {
...
@@ -540,8 +546,7 @@ func TestSetDefaultRequestsPod(t *testing.T) {
output
=
roundTrip
(
t
,
runtime
.
Object
(
pod
))
output
=
roundTrip
(
t
,
runtime
.
Object
(
pod
))
pod2
=
output
.
(
*
versioned
.
Pod
)
pod2
=
output
.
(
*
versioned
.
Pod
)
defaultRequest
=
pod2
.
Spec
.
Containers
[
0
]
.
Resources
.
Requests
defaultRequest
=
pod2
.
Spec
.
Containers
[
0
]
.
Resources
.
Requests
requestValue
=
defaultRequest
[
versioned
.
ResourceCPU
]
if
requestValue
:=
defaultRequest
[
versioned
.
ResourceCPU
];
requestValue
.
String
()
!=
"0"
{
if
requestValue
.
String
()
!=
"0"
{
t
.
Errorf
(
"Expected 0 request value, got: %s"
,
requestValue
.
String
())
t
.
Errorf
(
"Expected 0 request value, got: %s"
,
requestValue
.
String
())
}
}
}
}
...
...
pkg/kubelet/qos/qos_test.go
View file @
a04e6f86
...
@@ -123,6 +123,12 @@ func TestGetPodQos(t *testing.T) {
...
@@ -123,6 +123,12 @@ func TestGetPodQos(t *testing.T) {
}),
}),
expected
:
Burstable
,
expected
:
Burstable
,
},
},
{
pod
:
newPod
(
"burstable"
,
[]
api
.
Container
{
newContainer
(
"burstable"
,
getResourceList
(
"0"
,
"0"
),
getResourceList
(
"100m"
,
"200Mi"
)),
}),
expected
:
Burstable
,
},
}
}
for
_
,
testCase
:=
range
testCases
{
for
_
,
testCase
:=
range
testCases
{
if
actual
:=
GetPodQos
(
testCase
.
pod
);
testCase
.
expected
!=
actual
{
if
actual
:=
GetPodQos
(
testCase
.
pod
);
testCase
.
expected
!=
actual
{
...
...
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