diff --git a/pkg/scheduler/extender_test.go b/pkg/scheduler/extender_test.go index 44c3daee70c..ce7ed6ec466 100644 --- a/pkg/scheduler/extender_test.go +++ b/pkg/scheduler/extender_test.go @@ -93,6 +93,7 @@ func TestSchedulerWithExtenders(t *testing.T) { registerPlugins: []tf.RegisterPluginFunc{ tf.RegisterFilterPlugin("TrueFilter", tf.NewTrueFilterPlugin), tf.RegisterQueueSortPlugin(queuesort.Name, queuesort.New), + tf.RegisterScorePlugin("EqualPrioritizerPlugin", tf.NewEqualPrioritizerPlugin(), 20), tf.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New), }, extenders: []tf.FakeExtender{ @@ -245,6 +246,7 @@ func TestSchedulerWithExtenders(t *testing.T) { // because of the errors from errorPredicateExtender. registerPlugins: []tf.RegisterPluginFunc{ tf.RegisterFilterPlugin("TrueFilter", tf.NewTrueFilterPlugin), + tf.RegisterScorePlugin("EqualPrioritizerPlugin", tf.NewEqualPrioritizerPlugin(), 20), tf.RegisterQueueSortPlugin(queuesort.Name, queuesort.New), tf.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New), }, diff --git a/pkg/scheduler/schedule_one_test.go b/pkg/scheduler/schedule_one_test.go index 6e0291bc7a4..ee40f81f4c3 100644 --- a/pkg/scheduler/schedule_one_test.go +++ b/pkg/scheduler/schedule_one_test.go @@ -1814,6 +1814,7 @@ func TestSchedulerSchedulePod(t *testing.T) { registerPlugins: []tf.RegisterPluginFunc{ tf.RegisterQueueSortPlugin(queuesort.Name, queuesort.New), tf.RegisterFilterPlugin("TrueFilter", tf.NewTrueFilterPlugin), + tf.RegisterScorePlugin("EqualPrioritizerPlugin", tf.NewEqualPrioritizerPlugin(), 20), tf.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New), }, nodes: []string{"node1", "node2"}, @@ -1931,6 +1932,7 @@ func TestSchedulerSchedulePod(t *testing.T) { tf.RegisterQueueSortPlugin(queuesort.Name, queuesort.New), tf.RegisterPreFilterPlugin(volumebinding.Name, frameworkruntime.FactoryAdapter(fts, volumebinding.New)), tf.RegisterFilterPlugin("TrueFilter", tf.NewTrueFilterPlugin), + tf.RegisterScorePlugin("EqualPrioritizerPlugin", tf.NewEqualPrioritizerPlugin(), 20), tf.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New), }, nodes: []string{"node1", "node2"}, @@ -2044,6 +2046,7 @@ func TestSchedulerSchedulePod(t *testing.T) { "PreFilter", "Filter", ), + tf.RegisterScorePlugin("EqualPrioritizerPlugin", tf.NewEqualPrioritizerPlugin(), 20), tf.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New), }, nodes: []string{"node1", "node2", "node3"}, @@ -2317,6 +2320,7 @@ func TestSchedulerSchedulePod(t *testing.T) { }, }, nil }, "PreFilter", "Filter"), + tf.RegisterScorePlugin("EqualPrioritizerPlugin", tf.NewEqualPrioritizerPlugin(), 20), tf.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New), }, nodes: []string{"node1", "node2", "node3"}, @@ -3211,6 +3215,7 @@ func TestFairEvaluationForNodes(t *testing.T) { []tf.RegisterPluginFunc{ tf.RegisterQueueSortPlugin(queuesort.Name, queuesort.New), tf.RegisterFilterPlugin("TrueFilter", tf.NewTrueFilterPlugin), + tf.RegisterScorePlugin("EqualPrioritizerPlugin", tf.NewEqualPrioritizerPlugin(), 20), tf.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New), }, "", @@ -3289,6 +3294,7 @@ func TestPreferNominatedNodeFilterCallCounts(t *testing.T) { registerPlugins := []tf.RegisterPluginFunc{ tf.RegisterQueueSortPlugin(queuesort.Name, queuesort.New), registerFakeFilterFunc, + tf.RegisterScorePlugin("EqualPrioritizerPlugin", tf.NewEqualPrioritizerPlugin(), 20), tf.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New), } fwk, err := tf.NewFramework( diff --git a/pkg/scheduler/testing/framework/fake_extender.go b/pkg/scheduler/testing/framework/fake_extender.go index fa9479ff26a..3811df0b1a9 100644 --- a/pkg/scheduler/testing/framework/fake_extender.go +++ b/pkg/scheduler/testing/framework/fake_extender.go @@ -137,6 +137,30 @@ func (pl *node2PrioritizerPlugin) ScoreExtensions() framework.ScoreExtensions { return nil } +type equalPrioritizerPlugin struct{} + +// NewEqualPrioritizerPlugin returns a factory function to build equalPrioritizerPlugin. +func NewEqualPrioritizerPlugin() frameworkruntime.PluginFactory { + return func(_ context.Context, _ runtime.Object, _ framework.Handle) (framework.Plugin, error) { + return &equalPrioritizerPlugin{}, nil + } +} + +// Name returns the name of the plugin. +func (pl *equalPrioritizerPlugin) Name() string { + return "EqualPrioritizerPlugin" +} + +// Score returns score 1 for each node. +func (pl *equalPrioritizerPlugin) Score(_ context.Context, _ *framework.CycleState, _ *v1.Pod, _ string) (int64, *framework.Status) { + return int64(1), nil +} + +// ScoreExtensions returns nil. +func (pl *equalPrioritizerPlugin) ScoreExtensions() framework.ScoreExtensions { + return nil +} + // FakeExtender is a data struct which implements the Extender interface. type FakeExtender struct { // ExtenderName indicates this fake extender's name.