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
793ed987
Commit
793ed987
authored
Apr 25, 2018
by
Da K. Ma
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added more UT for invalid case.
Signed-off-by:
Da K. Ma
<
klaus1982.cn@gmail.com
>
parent
2d84501d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
0 deletions
+53
-0
validation_test.go
pkg/apis/core/validation/validation_test.go
+25
-0
predicates_test.go
pkg/scheduler/algorithm/predicates/predicates_test.go
+28
-0
No files found.
pkg/apis/core/validation/validation_test.go
View file @
793ed987
...
@@ -6522,6 +6522,31 @@ func TestValidatePod(t *testing.T) {
...
@@ -6522,6 +6522,31 @@ func TestValidatePod(t *testing.T) {
}),
}),
},
},
},
},
"invalid node selector requirement in node affinity, key is invalid"
:
{
expectedError
:
"spec.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchExpressions[0].key"
,
spec
:
core
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"123"
,
Namespace
:
"ns"
,
},
Spec
:
validPodSpec
(
&
core
.
Affinity
{
NodeAffinity
:
&
core
.
NodeAffinity
{
RequiredDuringSchedulingIgnoredDuringExecution
:
&
core
.
NodeSelector
{
NodeSelectorTerms
:
[]
core
.
NodeSelectorTerm
{
{
MatchExpressions
:
[]
core
.
NodeSelectorRequirement
{
{
Key
:
"invalid key ___@#"
,
Operator
:
core
.
NodeSelectorOpExists
,
},
},
},
},
},
},
}),
},
},
"invalid node field selector requirement in node affinity, more values for field selector"
:
{
"invalid node field selector requirement in node affinity, more values for field selector"
:
{
expectedError
:
"spec.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchFields[0].values"
,
expectedError
:
"spec.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchFields[0].values"
,
spec
:
core
.
Pod
{
spec
:
core
.
Pod
{
...
...
pkg/scheduler/algorithm/predicates/predicates_test.go
View file @
793ed987
...
@@ -1359,6 +1359,34 @@ func TestPodFitsSelector(t *testing.T) {
...
@@ -1359,6 +1359,34 @@ func TestPodFitsSelector(t *testing.T) {
test
:
"Pod with an Affinity matches node's labels but the PodSpec.NodeSelector(the old thing that we are deprecating) "
+
test
:
"Pod with an Affinity matches node's labels but the PodSpec.NodeSelector(the old thing that we are deprecating) "
+
"is not satisfied, won't schedule onto the node"
,
"is not satisfied, won't schedule onto the node"
,
},
},
{
pod
:
&
v1
.
Pod
{
Spec
:
v1
.
PodSpec
{
Affinity
:
&
v1
.
Affinity
{
NodeAffinity
:
&
v1
.
NodeAffinity
{
RequiredDuringSchedulingIgnoredDuringExecution
:
&
v1
.
NodeSelector
{
NodeSelectorTerms
:
[]
v1
.
NodeSelectorTerm
{
{
MatchExpressions
:
[]
v1
.
NodeSelectorRequirement
{
{
Key
:
"foo"
,
Operator
:
v1
.
NodeSelectorOpNotIn
,
Values
:
[]
string
{
"invalid value: ___@#$%^"
},
},
},
},
},
},
},
},
},
},
labels
:
map
[
string
]
string
{
"foo"
:
"bar"
,
},
fits
:
false
,
test
:
"Pod with an invalid value in Affinity term won't be scheduled onto the node"
,
},
}
}
expectedFailureReasons
:=
[]
algorithm
.
PredicateFailureReason
{
ErrNodeSelectorNotMatch
}
expectedFailureReasons
:=
[]
algorithm
.
PredicateFailureReason
{
ErrNodeSelectorNotMatch
}
...
...
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