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
5e096fed
Commit
5e096fed
authored
Mar 02, 2015
by
Abhishek Gupta
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing test case to remove dependency on algorithm provider
parent
a04e600f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
15 deletions
+28
-15
factory_test.go
plugin/pkg/scheduler/factory/factory_test.go
+28
-15
No files found.
plugin/pkg/scheduler/factory/factory_test.go
View file @
5e096fed
...
...
@@ -49,6 +49,8 @@ func TestCreate(t *testing.T) {
factory
.
Create
()
}
// Test configures a scheduler from a policies defined in a file
// It combines some configurable predicate/priorities with some pre-defined ones
func
TestCreateFromConfig
(
t
*
testing
.
T
)
{
var
configData
[]
byte
var
policy
schedulerapi
.
Policy
...
...
@@ -63,16 +65,11 @@ func TestCreateFromConfig(t *testing.T) {
client
:=
client
.
NewOrDie
(
&
client
.
Config
{
Host
:
server
.
URL
,
Version
:
testapi
.
Version
()})
factory
:=
NewConfigFactory
(
client
)
// Register the predicate and priority functions
// These would be registered by the DefaultProvider in regular operation
RegisterFitPredicate
(
"PodFitsPorts"
,
algorithm
.
PodFitsPorts
)
RegisterFitPredicate
(
"PodFitsResources"
,
algorithm
.
NewResourceFitPredicate
(
MinionLister
))
RegisterFitPredicate
(
"NoDiskConflict"
,
algorithm
.
NoDiskConflict
)
RegisterFitPredicate
(
"MatchNodeSelector"
,
algorithm
.
NewSelectorMatchPredicate
(
MinionLister
))
RegisterFitPredicate
(
"HostName"
,
algorithm
.
PodFitsHost
)
RegisterPriorityFunction
(
"LeastRequestedPriority"
,
algorithm
.
LeastRequestedPriority
,
1
)
RegisterPriorityFunction
(
"ServiceSpreadingPriority"
,
algorithm
.
NewServiceSpreadPriority
(
ServiceLister
),
1
)
RegisterPriorityFunction
(
"EqualPriority"
,
algorithm
.
EqualPriority
,
0
)
// Pre-register some predicate and priority functions
RegisterFitPredicate
(
"PredicateOne"
,
PredicateOne
)
RegisterFitPredicate
(
"PredicateTwo"
,
PredicateTwo
)
RegisterPriorityFunction
(
"PriorityOne"
,
PriorityOne
,
1
)
RegisterPriorityFunction
(
"PriorityTwo"
,
PriorityTwo
,
1
)
configData
=
[]
byte
(
`{
"kind" : "Policy",
...
...
@@ -80,13 +77,13 @@ func TestCreateFromConfig(t *testing.T) {
"predicates" : [
{"name" : "TestZoneAffinity", "argument" : {"serviceAffinity" : {"labels" : ["zone"]}}},
{"name" : "TestRequireZone", "argument" : {"labelsPresence" : {"labels" : ["zone"], "presence" : true}}},
{"name" : "P
odFitsPorts
"},
{"name" : "
MatchNodeSelector
"}
{"name" : "P
redicateOne
"},
{"name" : "
PredicateTwo
"}
],
"priorities" : [
{"name" : "RackSpread", "weight" :
2
, "argument" : {"serviceAntiAffinity" : {"label" : "rack"}}},
{"name" : "
ServiceSpreadingPriority", "weight" : 1}
]
{"name" : "RackSpread", "weight" :
3
, "argument" : {"serviceAntiAffinity" : {"label" : "rack"}}},
{"name" : "
PriorityOne", "weight" : 2},
{"name" : "PriorityTwo", "weight" : 1}
]
}`
)
err
:=
latestschedulerapi
.
Codec
.
DecodeInto
(
configData
,
&
policy
)
if
err
!=
nil
{
...
...
@@ -119,6 +116,22 @@ func TestCreateFromEmptyConfig(t *testing.T) {
factory
.
CreateFromConfig
(
policy
)
}
func
PredicateOne
(
pod
api
.
Pod
,
existingPods
[]
api
.
Pod
,
node
string
)
(
bool
,
error
)
{
return
true
,
nil
}
func
PredicateTwo
(
pod
api
.
Pod
,
existingPods
[]
api
.
Pod
,
node
string
)
(
bool
,
error
)
{
return
true
,
nil
}
func
PriorityOne
(
pod
api
.
Pod
,
podLister
algorithm
.
PodLister
,
minionLister
algorithm
.
MinionLister
)
(
algorithm
.
HostPriorityList
,
error
)
{
return
[]
algorithm
.
HostPriority
{},
nil
}
func
PriorityTwo
(
pod
api
.
Pod
,
podLister
algorithm
.
PodLister
,
minionLister
algorithm
.
MinionLister
)
(
algorithm
.
HostPriorityList
,
error
)
{
return
[]
algorithm
.
HostPriority
{},
nil
}
func
TestPollMinions
(
t
*
testing
.
T
)
{
table
:=
[]
struct
{
minions
[]
api
.
Node
...
...
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