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
4e503597
Commit
4e503597
authored
Feb 28, 2019
by
Sreemanti Ghosh
Committed by
nolancon
May 30, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Unit test for Topology Manager policy_strict and policy_preferred
parent
eff568e4
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
113 additions
and
0 deletions
+113
-0
policy_preferred_test.go
pkg/kubelet/cm/topologymanager/policy_preferred_test.go
+52
-0
policy_strict_test.go
pkg/kubelet/cm/topologymanager/policy_strict_test.go
+61
-0
No files found.
pkg/kubelet/cm/topologymanager/policy_preferred_test.go
0 → 100644
View file @
4e503597
/*
Copyright 2019 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
topologymanager
import
(
"testing"
)
func
TestCanAdmitPodResult1
(
t
*
testing
.
T
)
{
tcases
:=
[]
struct
{
name
string
affinity
bool
expected
bool
}{
{
name
:
"Affinity is set to false in topology hints"
,
affinity
:
false
,
expected
:
true
,
},
{
name
:
"Affinity is set to true in topology hints"
,
affinity
:
true
,
expected
:
true
,
},
}
for
_
,
tc
:=
range
tcases
{
policy
:=
NewPreferredPolicy
()
hints
:=
TopologyHints
{
Affinity
:
tc
.
affinity
,
}
result
:=
policy
.
CanAdmitPodResult
(
hints
)
if
result
.
Admit
!=
tc
.
expected
{
t
.
Errorf
(
"Expected Admit field in result to be %t, got %t"
,
tc
.
expected
,
result
.
Admit
)
}
}
}
pkg/kubelet/cm/topologymanager/policy_strict_test.go
0 → 100644
View file @
4e503597
/*
Copyright 2019 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
topologymanager
import
(
"testing"
)
func
TestCanAdmitPodResult
(
t
*
testing
.
T
)
{
tcases
:=
[]
struct
{
name
string
affinity
bool
expected
bool
}{
{
name
:
"Affinity is set to false in topology hints"
,
affinity
:
false
,
expected
:
false
,
},
{
name
:
"Affinity is set to true in topology hints"
,
affinity
:
true
,
expected
:
true
,
},
}
for
_
,
tc
:=
range
tcases
{
policy
:=
NewStrictPolicy
()
hints
:=
TopologyHints
{
Affinity
:
tc
.
affinity
,
}
result
:=
policy
.
CanAdmitPodResult
(
hints
)
if
result
.
Admit
!=
tc
.
expected
{
t
.
Errorf
(
"Expected Admit field in result to be %t, got %t"
,
tc
.
expected
,
result
.
Admit
)
}
if
tc
.
expected
==
false
{
if
len
(
result
.
Reason
)
==
0
{
t
.
Errorf
(
"Expected Reason field to be not empty"
)
}
if
len
(
result
.
Message
)
==
0
{
t
.
Errorf
(
"Expected Message field to be not empty"
)
}
}
}
}
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