Skip to content

Commit 52ad3d9

Browse files
committed
Add test for algorithm provider and policy config file
1 parent 11277d4 commit 52ad3d9

File tree

1 file changed

+105
-0
lines changed

1 file changed

+105
-0
lines changed

cmd/kube-scheduler/app/server_test.go

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,19 @@ profiles:
147147
t.Fatal(err)
148148
}
149149

150+
// policy config file
151+
policyConfigFile := filepath.Join(tmpDir, "policy-config.yaml")
152+
if err := ioutil.WriteFile(policyConfigFile, []byte(`{
153+
"kind": "Policy",
154+
"apiVersion": "v1",
155+
"predicates": [
156+
{"name": "MatchInterPodAffinity"}
157+
],"priorities": [
158+
{"name": "InterPodAffinityPriority", "weight": 2}
159+
]}`), os.FileMode(0600)); err != nil {
160+
t.Fatal(err)
161+
}
162+
150163
defaultPlugins := map[string][]kubeschedulerconfig.Plugin{
151164
"QueueSortPlugin": {
152165
{Name: "PrioritySort"},
@@ -259,6 +272,98 @@ profiles:
259272
"my-scheduler": defaultPlugins,
260273
},
261274
},
275+
{
276+
name: "default algorithm provider",
277+
flags: []string{
278+
"--kubeconfig", configKubeconfig,
279+
"--algorithm-provider", "DefaultProvider",
280+
},
281+
wantPlugins: map[string]map[string][]kubeschedulerconfig.Plugin{
282+
"default-scheduler": defaultPlugins,
283+
},
284+
},
285+
{
286+
name: "cluster autoscaler provider",
287+
flags: []string{
288+
"--kubeconfig", configKubeconfig,
289+
"--algorithm-provider", "ClusterAutoscalerProvider",
290+
},
291+
wantPlugins: map[string]map[string][]kubeschedulerconfig.Plugin{
292+
"default-scheduler": {
293+
"QueueSortPlugin": {
294+
{Name: "PrioritySort"},
295+
},
296+
"PreFilterPlugin": {
297+
{Name: "NodeResourcesFit"},
298+
{Name: "NodePorts"},
299+
{Name: "InterPodAffinity"},
300+
{Name: "PodTopologySpread"},
301+
},
302+
"FilterPlugin": {
303+
{Name: "NodeUnschedulable"},
304+
{Name: "NodeResourcesFit"},
305+
{Name: "NodeName"},
306+
{Name: "NodePorts"},
307+
{Name: "NodeAffinity"},
308+
{Name: "VolumeRestrictions"},
309+
{Name: "TaintToleration"},
310+
{Name: "EBSLimits"},
311+
{Name: "GCEPDLimits"},
312+
{Name: "NodeVolumeLimits"},
313+
{Name: "AzureDiskLimits"},
314+
{Name: "VolumeBinding"},
315+
{Name: "VolumeZone"},
316+
{Name: "InterPodAffinity"},
317+
{Name: "PodTopologySpread"},
318+
},
319+
"PreScorePlugin": {
320+
{Name: "InterPodAffinity"},
321+
{Name: "DefaultPodTopologySpread"},
322+
{Name: "TaintToleration"},
323+
{Name: "PodTopologySpread"},
324+
},
325+
"ScorePlugin": {
326+
{Name: "NodeResourcesBalancedAllocation", Weight: 1},
327+
{Name: "ImageLocality", Weight: 1},
328+
{Name: "InterPodAffinity", Weight: 1},
329+
{Name: "NodeResourcesMostAllocated", Weight: 1},
330+
{Name: "NodeAffinity", Weight: 1},
331+
{Name: "NodePreferAvoidPods", Weight: 10000},
332+
{Name: "DefaultPodTopologySpread", Weight: 1},
333+
{Name: "TaintToleration", Weight: 1},
334+
{Name: "PodTopologySpread", Weight: 1},
335+
},
336+
"BindPlugin": {{Name: "DefaultBinder"}},
337+
},
338+
},
339+
},
340+
{
341+
name: "policy config file",
342+
flags: []string{
343+
"--kubeconfig", configKubeconfig,
344+
"--policy-config-file", policyConfigFile,
345+
},
346+
wantPlugins: map[string]map[string][]kubeschedulerconfig.Plugin{
347+
"default-scheduler": {
348+
"QueueSortPlugin": {{Name: "PrioritySort"}},
349+
"PreFilterPlugin": {
350+
{Name: "InterPodAffinity"},
351+
},
352+
"FilterPlugin": {
353+
{Name: "NodeUnschedulable"},
354+
{Name: "TaintToleration"},
355+
{Name: "InterPodAffinity"},
356+
},
357+
"PreScorePlugin": {
358+
{Name: "InterPodAffinity"},
359+
},
360+
"ScorePlugin": {
361+
{Name: "InterPodAffinity", Weight: 2},
362+
},
363+
"BindPlugin": {{Name: "DefaultBinder"}},
364+
},
365+
},
366+
},
262367
}
263368

264369
for _, tc := range testcases {

0 commit comments

Comments
 (0)