mirror of
https://github.com/kubernetes-sigs/descheduler.git
synced 2026-01-28 14:41:10 +01:00
Merge pull request #1806 from ingvagabund/profile-refactoring
refactor(pkg/framework/profile): dedup unit test code
This commit is contained in:
2
pkg/api/v1alpha2/zz_generated.conversion.go
generated
2
pkg/api/v1alpha2/zz_generated.conversion.go
generated
@@ -2,7 +2,7 @@
|
|||||||
// +build !ignore_autogenerated
|
// +build !ignore_autogenerated
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2025 The Kubernetes Authors.
|
Copyright 2026 The Kubernetes Authors.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
2
pkg/api/v1alpha2/zz_generated.deepcopy.go
generated
2
pkg/api/v1alpha2/zz_generated.deepcopy.go
generated
@@ -2,7 +2,7 @@
|
|||||||
// +build !ignore_autogenerated
|
// +build !ignore_autogenerated
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2025 The Kubernetes Authors.
|
Copyright 2026 The Kubernetes Authors.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
2
pkg/api/v1alpha2/zz_generated.defaults.go
generated
2
pkg/api/v1alpha2/zz_generated.defaults.go
generated
@@ -2,7 +2,7 @@
|
|||||||
// +build !ignore_autogenerated
|
// +build !ignore_autogenerated
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2025 The Kubernetes Authors.
|
Copyright 2026 The Kubernetes Authors.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
2
pkg/api/zz_generated.deepcopy.go
generated
2
pkg/api/zz_generated.deepcopy.go
generated
@@ -2,7 +2,7 @@
|
|||||||
// +build !ignore_autogenerated
|
// +build !ignore_autogenerated
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2025 The Kubernetes Authors.
|
Copyright 2026 The Kubernetes Authors.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// +build !ignore_autogenerated
|
// +build !ignore_autogenerated
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2025 The Kubernetes Authors.
|
Copyright 2026 The Kubernetes Authors.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// +build !ignore_autogenerated
|
// +build !ignore_autogenerated
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2025 The Kubernetes Authors.
|
Copyright 2026 The Kubernetes Authors.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// +build !ignore_autogenerated
|
// +build !ignore_autogenerated
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2025 The Kubernetes Authors.
|
Copyright 2026 The Kubernetes Authors.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// +build !ignore_autogenerated
|
// +build !ignore_autogenerated
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2025 The Kubernetes Authors.
|
Copyright 2026 The Kubernetes Authors.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -408,3 +408,55 @@ func (d *FakeFilterPlugin) handleBoolAction(action Action) bool {
|
|||||||
}
|
}
|
||||||
panic(fmt.Errorf("unhandled %q action", action.GetExtensionPoint()))
|
panic(fmt.Errorf("unhandled %q action", action.GetExtensionPoint()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RegisterFakePlugin registers a FakePlugin with the given registry
|
||||||
|
func RegisterFakePlugin(name string, plugin *FakePlugin, registry pluginregistry.Registry) {
|
||||||
|
pluginregistry.Register(
|
||||||
|
name,
|
||||||
|
NewPluginFncFromFake(plugin),
|
||||||
|
&FakePlugin{},
|
||||||
|
&FakePluginArgs{},
|
||||||
|
ValidateFakePluginArgs,
|
||||||
|
SetDefaults_FakePluginArgs,
|
||||||
|
registry,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RegisterFakeDeschedulePlugin registers a FakeDeschedulePlugin with the given registry
|
||||||
|
func RegisterFakeDeschedulePlugin(name string, plugin *FakeDeschedulePlugin, registry pluginregistry.Registry) {
|
||||||
|
pluginregistry.Register(
|
||||||
|
name,
|
||||||
|
NewFakeDeschedulePluginFncFromFake(plugin),
|
||||||
|
&FakeDeschedulePlugin{},
|
||||||
|
&FakeDeschedulePluginArgs{},
|
||||||
|
ValidateFakePluginArgs,
|
||||||
|
SetDefaults_FakePluginArgs,
|
||||||
|
registry,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RegisterFakeBalancePlugin registers a FakeBalancePlugin with the given registry
|
||||||
|
func RegisterFakeBalancePlugin(name string, plugin *FakeBalancePlugin, registry pluginregistry.Registry) {
|
||||||
|
pluginregistry.Register(
|
||||||
|
name,
|
||||||
|
NewFakeBalancePluginFncFromFake(plugin),
|
||||||
|
&FakeBalancePlugin{},
|
||||||
|
&FakeBalancePluginArgs{},
|
||||||
|
ValidateFakePluginArgs,
|
||||||
|
SetDefaults_FakePluginArgs,
|
||||||
|
registry,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RegisterFakeFilterPlugin registers a FakeFilterPlugin with the given registry
|
||||||
|
func RegisterFakeFilterPlugin(name string, plugin *FakeFilterPlugin, registry pluginregistry.Registry) {
|
||||||
|
pluginregistry.Register(
|
||||||
|
name,
|
||||||
|
NewFakeFilterPluginFncFromFake(plugin),
|
||||||
|
&FakeFilterPlugin{},
|
||||||
|
&FakeFilterPluginArgs{},
|
||||||
|
ValidateFakePluginArgs,
|
||||||
|
SetDefaults_FakePluginArgs,
|
||||||
|
registry,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// +build !ignore_autogenerated
|
// +build !ignore_autogenerated
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2025 The Kubernetes Authors.
|
Copyright 2026 The Kubernetes Authors.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// +build !ignore_autogenerated
|
// +build !ignore_autogenerated
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2025 The Kubernetes Authors.
|
Copyright 2026 The Kubernetes Authors.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// +build !ignore_autogenerated
|
// +build !ignore_autogenerated
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2025 The Kubernetes Authors.
|
Copyright 2026 The Kubernetes Authors.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// +build !ignore_autogenerated
|
// +build !ignore_autogenerated
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2025 The Kubernetes Authors.
|
Copyright 2026 The Kubernetes Authors.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// +build !ignore_autogenerated
|
// +build !ignore_autogenerated
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2025 The Kubernetes Authors.
|
Copyright 2026 The Kubernetes Authors.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// +build !ignore_autogenerated
|
// +build !ignore_autogenerated
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2025 The Kubernetes Authors.
|
Copyright 2026 The Kubernetes Authors.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// +build !ignore_autogenerated
|
// +build !ignore_autogenerated
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2025 The Kubernetes Authors.
|
Copyright 2026 The Kubernetes Authors.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// +build !ignore_autogenerated
|
// +build !ignore_autogenerated
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2025 The Kubernetes Authors.
|
Copyright 2026 The Kubernetes Authors.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// +build !ignore_autogenerated
|
// +build !ignore_autogenerated
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2025 The Kubernetes Authors.
|
Copyright 2026 The Kubernetes Authors.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// +build !ignore_autogenerated
|
// +build !ignore_autogenerated
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2025 The Kubernetes Authors.
|
Copyright 2026 The Kubernetes Authors.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// +build !ignore_autogenerated
|
// +build !ignore_autogenerated
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2025 The Kubernetes Authors.
|
Copyright 2026 The Kubernetes Authors.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// +build !ignore_autogenerated
|
// +build !ignore_autogenerated
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2025 The Kubernetes Authors.
|
Copyright 2026 The Kubernetes Authors.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// +build !ignore_autogenerated
|
// +build !ignore_autogenerated
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2025 The Kubernetes Authors.
|
Copyright 2026 The Kubernetes Authors.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// +build !ignore_autogenerated
|
// +build !ignore_autogenerated
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2025 The Kubernetes Authors.
|
Copyright 2026 The Kubernetes Authors.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// +build !ignore_autogenerated
|
// +build !ignore_autogenerated
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2025 The Kubernetes Authors.
|
Copyright 2026 The Kubernetes Authors.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// +build !ignore_autogenerated
|
// +build !ignore_autogenerated
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2025 The Kubernetes Authors.
|
Copyright 2026 The Kubernetes Authors.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// +build !ignore_autogenerated
|
// +build !ignore_autogenerated
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2025 The Kubernetes Authors.
|
Copyright 2026 The Kubernetes Authors.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// +build !ignore_autogenerated
|
// +build !ignore_autogenerated
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2025 The Kubernetes Authors.
|
Copyright 2026 The Kubernetes Authors.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// +build !ignore_autogenerated
|
// +build !ignore_autogenerated
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2025 The Kubernetes Authors.
|
Copyright 2026 The Kubernetes Authors.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// +build !ignore_autogenerated
|
// +build !ignore_autogenerated
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2025 The Kubernetes Authors.
|
Copyright 2026 The Kubernetes Authors.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// +build !ignore_autogenerated
|
// +build !ignore_autogenerated
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2025 The Kubernetes Authors.
|
Copyright 2026 The Kubernetes Authors.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// +build !ignore_autogenerated
|
// +build !ignore_autogenerated
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2025 The Kubernetes Authors.
|
Copyright 2026 The Kubernetes Authors.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// +build !ignore_autogenerated
|
// +build !ignore_autogenerated
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2025 The Kubernetes Authors.
|
Copyright 2026 The Kubernetes Authors.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -26,7 +26,60 @@ import (
|
|||||||
testutils "sigs.k8s.io/descheduler/test"
|
testutils "sigs.k8s.io/descheduler/test"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// registerDefaultEvictor registers the DefaultEvictor plugin with the given registry
|
||||||
|
func registerDefaultEvictor(registry pluginregistry.Registry) {
|
||||||
|
pluginregistry.Register(
|
||||||
|
defaultevictor.PluginName,
|
||||||
|
defaultevictor.New,
|
||||||
|
&defaultevictor.DefaultEvictor{},
|
||||||
|
&defaultevictor.DefaultEvictorArgs{},
|
||||||
|
defaultevictor.ValidateDefaultEvictorArgs,
|
||||||
|
defaultevictor.SetDefaults_DefaultEvictorArgs,
|
||||||
|
registry,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
func TestProfileDescheduleBalanceExtensionPointsEviction(t *testing.T) {
|
func TestProfileDescheduleBalanceExtensionPointsEviction(t *testing.T) {
|
||||||
|
// Helper to build profile config with default Filter and PreEvictionFilter
|
||||||
|
buildProfileConfig := func(name string, descheduleEnabled, balanceEnabled bool) api.DeschedulerProfile {
|
||||||
|
config := api.DeschedulerProfile{
|
||||||
|
Name: name,
|
||||||
|
PluginConfigs: []api.PluginConfig{
|
||||||
|
{
|
||||||
|
Name: defaultevictor.PluginName,
|
||||||
|
Args: &defaultevictor.DefaultEvictorArgs{
|
||||||
|
PriorityThreshold: &api.PriorityThreshold{
|
||||||
|
Value: nil,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "FakePlugin",
|
||||||
|
Args: &fakeplugin.FakePluginArgs{},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Plugins: api.Plugins{
|
||||||
|
Filter: api.PluginSet{
|
||||||
|
Enabled: []string{defaultevictor.PluginName},
|
||||||
|
},
|
||||||
|
PreEvictionFilter: api.PluginSet{
|
||||||
|
Enabled: []string{defaultevictor.PluginName},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
if descheduleEnabled {
|
||||||
|
config.Plugins.Deschedule = api.PluginSet{
|
||||||
|
Enabled: []string{"FakePlugin"},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if balanceEnabled {
|
||||||
|
config.Plugins.Balance = api.PluginSet{
|
||||||
|
Enabled: []string{"FakePlugin"},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return config
|
||||||
|
}
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
config api.DeschedulerProfile
|
config api.DeschedulerProfile
|
||||||
@@ -34,134 +87,26 @@ func TestProfileDescheduleBalanceExtensionPointsEviction(t *testing.T) {
|
|||||||
expectedEviction bool
|
expectedEviction bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "profile with deschedule extension point enabled single eviction",
|
name: "profile with deschedule extension point enabled single eviction",
|
||||||
config: api.DeschedulerProfile{
|
config: buildProfileConfig("strategy-test-profile-with-deschedule", true, false),
|
||||||
Name: "strategy-test-profile-with-deschedule",
|
|
||||||
PluginConfigs: []api.PluginConfig{
|
|
||||||
{
|
|
||||||
Name: defaultevictor.PluginName,
|
|
||||||
Args: &defaultevictor.DefaultEvictorArgs{
|
|
||||||
PriorityThreshold: &api.PriorityThreshold{
|
|
||||||
Value: nil,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Name: "FakePlugin",
|
|
||||||
Args: &fakeplugin.FakePluginArgs{},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Plugins: api.Plugins{
|
|
||||||
Deschedule: api.PluginSet{
|
|
||||||
Enabled: []string{"FakePlugin"},
|
|
||||||
},
|
|
||||||
Filter: api.PluginSet{
|
|
||||||
Enabled: []string{defaultevictor.PluginName},
|
|
||||||
},
|
|
||||||
PreEvictionFilter: api.PluginSet{
|
|
||||||
Enabled: []string{defaultevictor.PluginName},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
extensionPoint: frameworktypes.DescheduleExtensionPoint,
|
extensionPoint: frameworktypes.DescheduleExtensionPoint,
|
||||||
expectedEviction: true,
|
expectedEviction: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "profile with balance extension point enabled single eviction",
|
name: "profile with balance extension point enabled single eviction",
|
||||||
config: api.DeschedulerProfile{
|
config: buildProfileConfig("strategy-test-profile-with-balance", false, true),
|
||||||
Name: "strategy-test-profile-with-balance",
|
|
||||||
PluginConfigs: []api.PluginConfig{
|
|
||||||
{
|
|
||||||
Name: defaultevictor.PluginName,
|
|
||||||
Args: &defaultevictor.DefaultEvictorArgs{
|
|
||||||
PriorityThreshold: &api.PriorityThreshold{
|
|
||||||
Value: nil,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Name: "FakePlugin",
|
|
||||||
Args: &fakeplugin.FakePluginArgs{},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Plugins: api.Plugins{
|
|
||||||
Balance: api.PluginSet{
|
|
||||||
Enabled: []string{"FakePlugin"},
|
|
||||||
},
|
|
||||||
Filter: api.PluginSet{
|
|
||||||
Enabled: []string{defaultevictor.PluginName},
|
|
||||||
},
|
|
||||||
PreEvictionFilter: api.PluginSet{
|
|
||||||
Enabled: []string{defaultevictor.PluginName},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
extensionPoint: frameworktypes.BalanceExtensionPoint,
|
extensionPoint: frameworktypes.BalanceExtensionPoint,
|
||||||
expectedEviction: true,
|
expectedEviction: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "profile with deschedule extension point balance enabled no eviction",
|
name: "profile with deschedule extension point balance enabled no eviction",
|
||||||
config: api.DeschedulerProfile{
|
config: buildProfileConfig("strategy-test-profile-with-balance", false, true),
|
||||||
Name: "strategy-test-profile-with-deschedule",
|
|
||||||
PluginConfigs: []api.PluginConfig{
|
|
||||||
{
|
|
||||||
Name: defaultevictor.PluginName,
|
|
||||||
Args: &defaultevictor.DefaultEvictorArgs{
|
|
||||||
PriorityThreshold: &api.PriorityThreshold{
|
|
||||||
Value: nil,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Name: "FakePlugin",
|
|
||||||
Args: &fakeplugin.FakePluginArgs{},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Plugins: api.Plugins{
|
|
||||||
Balance: api.PluginSet{
|
|
||||||
Enabled: []string{"FakePlugin"},
|
|
||||||
},
|
|
||||||
Filter: api.PluginSet{
|
|
||||||
Enabled: []string{defaultevictor.PluginName},
|
|
||||||
},
|
|
||||||
PreEvictionFilter: api.PluginSet{
|
|
||||||
Enabled: []string{defaultevictor.PluginName},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
extensionPoint: frameworktypes.DescheduleExtensionPoint,
|
extensionPoint: frameworktypes.DescheduleExtensionPoint,
|
||||||
expectedEviction: false,
|
expectedEviction: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "profile with balance extension point deschedule enabled no eviction",
|
name: "profile with balance extension point deschedule enabled no eviction",
|
||||||
config: api.DeschedulerProfile{
|
config: buildProfileConfig("strategy-test-profile-with-deschedule", true, false),
|
||||||
Name: "strategy-test-profile-with-deschedule",
|
|
||||||
PluginConfigs: []api.PluginConfig{
|
|
||||||
{
|
|
||||||
Name: defaultevictor.PluginName,
|
|
||||||
Args: &defaultevictor.DefaultEvictorArgs{
|
|
||||||
PriorityThreshold: &api.PriorityThreshold{
|
|
||||||
Value: nil,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Name: "FakePlugin",
|
|
||||||
Args: &fakeplugin.FakePluginArgs{},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Plugins: api.Plugins{
|
|
||||||
Deschedule: api.PluginSet{
|
|
||||||
Enabled: []string{"FakePlugin"},
|
|
||||||
},
|
|
||||||
Filter: api.PluginSet{
|
|
||||||
Enabled: []string{defaultevictor.PluginName},
|
|
||||||
},
|
|
||||||
PreEvictionFilter: api.PluginSet{
|
|
||||||
Enabled: []string{defaultevictor.PluginName},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
extensionPoint: frameworktypes.BalanceExtensionPoint,
|
extensionPoint: frameworktypes.BalanceExtensionPoint,
|
||||||
expectedEviction: false,
|
expectedEviction: false,
|
||||||
},
|
},
|
||||||
@@ -206,25 +151,9 @@ func TestProfileDescheduleBalanceExtensionPointsEviction(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pluginregistry.PluginRegistry = pluginregistry.NewRegistry()
|
pluginregistry.PluginRegistry = pluginregistry.NewRegistry()
|
||||||
pluginregistry.Register(
|
fakeplugin.RegisterFakePlugin("FakePlugin", &fakePlugin, pluginregistry.PluginRegistry)
|
||||||
"FakePlugin",
|
|
||||||
fakeplugin.NewPluginFncFromFake(&fakePlugin),
|
|
||||||
&fakeplugin.FakePlugin{},
|
|
||||||
&fakeplugin.FakePluginArgs{},
|
|
||||||
fakeplugin.ValidateFakePluginArgs,
|
|
||||||
fakeplugin.SetDefaults_FakePluginArgs,
|
|
||||||
pluginregistry.PluginRegistry,
|
|
||||||
)
|
|
||||||
|
|
||||||
pluginregistry.Register(
|
registerDefaultEvictor(pluginregistry.PluginRegistry)
|
||||||
defaultevictor.PluginName,
|
|
||||||
defaultevictor.New,
|
|
||||||
&defaultevictor.DefaultEvictor{},
|
|
||||||
&defaultevictor.DefaultEvictorArgs{},
|
|
||||||
defaultevictor.ValidateDefaultEvictorArgs,
|
|
||||||
defaultevictor.SetDefaults_DefaultEvictorArgs,
|
|
||||||
pluginregistry.PluginRegistry,
|
|
||||||
)
|
|
||||||
|
|
||||||
client := fakeclientset.NewSimpleClientset(n1, n2, p1)
|
client := fakeclientset.NewSimpleClientset(n1, n2, p1)
|
||||||
var evictedPods []string
|
var evictedPods []string
|
||||||
@@ -319,56 +248,13 @@ func TestProfileExtensionPoints(t *testing.T) {
|
|||||||
fakeBalancePlugin := &fakeplugin.FakeBalancePlugin{PluginName: balancePluginName}
|
fakeBalancePlugin := &fakeplugin.FakeBalancePlugin{PluginName: balancePluginName}
|
||||||
fakeFilterPlugin := &fakeplugin.FakeFilterPlugin{PluginName: filterPluginName}
|
fakeFilterPlugin := &fakeplugin.FakeFilterPlugin{PluginName: filterPluginName}
|
||||||
|
|
||||||
pluginregistry.Register(
|
fakeplugin.RegisterFakePlugin(fakePluginName, fakePlugin, pluginregistry.PluginRegistry)
|
||||||
fakePluginName,
|
fakeplugin.RegisterFakeDeschedulePlugin(deschedulePluginName, fakeDeschedulePlugin, pluginregistry.PluginRegistry)
|
||||||
fakeplugin.NewPluginFncFromFake(fakePlugin),
|
fakeplugin.RegisterFakeBalancePlugin(balancePluginName, fakeBalancePlugin, pluginregistry.PluginRegistry)
|
||||||
&fakeplugin.FakePlugin{},
|
fakeplugin.RegisterFakeFilterPlugin(filterPluginName, fakeFilterPlugin, pluginregistry.PluginRegistry)
|
||||||
&fakeplugin.FakePluginArgs{},
|
|
||||||
fakeplugin.ValidateFakePluginArgs,
|
|
||||||
fakeplugin.SetDefaults_FakePluginArgs,
|
|
||||||
pluginregistry.PluginRegistry,
|
|
||||||
)
|
|
||||||
|
|
||||||
pluginregistry.Register(
|
|
||||||
deschedulePluginName,
|
|
||||||
fakeplugin.NewFakeDeschedulePluginFncFromFake(fakeDeschedulePlugin),
|
|
||||||
&fakeplugin.FakeDeschedulePlugin{},
|
|
||||||
&fakeplugin.FakeDeschedulePluginArgs{},
|
|
||||||
fakeplugin.ValidateFakePluginArgs,
|
|
||||||
fakeplugin.SetDefaults_FakePluginArgs,
|
|
||||||
pluginregistry.PluginRegistry,
|
|
||||||
)
|
|
||||||
|
|
||||||
pluginregistry.Register(
|
|
||||||
balancePluginName,
|
|
||||||
fakeplugin.NewFakeBalancePluginFncFromFake(fakeBalancePlugin),
|
|
||||||
&fakeplugin.FakeBalancePlugin{},
|
|
||||||
&fakeplugin.FakeBalancePluginArgs{},
|
|
||||||
fakeplugin.ValidateFakePluginArgs,
|
|
||||||
fakeplugin.SetDefaults_FakePluginArgs,
|
|
||||||
pluginregistry.PluginRegistry,
|
|
||||||
)
|
|
||||||
|
|
||||||
pluginregistry.Register(
|
|
||||||
filterPluginName,
|
|
||||||
fakeplugin.NewFakeFilterPluginFncFromFake(fakeFilterPlugin),
|
|
||||||
&fakeplugin.FakeFilterPlugin{},
|
|
||||||
&fakeplugin.FakeFilterPluginArgs{},
|
|
||||||
fakeplugin.ValidateFakePluginArgs,
|
|
||||||
fakeplugin.SetDefaults_FakePluginArgs,
|
|
||||||
pluginregistry.PluginRegistry,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pluginregistry.Register(
|
registerDefaultEvictor(pluginregistry.PluginRegistry)
|
||||||
defaultevictor.PluginName,
|
|
||||||
defaultevictor.New,
|
|
||||||
&defaultevictor.DefaultEvictor{},
|
|
||||||
&defaultevictor.DefaultEvictorArgs{},
|
|
||||||
defaultevictor.ValidateDefaultEvictorArgs,
|
|
||||||
defaultevictor.SetDefaults_DefaultEvictorArgs,
|
|
||||||
pluginregistry.PluginRegistry,
|
|
||||||
)
|
|
||||||
|
|
||||||
client := fakeclientset.NewSimpleClientset(n1, n2, p1)
|
client := fakeclientset.NewSimpleClientset(n1, n2, p1)
|
||||||
var evictedPods []string
|
var evictedPods []string
|
||||||
@@ -524,15 +410,7 @@ func TestProfileExtensionPointOrdering(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// plugin implementing Filter extension point
|
// plugin implementing Filter extension point
|
||||||
pluginregistry.Register(
|
fakeplugin.RegisterFakeFilterPlugin(pluginName, fakeFilterPlugin, pluginregistry.PluginRegistry)
|
||||||
pluginName,
|
|
||||||
fakeplugin.NewFakeFilterPluginFncFromFake(fakeFilterPlugin),
|
|
||||||
&fakeplugin.FakeFilterPlugin{},
|
|
||||||
&fakeplugin.FakeFilterPluginArgs{},
|
|
||||||
fakeplugin.ValidateFakePluginArgs,
|
|
||||||
fakeplugin.SetDefaults_FakePluginArgs,
|
|
||||||
pluginregistry.PluginRegistry,
|
|
||||||
)
|
|
||||||
|
|
||||||
fakePluginName := fmt.Sprintf("FakePlugin_%v", i)
|
fakePluginName := fmt.Sprintf("FakePlugin_%v", i)
|
||||||
fakePlugin := fakeplugin.FakePlugin{}
|
fakePlugin := fakeplugin.FakePlugin{}
|
||||||
@@ -557,26 +435,10 @@ func TestProfileExtensionPointOrdering(t *testing.T) {
|
|||||||
return true, false, nil
|
return true, false, nil
|
||||||
})
|
})
|
||||||
|
|
||||||
pluginregistry.Register(
|
fakeplugin.RegisterFakePlugin(fakePluginName, &fakePlugin, pluginregistry.PluginRegistry)
|
||||||
fakePluginName,
|
|
||||||
fakeplugin.NewPluginFncFromFake(&fakePlugin),
|
|
||||||
&fakeplugin.FakePlugin{},
|
|
||||||
&fakeplugin.FakePluginArgs{},
|
|
||||||
fakeplugin.ValidateFakePluginArgs,
|
|
||||||
fakeplugin.SetDefaults_FakePluginArgs,
|
|
||||||
pluginregistry.PluginRegistry,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pluginregistry.Register(
|
registerDefaultEvictor(pluginregistry.PluginRegistry)
|
||||||
defaultevictor.PluginName,
|
|
||||||
defaultevictor.New,
|
|
||||||
&defaultevictor.DefaultEvictor{},
|
|
||||||
&defaultevictor.DefaultEvictorArgs{},
|
|
||||||
defaultevictor.ValidateDefaultEvictorArgs,
|
|
||||||
defaultevictor.SetDefaults_DefaultEvictorArgs,
|
|
||||||
pluginregistry.PluginRegistry,
|
|
||||||
)
|
|
||||||
|
|
||||||
client := fakeclientset.NewSimpleClientset(n1, n2, p1)
|
client := fakeclientset.NewSimpleClientset(n1, n2, p1)
|
||||||
var evictedPods []string
|
var evictedPods []string
|
||||||
|
|||||||
Reference in New Issue
Block a user