mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-30 15:02:23 +00:00
Fix existing unit test (add no op scoring plugin)
This commit is contained in:
parent
e19be41f58
commit
7abba24231
@ -93,6 +93,7 @@ func TestSchedulerWithExtenders(t *testing.T) {
|
|||||||
registerPlugins: []tf.RegisterPluginFunc{
|
registerPlugins: []tf.RegisterPluginFunc{
|
||||||
tf.RegisterFilterPlugin("TrueFilter", tf.NewTrueFilterPlugin),
|
tf.RegisterFilterPlugin("TrueFilter", tf.NewTrueFilterPlugin),
|
||||||
tf.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
|
tf.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
|
||||||
|
tf.RegisterScorePlugin("EqualPrioritizerPlugin", tf.NewEqualPrioritizerPlugin(), 20),
|
||||||
tf.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
|
tf.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
|
||||||
},
|
},
|
||||||
extenders: []tf.FakeExtender{
|
extenders: []tf.FakeExtender{
|
||||||
@ -245,6 +246,7 @@ func TestSchedulerWithExtenders(t *testing.T) {
|
|||||||
// because of the errors from errorPredicateExtender.
|
// because of the errors from errorPredicateExtender.
|
||||||
registerPlugins: []tf.RegisterPluginFunc{
|
registerPlugins: []tf.RegisterPluginFunc{
|
||||||
tf.RegisterFilterPlugin("TrueFilter", tf.NewTrueFilterPlugin),
|
tf.RegisterFilterPlugin("TrueFilter", tf.NewTrueFilterPlugin),
|
||||||
|
tf.RegisterScorePlugin("EqualPrioritizerPlugin", tf.NewEqualPrioritizerPlugin(), 20),
|
||||||
tf.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
|
tf.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
|
||||||
tf.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
|
tf.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
|
||||||
},
|
},
|
||||||
|
@ -1814,6 +1814,7 @@ func TestSchedulerSchedulePod(t *testing.T) {
|
|||||||
registerPlugins: []tf.RegisterPluginFunc{
|
registerPlugins: []tf.RegisterPluginFunc{
|
||||||
tf.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
|
tf.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
|
||||||
tf.RegisterFilterPlugin("TrueFilter", tf.NewTrueFilterPlugin),
|
tf.RegisterFilterPlugin("TrueFilter", tf.NewTrueFilterPlugin),
|
||||||
|
tf.RegisterScorePlugin("EqualPrioritizerPlugin", tf.NewEqualPrioritizerPlugin(), 20),
|
||||||
tf.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
|
tf.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
|
||||||
},
|
},
|
||||||
nodes: []string{"node1", "node2"},
|
nodes: []string{"node1", "node2"},
|
||||||
@ -1931,6 +1932,7 @@ func TestSchedulerSchedulePod(t *testing.T) {
|
|||||||
tf.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
|
tf.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
|
||||||
tf.RegisterPreFilterPlugin(volumebinding.Name, frameworkruntime.FactoryAdapter(fts, volumebinding.New)),
|
tf.RegisterPreFilterPlugin(volumebinding.Name, frameworkruntime.FactoryAdapter(fts, volumebinding.New)),
|
||||||
tf.RegisterFilterPlugin("TrueFilter", tf.NewTrueFilterPlugin),
|
tf.RegisterFilterPlugin("TrueFilter", tf.NewTrueFilterPlugin),
|
||||||
|
tf.RegisterScorePlugin("EqualPrioritizerPlugin", tf.NewEqualPrioritizerPlugin(), 20),
|
||||||
tf.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
|
tf.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
|
||||||
},
|
},
|
||||||
nodes: []string{"node1", "node2"},
|
nodes: []string{"node1", "node2"},
|
||||||
@ -2044,6 +2046,7 @@ func TestSchedulerSchedulePod(t *testing.T) {
|
|||||||
"PreFilter",
|
"PreFilter",
|
||||||
"Filter",
|
"Filter",
|
||||||
),
|
),
|
||||||
|
tf.RegisterScorePlugin("EqualPrioritizerPlugin", tf.NewEqualPrioritizerPlugin(), 20),
|
||||||
tf.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
|
tf.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
|
||||||
},
|
},
|
||||||
nodes: []string{"node1", "node2", "node3"},
|
nodes: []string{"node1", "node2", "node3"},
|
||||||
@ -2317,6 +2320,7 @@ func TestSchedulerSchedulePod(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
}, "PreFilter", "Filter"),
|
}, "PreFilter", "Filter"),
|
||||||
|
tf.RegisterScorePlugin("EqualPrioritizerPlugin", tf.NewEqualPrioritizerPlugin(), 20),
|
||||||
tf.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
|
tf.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
|
||||||
},
|
},
|
||||||
nodes: []string{"node1", "node2", "node3"},
|
nodes: []string{"node1", "node2", "node3"},
|
||||||
@ -3211,6 +3215,7 @@ func TestFairEvaluationForNodes(t *testing.T) {
|
|||||||
[]tf.RegisterPluginFunc{
|
[]tf.RegisterPluginFunc{
|
||||||
tf.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
|
tf.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
|
||||||
tf.RegisterFilterPlugin("TrueFilter", tf.NewTrueFilterPlugin),
|
tf.RegisterFilterPlugin("TrueFilter", tf.NewTrueFilterPlugin),
|
||||||
|
tf.RegisterScorePlugin("EqualPrioritizerPlugin", tf.NewEqualPrioritizerPlugin(), 20),
|
||||||
tf.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
|
tf.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
|
||||||
},
|
},
|
||||||
"",
|
"",
|
||||||
@ -3289,6 +3294,7 @@ func TestPreferNominatedNodeFilterCallCounts(t *testing.T) {
|
|||||||
registerPlugins := []tf.RegisterPluginFunc{
|
registerPlugins := []tf.RegisterPluginFunc{
|
||||||
tf.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
|
tf.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
|
||||||
registerFakeFilterFunc,
|
registerFakeFilterFunc,
|
||||||
|
tf.RegisterScorePlugin("EqualPrioritizerPlugin", tf.NewEqualPrioritizerPlugin(), 20),
|
||||||
tf.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
|
tf.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
|
||||||
}
|
}
|
||||||
fwk, err := tf.NewFramework(
|
fwk, err := tf.NewFramework(
|
||||||
|
@ -137,6 +137,30 @@ func (pl *node2PrioritizerPlugin) ScoreExtensions() framework.ScoreExtensions {
|
|||||||
return nil
|
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.
|
// FakeExtender is a data struct which implements the Extender interface.
|
||||||
type FakeExtender struct {
|
type FakeExtender struct {
|
||||||
// ExtenderName indicates this fake extender's name.
|
// ExtenderName indicates this fake extender's name.
|
||||||
|
Loading…
Reference in New Issue
Block a user