Skip to content

Commit d871ab9

Browse files
authored
Merge pull request kubernetes#91278 from chendave/testcase
scheduler: Expand testcases to cover more plugin defaults
2 parents 52358fe + c74a5d4 commit d871ab9

File tree

1 file changed

+35
-3
lines changed

1 file changed

+35
-3
lines changed

pkg/scheduler/framework/v1alpha1/framework_test.go

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -470,11 +470,13 @@ func recordingPluginFactory(name string, result map[string]runtime.Object) Plugi
470470

471471
func TestNewFrameworkPluginDefaults(t *testing.T) {
472472
// In-tree plugins that use args.
473-
pluginsWithArgs := []string{"InterPodAffinity", "NodeLabel", "NodeResourcesFit", "RequestedToCapacityRatio", "PodTopologySpread"}
473+
pluginsWithArgs := []string{"InterPodAffinity", "NodeLabel", "NodeResourcesFit", "NodeResourcesLeastAllocated", "NodeResourcesMostAllocated", "PodTopologySpread", "RequestedToCapacityRatio"}
474474
plugins := config.Plugins{
475475
Filter: &config.PluginSet{},
476476
}
477477
// Use all plugins in Filter.
478+
// NOTE: This does not mean those plugins implemented `Filter` interfaces.
479+
// `TestPlugin` is created in this test to fake the behavior for test purpose.
478480
for _, name := range pluginsWithArgs {
479481
plugins.Filter.Enabled = append(plugins.Filter.Enabled, config.Plugin{Name: name})
480482
}
@@ -498,6 +500,12 @@ func TestNewFrameworkPluginDefaults(t *testing.T) {
498500
},
499501
"NodeLabel": &config.NodeLabelArgs{},
500502
"NodeResourcesFit": &config.NodeResourcesFitArgs{},
503+
"NodeResourcesLeastAllocated": &config.NodeResourcesLeastAllocatedArgs{
504+
Resources: []config.ResourceSpec{{Name: "cpu", Weight: 1}, {Name: "memory", Weight: 1}},
505+
},
506+
"NodeResourcesMostAllocated": &config.NodeResourcesMostAllocatedArgs{
507+
Resources: []config.ResourceSpec{{Name: "cpu", Weight: 1}, {Name: "memory", Weight: 1}},
508+
},
501509
"RequestedToCapacityRatio": &config.RequestedToCapacityRatioArgs{
502510
Resources: []config.ResourceSpec{{Name: "cpu", Weight: 1}, {Name: "memory", Weight: 1}},
503511
},
@@ -519,6 +527,24 @@ func TestNewFrameworkPluginDefaults(t *testing.T) {
519527
IgnoredResources: []string{"example.com/foo"},
520528
},
521529
},
530+
{
531+
Name: "NodeResourcesLeastAllocated",
532+
Args: &config.NodeResourcesLeastAllocatedArgs{
533+
Resources: []config.ResourceSpec{{Name: "resource", Weight: 4}},
534+
},
535+
},
536+
{
537+
Name: "NodeResourcesMostAllocated",
538+
Args: &config.NodeResourcesMostAllocatedArgs{
539+
Resources: []config.ResourceSpec{{Name: "resource", Weight: 3}},
540+
},
541+
},
542+
{
543+
Name: "RequestedToCapacityRatio",
544+
Args: &config.RequestedToCapacityRatioArgs{
545+
Resources: []config.ResourceSpec{{Name: "resource", Weight: 2}},
546+
},
547+
},
522548
},
523549
wantCfg: map[string]runtime.Object{
524550
"InterPodAffinity": &config.InterPodAffinityArgs{
@@ -528,10 +554,16 @@ func TestNewFrameworkPluginDefaults(t *testing.T) {
528554
"NodeResourcesFit": &config.NodeResourcesFitArgs{
529555
IgnoredResources: []string{"example.com/foo"},
530556
},
531-
"RequestedToCapacityRatio": &config.RequestedToCapacityRatioArgs{
532-
Resources: []config.ResourceSpec{{Name: "cpu", Weight: 1}, {Name: "memory", Weight: 1}},
557+
"NodeResourcesLeastAllocated": &config.NodeResourcesLeastAllocatedArgs{
558+
Resources: []config.ResourceSpec{{Name: "resource", Weight: 4}},
559+
},
560+
"NodeResourcesMostAllocated": &config.NodeResourcesMostAllocatedArgs{
561+
Resources: []config.ResourceSpec{{Name: "resource", Weight: 3}},
533562
},
534563
"PodTopologySpread": &config.PodTopologySpreadArgs{},
564+
"RequestedToCapacityRatio": &config.RequestedToCapacityRatioArgs{
565+
Resources: []config.ResourceSpec{{Name: "resource", Weight: 2}},
566+
},
535567
},
536568
},
537569
}

0 commit comments

Comments
 (0)