mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-06 18:54:06 +00:00
Fix existing unit test (add no op scoring plugin)
This commit is contained in:
parent
199dc03bdd
commit
feb23ec581
@ -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),
|
||||
},
|
||||
|
@ -1809,6 +1809,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"},
|
||||
@ -1926,6 +1927,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"},
|
||||
@ -2039,6 +2041,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"},
|
||||
@ -2279,6 +2282,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"},
|
||||
@ -3168,6 +3172,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),
|
||||
},
|
||||
"",
|
||||
@ -3246,6 +3251,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(
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user