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
bc9c4614
Commit
bc9c4614
authored
Jun 07, 2016
by
Abhishek Gupta
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding test case for scheduler NodeConditionPredicate
parent
623e7dfa
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
0 deletions
+43
-0
factory_test.go
plugin/pkg/scheduler/factory/factory_test.go
+43
-0
No files found.
plugin/pkg/scheduler/factory/factory_test.go
View file @
bc9c4614
...
...
@@ -430,3 +430,46 @@ func TestInvalidFactoryArgs(t *testing.T) {
}
}
func
TestNodeConditionPredicate
(
t
*
testing
.
T
)
{
nodeFunc
:=
getNodeConditionPredicate
()
nodeList
:=
&
api
.
NodeList
{
Items
:
[]
api
.
Node
{
// node1 considered
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"node1"
},
Status
:
api
.
NodeStatus
{
Conditions
:
[]
api
.
NodeCondition
{{
Type
:
api
.
NodeReady
,
Status
:
api
.
ConditionTrue
}}}},
// node2 ignored - node not Ready
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"node2"
},
Status
:
api
.
NodeStatus
{
Conditions
:
[]
api
.
NodeCondition
{{
Type
:
api
.
NodeReady
,
Status
:
api
.
ConditionFalse
}}}},
// node3 ignored - node out of disk
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"node3"
},
Status
:
api
.
NodeStatus
{
Conditions
:
[]
api
.
NodeCondition
{{
Type
:
api
.
NodeOutOfDisk
,
Status
:
api
.
ConditionTrue
}}}},
// node4 considered
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"node4"
},
Status
:
api
.
NodeStatus
{
Conditions
:
[]
api
.
NodeCondition
{{
Type
:
api
.
NodeOutOfDisk
,
Status
:
api
.
ConditionFalse
}}}},
// node5 ignored - node out of disk
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"node5"
},
Status
:
api
.
NodeStatus
{
Conditions
:
[]
api
.
NodeCondition
{{
Type
:
api
.
NodeReady
,
Status
:
api
.
ConditionTrue
},
{
Type
:
api
.
NodeOutOfDisk
,
Status
:
api
.
ConditionTrue
}}}},
// node6 considered
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"node6"
},
Status
:
api
.
NodeStatus
{
Conditions
:
[]
api
.
NodeCondition
{{
Type
:
api
.
NodeReady
,
Status
:
api
.
ConditionTrue
},
{
Type
:
api
.
NodeOutOfDisk
,
Status
:
api
.
ConditionFalse
}}}},
// node7 ignored - node out of disk, node not Ready
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"node7"
},
Status
:
api
.
NodeStatus
{
Conditions
:
[]
api
.
NodeCondition
{{
Type
:
api
.
NodeReady
,
Status
:
api
.
ConditionFalse
},
{
Type
:
api
.
NodeOutOfDisk
,
Status
:
api
.
ConditionTrue
}}}},
// node8 ignored - node not Ready
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"node8"
},
Status
:
api
.
NodeStatus
{
Conditions
:
[]
api
.
NodeCondition
{{
Type
:
api
.
NodeReady
,
Status
:
api
.
ConditionFalse
},
{
Type
:
api
.
NodeOutOfDisk
,
Status
:
api
.
ConditionFalse
}}}},
// node9 ignored - node unschedulable
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"node9"
},
Spec
:
api
.
NodeSpec
{
Unschedulable
:
true
}},
// node10 considered
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"node10"
},
Spec
:
api
.
NodeSpec
{
Unschedulable
:
false
}},
// node11 considered
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"node11"
}},
},
}
nodeNames
:=
[]
string
{}
for
_
,
node
:=
range
nodeList
.
Items
{
if
nodeFunc
(
node
)
{
nodeNames
=
append
(
nodeNames
,
node
.
Name
)
}
}
expectedNodes
:=
[]
string
{
"node1"
,
"node4"
,
"node6"
,
"node10"
,
"node11"
}
if
!
reflect
.
DeepEqual
(
expectedNodes
,
nodeNames
)
{
t
.
Errorf
(
"expected: %v, got %v"
,
expectedNodes
,
nodeNames
)
}
}
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