diff --git a/pkg/api/v1alpha2/zz_generated.conversion.go b/pkg/api/v1alpha2/zz_generated.conversion.go index ad4d7fa7b..f3a206fc9 100644 --- a/pkg/api/v1alpha2/zz_generated.conversion.go +++ b/pkg/api/v1alpha2/zz_generated.conversion.go @@ -2,7 +2,7 @@ // +build !ignore_autogenerated /* -Copyright 2025 The Kubernetes Authors. +Copyright 2026 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/pkg/api/v1alpha2/zz_generated.deepcopy.go b/pkg/api/v1alpha2/zz_generated.deepcopy.go index 5de5bfd72..6923e3f9b 100644 --- a/pkg/api/v1alpha2/zz_generated.deepcopy.go +++ b/pkg/api/v1alpha2/zz_generated.deepcopy.go @@ -2,7 +2,7 @@ // +build !ignore_autogenerated /* -Copyright 2025 The Kubernetes Authors. +Copyright 2026 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/pkg/api/v1alpha2/zz_generated.defaults.go b/pkg/api/v1alpha2/zz_generated.defaults.go index a2d19a7d3..feb0db1b8 100644 --- a/pkg/api/v1alpha2/zz_generated.defaults.go +++ b/pkg/api/v1alpha2/zz_generated.defaults.go @@ -2,7 +2,7 @@ // +build !ignore_autogenerated /* -Copyright 2025 The Kubernetes Authors. +Copyright 2026 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/pkg/api/zz_generated.deepcopy.go b/pkg/api/zz_generated.deepcopy.go index 01c2c31bc..885657cc9 100644 --- a/pkg/api/zz_generated.deepcopy.go +++ b/pkg/api/zz_generated.deepcopy.go @@ -2,7 +2,7 @@ // +build !ignore_autogenerated /* -Copyright 2025 The Kubernetes Authors. +Copyright 2026 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/pkg/apis/componentconfig/v1alpha1/zz_generated.conversion.go b/pkg/apis/componentconfig/v1alpha1/zz_generated.conversion.go index bf5ab4422..067e46707 100644 --- a/pkg/apis/componentconfig/v1alpha1/zz_generated.conversion.go +++ b/pkg/apis/componentconfig/v1alpha1/zz_generated.conversion.go @@ -2,7 +2,7 @@ // +build !ignore_autogenerated /* -Copyright 2025 The Kubernetes Authors. +Copyright 2026 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/pkg/apis/componentconfig/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/componentconfig/v1alpha1/zz_generated.deepcopy.go index 229e6cd57..dc4679ddf 100644 --- a/pkg/apis/componentconfig/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/componentconfig/v1alpha1/zz_generated.deepcopy.go @@ -2,7 +2,7 @@ // +build !ignore_autogenerated /* -Copyright 2025 The Kubernetes Authors. +Copyright 2026 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/pkg/apis/componentconfig/v1alpha1/zz_generated.defaults.go b/pkg/apis/componentconfig/v1alpha1/zz_generated.defaults.go index 12339a4cc..8b135950a 100644 --- a/pkg/apis/componentconfig/v1alpha1/zz_generated.defaults.go +++ b/pkg/apis/componentconfig/v1alpha1/zz_generated.defaults.go @@ -2,7 +2,7 @@ // +build !ignore_autogenerated /* -Copyright 2025 The Kubernetes Authors. +Copyright 2026 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/pkg/apis/componentconfig/zz_generated.deepcopy.go b/pkg/apis/componentconfig/zz_generated.deepcopy.go index 4d9c86c34..33081eb1e 100644 --- a/pkg/apis/componentconfig/zz_generated.deepcopy.go +++ b/pkg/apis/componentconfig/zz_generated.deepcopy.go @@ -2,7 +2,7 @@ // +build !ignore_autogenerated /* -Copyright 2025 The Kubernetes Authors. +Copyright 2026 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/pkg/framework/fake/plugin/fake.go b/pkg/framework/fake/plugin/fake.go index c745a84e1..327b1bb36 100644 --- a/pkg/framework/fake/plugin/fake.go +++ b/pkg/framework/fake/plugin/fake.go @@ -408,3 +408,55 @@ func (d *FakeFilterPlugin) handleBoolAction(action Action) bool { } 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, + ) +} diff --git a/pkg/framework/fake/plugin/zz_generated.deepcopy.go b/pkg/framework/fake/plugin/zz_generated.deepcopy.go index da83223aa..d553ca5a6 100644 --- a/pkg/framework/fake/plugin/zz_generated.deepcopy.go +++ b/pkg/framework/fake/plugin/zz_generated.deepcopy.go @@ -2,7 +2,7 @@ // +build !ignore_autogenerated /* -Copyright 2025 The Kubernetes Authors. +Copyright 2026 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/pkg/framework/plugins/defaultevictor/zz_generated.deepcopy.go b/pkg/framework/plugins/defaultevictor/zz_generated.deepcopy.go index 84199183a..579b18f19 100644 --- a/pkg/framework/plugins/defaultevictor/zz_generated.deepcopy.go +++ b/pkg/framework/plugins/defaultevictor/zz_generated.deepcopy.go @@ -2,7 +2,7 @@ // +build !ignore_autogenerated /* -Copyright 2025 The Kubernetes Authors. +Copyright 2026 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/pkg/framework/plugins/defaultevictor/zz_generated.defaults.go b/pkg/framework/plugins/defaultevictor/zz_generated.defaults.go index 2c58275df..4bb535b3d 100644 --- a/pkg/framework/plugins/defaultevictor/zz_generated.defaults.go +++ b/pkg/framework/plugins/defaultevictor/zz_generated.defaults.go @@ -2,7 +2,7 @@ // +build !ignore_autogenerated /* -Copyright 2025 The Kubernetes Authors. +Copyright 2026 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/pkg/framework/plugins/example/zz_generated.deepcopy.go b/pkg/framework/plugins/example/zz_generated.deepcopy.go index 92eaf82dc..4d5de8a93 100644 --- a/pkg/framework/plugins/example/zz_generated.deepcopy.go +++ b/pkg/framework/plugins/example/zz_generated.deepcopy.go @@ -2,7 +2,7 @@ // +build !ignore_autogenerated /* -Copyright 2025 The Kubernetes Authors. +Copyright 2026 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/pkg/framework/plugins/example/zz_generated.defaults.go b/pkg/framework/plugins/example/zz_generated.defaults.go index 16f62cd5b..e7e89af75 100644 --- a/pkg/framework/plugins/example/zz_generated.defaults.go +++ b/pkg/framework/plugins/example/zz_generated.defaults.go @@ -2,7 +2,7 @@ // +build !ignore_autogenerated /* -Copyright 2025 The Kubernetes Authors. +Copyright 2026 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/pkg/framework/plugins/nodeutilization/zz_generated.deepcopy.go b/pkg/framework/plugins/nodeutilization/zz_generated.deepcopy.go index 7f84492b9..fe0b40be8 100644 --- a/pkg/framework/plugins/nodeutilization/zz_generated.deepcopy.go +++ b/pkg/framework/plugins/nodeutilization/zz_generated.deepcopy.go @@ -2,7 +2,7 @@ // +build !ignore_autogenerated /* -Copyright 2025 The Kubernetes Authors. +Copyright 2026 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/pkg/framework/plugins/nodeutilization/zz_generated.defaults.go b/pkg/framework/plugins/nodeutilization/zz_generated.defaults.go index 617726cbf..2e0f350fe 100644 --- a/pkg/framework/plugins/nodeutilization/zz_generated.defaults.go +++ b/pkg/framework/plugins/nodeutilization/zz_generated.defaults.go @@ -2,7 +2,7 @@ // +build !ignore_autogenerated /* -Copyright 2025 The Kubernetes Authors. +Copyright 2026 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/pkg/framework/plugins/podlifetime/zz_generated.deepcopy.go b/pkg/framework/plugins/podlifetime/zz_generated.deepcopy.go index aa73c5a13..4e1794da9 100644 --- a/pkg/framework/plugins/podlifetime/zz_generated.deepcopy.go +++ b/pkg/framework/plugins/podlifetime/zz_generated.deepcopy.go @@ -2,7 +2,7 @@ // +build !ignore_autogenerated /* -Copyright 2025 The Kubernetes Authors. +Copyright 2026 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/pkg/framework/plugins/podlifetime/zz_generated.defaults.go b/pkg/framework/plugins/podlifetime/zz_generated.defaults.go index ee9ef084e..e92e13817 100644 --- a/pkg/framework/plugins/podlifetime/zz_generated.defaults.go +++ b/pkg/framework/plugins/podlifetime/zz_generated.defaults.go @@ -2,7 +2,7 @@ // +build !ignore_autogenerated /* -Copyright 2025 The Kubernetes Authors. +Copyright 2026 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/pkg/framework/plugins/removeduplicates/zz_generated.deepcopy.go b/pkg/framework/plugins/removeduplicates/zz_generated.deepcopy.go index 2a4b13383..490540e53 100644 --- a/pkg/framework/plugins/removeduplicates/zz_generated.deepcopy.go +++ b/pkg/framework/plugins/removeduplicates/zz_generated.deepcopy.go @@ -2,7 +2,7 @@ // +build !ignore_autogenerated /* -Copyright 2025 The Kubernetes Authors. +Copyright 2026 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/pkg/framework/plugins/removeduplicates/zz_generated.defaults.go b/pkg/framework/plugins/removeduplicates/zz_generated.defaults.go index 0777c1991..ce0b0877f 100644 --- a/pkg/framework/plugins/removeduplicates/zz_generated.defaults.go +++ b/pkg/framework/plugins/removeduplicates/zz_generated.defaults.go @@ -2,7 +2,7 @@ // +build !ignore_autogenerated /* -Copyright 2025 The Kubernetes Authors. +Copyright 2026 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/pkg/framework/plugins/removefailedpods/zz_generated.deepcopy.go b/pkg/framework/plugins/removefailedpods/zz_generated.deepcopy.go index 3a22a4d43..2abfd230e 100644 --- a/pkg/framework/plugins/removefailedpods/zz_generated.deepcopy.go +++ b/pkg/framework/plugins/removefailedpods/zz_generated.deepcopy.go @@ -2,7 +2,7 @@ // +build !ignore_autogenerated /* -Copyright 2025 The Kubernetes Authors. +Copyright 2026 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/pkg/framework/plugins/removefailedpods/zz_generated.defaults.go b/pkg/framework/plugins/removefailedpods/zz_generated.defaults.go index 735b19766..9636cbb21 100644 --- a/pkg/framework/plugins/removefailedpods/zz_generated.defaults.go +++ b/pkg/framework/plugins/removefailedpods/zz_generated.defaults.go @@ -2,7 +2,7 @@ // +build !ignore_autogenerated /* -Copyright 2025 The Kubernetes Authors. +Copyright 2026 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/pkg/framework/plugins/removepodshavingtoomanyrestarts/zz_generated.deepcopy.go b/pkg/framework/plugins/removepodshavingtoomanyrestarts/zz_generated.deepcopy.go index cf56c1a65..e862ca973 100644 --- a/pkg/framework/plugins/removepodshavingtoomanyrestarts/zz_generated.deepcopy.go +++ b/pkg/framework/plugins/removepodshavingtoomanyrestarts/zz_generated.deepcopy.go @@ -2,7 +2,7 @@ // +build !ignore_autogenerated /* -Copyright 2025 The Kubernetes Authors. +Copyright 2026 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/pkg/framework/plugins/removepodshavingtoomanyrestarts/zz_generated.defaults.go b/pkg/framework/plugins/removepodshavingtoomanyrestarts/zz_generated.defaults.go index 5875f38ec..6fe0e154a 100644 --- a/pkg/framework/plugins/removepodshavingtoomanyrestarts/zz_generated.defaults.go +++ b/pkg/framework/plugins/removepodshavingtoomanyrestarts/zz_generated.defaults.go @@ -2,7 +2,7 @@ // +build !ignore_autogenerated /* -Copyright 2025 The Kubernetes Authors. +Copyright 2026 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/pkg/framework/plugins/removepodsviolatinginterpodantiaffinity/zz_generated.deepcopy.go b/pkg/framework/plugins/removepodsviolatinginterpodantiaffinity/zz_generated.deepcopy.go index 84cf11819..4eeee22ba 100644 --- a/pkg/framework/plugins/removepodsviolatinginterpodantiaffinity/zz_generated.deepcopy.go +++ b/pkg/framework/plugins/removepodsviolatinginterpodantiaffinity/zz_generated.deepcopy.go @@ -2,7 +2,7 @@ // +build !ignore_autogenerated /* -Copyright 2025 The Kubernetes Authors. +Copyright 2026 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/pkg/framework/plugins/removepodsviolatinginterpodantiaffinity/zz_generated.defaults.go b/pkg/framework/plugins/removepodsviolatinginterpodantiaffinity/zz_generated.defaults.go index d39c49cf7..40e13f0af 100644 --- a/pkg/framework/plugins/removepodsviolatinginterpodantiaffinity/zz_generated.defaults.go +++ b/pkg/framework/plugins/removepodsviolatinginterpodantiaffinity/zz_generated.defaults.go @@ -2,7 +2,7 @@ // +build !ignore_autogenerated /* -Copyright 2025 The Kubernetes Authors. +Copyright 2026 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/pkg/framework/plugins/removepodsviolatingnodeaffinity/zz_generated.deepcopy.go b/pkg/framework/plugins/removepodsviolatingnodeaffinity/zz_generated.deepcopy.go index 4baccab30..47534df2c 100644 --- a/pkg/framework/plugins/removepodsviolatingnodeaffinity/zz_generated.deepcopy.go +++ b/pkg/framework/plugins/removepodsviolatingnodeaffinity/zz_generated.deepcopy.go @@ -2,7 +2,7 @@ // +build !ignore_autogenerated /* -Copyright 2025 The Kubernetes Authors. +Copyright 2026 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/pkg/framework/plugins/removepodsviolatingnodeaffinity/zz_generated.defaults.go b/pkg/framework/plugins/removepodsviolatingnodeaffinity/zz_generated.defaults.go index c96f17fd3..72f5b339d 100644 --- a/pkg/framework/plugins/removepodsviolatingnodeaffinity/zz_generated.defaults.go +++ b/pkg/framework/plugins/removepodsviolatingnodeaffinity/zz_generated.defaults.go @@ -2,7 +2,7 @@ // +build !ignore_autogenerated /* -Copyright 2025 The Kubernetes Authors. +Copyright 2026 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/pkg/framework/plugins/removepodsviolatingnodetaints/zz_generated.deepcopy.go b/pkg/framework/plugins/removepodsviolatingnodetaints/zz_generated.deepcopy.go index fb2fd1b67..e26b8ee1e 100644 --- a/pkg/framework/plugins/removepodsviolatingnodetaints/zz_generated.deepcopy.go +++ b/pkg/framework/plugins/removepodsviolatingnodetaints/zz_generated.deepcopy.go @@ -2,7 +2,7 @@ // +build !ignore_autogenerated /* -Copyright 2025 The Kubernetes Authors. +Copyright 2026 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/pkg/framework/plugins/removepodsviolatingnodetaints/zz_generated.defaults.go b/pkg/framework/plugins/removepodsviolatingnodetaints/zz_generated.defaults.go index 13706fc6d..77357cc34 100644 --- a/pkg/framework/plugins/removepodsviolatingnodetaints/zz_generated.defaults.go +++ b/pkg/framework/plugins/removepodsviolatingnodetaints/zz_generated.defaults.go @@ -2,7 +2,7 @@ // +build !ignore_autogenerated /* -Copyright 2025 The Kubernetes Authors. +Copyright 2026 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/pkg/framework/plugins/removepodsviolatingtopologyspreadconstraint/zz_generated.deepcopy.go b/pkg/framework/plugins/removepodsviolatingtopologyspreadconstraint/zz_generated.deepcopy.go index 67524e747..223bcbc91 100644 --- a/pkg/framework/plugins/removepodsviolatingtopologyspreadconstraint/zz_generated.deepcopy.go +++ b/pkg/framework/plugins/removepodsviolatingtopologyspreadconstraint/zz_generated.deepcopy.go @@ -2,7 +2,7 @@ // +build !ignore_autogenerated /* -Copyright 2025 The Kubernetes Authors. +Copyright 2026 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/pkg/framework/plugins/removepodsviolatingtopologyspreadconstraint/zz_generated.defaults.go b/pkg/framework/plugins/removepodsviolatingtopologyspreadconstraint/zz_generated.defaults.go index 43aa4e435..7a6daa7f3 100644 --- a/pkg/framework/plugins/removepodsviolatingtopologyspreadconstraint/zz_generated.defaults.go +++ b/pkg/framework/plugins/removepodsviolatingtopologyspreadconstraint/zz_generated.defaults.go @@ -2,7 +2,7 @@ // +build !ignore_autogenerated /* -Copyright 2025 The Kubernetes Authors. +Copyright 2026 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/pkg/framework/profile/profile_test.go b/pkg/framework/profile/profile_test.go index 5eeebb602..31756abc5 100644 --- a/pkg/framework/profile/profile_test.go +++ b/pkg/framework/profile/profile_test.go @@ -26,7 +26,60 @@ import ( 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) { + // 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 { name string config api.DeschedulerProfile @@ -34,134 +87,26 @@ func TestProfileDescheduleBalanceExtensionPointsEviction(t *testing.T) { expectedEviction bool }{ { - name: "profile with deschedule extension point enabled single eviction", - config: api.DeschedulerProfile{ - 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}, - }, - }, - }, + name: "profile with deschedule extension point enabled single eviction", + config: buildProfileConfig("strategy-test-profile-with-deschedule", true, false), extensionPoint: frameworktypes.DescheduleExtensionPoint, expectedEviction: true, }, { - name: "profile with balance extension point enabled single eviction", - config: api.DeschedulerProfile{ - 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}, - }, - }, - }, + name: "profile with balance extension point enabled single eviction", + config: buildProfileConfig("strategy-test-profile-with-balance", false, true), extensionPoint: frameworktypes.BalanceExtensionPoint, expectedEviction: true, }, { - name: "profile with deschedule extension point balance enabled no eviction", - config: api.DeschedulerProfile{ - 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}, - }, - }, - }, + name: "profile with deschedule extension point balance enabled no eviction", + config: buildProfileConfig("strategy-test-profile-with-balance", false, true), extensionPoint: frameworktypes.DescheduleExtensionPoint, expectedEviction: false, }, { - name: "profile with balance extension point deschedule enabled no eviction", - config: api.DeschedulerProfile{ - 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}, - }, - }, - }, + name: "profile with balance extension point deschedule enabled no eviction", + config: buildProfileConfig("strategy-test-profile-with-deschedule", true, false), extensionPoint: frameworktypes.BalanceExtensionPoint, expectedEviction: false, }, @@ -206,25 +151,9 @@ func TestProfileDescheduleBalanceExtensionPointsEviction(t *testing.T) { } pluginregistry.PluginRegistry = pluginregistry.NewRegistry() - pluginregistry.Register( - "FakePlugin", - fakeplugin.NewPluginFncFromFake(&fakePlugin), - &fakeplugin.FakePlugin{}, - &fakeplugin.FakePluginArgs{}, - fakeplugin.ValidateFakePluginArgs, - fakeplugin.SetDefaults_FakePluginArgs, - pluginregistry.PluginRegistry, - ) + fakeplugin.RegisterFakePlugin("FakePlugin", &fakePlugin, pluginregistry.PluginRegistry) - pluginregistry.Register( - defaultevictor.PluginName, - defaultevictor.New, - &defaultevictor.DefaultEvictor{}, - &defaultevictor.DefaultEvictorArgs{}, - defaultevictor.ValidateDefaultEvictorArgs, - defaultevictor.SetDefaults_DefaultEvictorArgs, - pluginregistry.PluginRegistry, - ) + registerDefaultEvictor(pluginregistry.PluginRegistry) client := fakeclientset.NewSimpleClientset(n1, n2, p1) var evictedPods []string @@ -319,56 +248,13 @@ func TestProfileExtensionPoints(t *testing.T) { fakeBalancePlugin := &fakeplugin.FakeBalancePlugin{PluginName: balancePluginName} fakeFilterPlugin := &fakeplugin.FakeFilterPlugin{PluginName: filterPluginName} - pluginregistry.Register( - fakePluginName, - fakeplugin.NewPluginFncFromFake(fakePlugin), - &fakeplugin.FakePlugin{}, - &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, - ) + fakeplugin.RegisterFakePlugin(fakePluginName, fakePlugin, pluginregistry.PluginRegistry) + fakeplugin.RegisterFakeDeschedulePlugin(deschedulePluginName, fakeDeschedulePlugin, pluginregistry.PluginRegistry) + fakeplugin.RegisterFakeBalancePlugin(balancePluginName, fakeBalancePlugin, pluginregistry.PluginRegistry) + fakeplugin.RegisterFakeFilterPlugin(filterPluginName, fakeFilterPlugin, pluginregistry.PluginRegistry) } - pluginregistry.Register( - defaultevictor.PluginName, - defaultevictor.New, - &defaultevictor.DefaultEvictor{}, - &defaultevictor.DefaultEvictorArgs{}, - defaultevictor.ValidateDefaultEvictorArgs, - defaultevictor.SetDefaults_DefaultEvictorArgs, - pluginregistry.PluginRegistry, - ) + registerDefaultEvictor(pluginregistry.PluginRegistry) client := fakeclientset.NewSimpleClientset(n1, n2, p1) var evictedPods []string @@ -524,15 +410,7 @@ func TestProfileExtensionPointOrdering(t *testing.T) { }) // plugin implementing Filter extension point - pluginregistry.Register( - pluginName, - fakeplugin.NewFakeFilterPluginFncFromFake(fakeFilterPlugin), - &fakeplugin.FakeFilterPlugin{}, - &fakeplugin.FakeFilterPluginArgs{}, - fakeplugin.ValidateFakePluginArgs, - fakeplugin.SetDefaults_FakePluginArgs, - pluginregistry.PluginRegistry, - ) + fakeplugin.RegisterFakeFilterPlugin(pluginName, fakeFilterPlugin, pluginregistry.PluginRegistry) fakePluginName := fmt.Sprintf("FakePlugin_%v", i) fakePlugin := fakeplugin.FakePlugin{} @@ -557,26 +435,10 @@ func TestProfileExtensionPointOrdering(t *testing.T) { return true, false, nil }) - pluginregistry.Register( - fakePluginName, - fakeplugin.NewPluginFncFromFake(&fakePlugin), - &fakeplugin.FakePlugin{}, - &fakeplugin.FakePluginArgs{}, - fakeplugin.ValidateFakePluginArgs, - fakeplugin.SetDefaults_FakePluginArgs, - pluginregistry.PluginRegistry, - ) + fakeplugin.RegisterFakePlugin(fakePluginName, &fakePlugin, pluginregistry.PluginRegistry) } - pluginregistry.Register( - defaultevictor.PluginName, - defaultevictor.New, - &defaultevictor.DefaultEvictor{}, - &defaultevictor.DefaultEvictorArgs{}, - defaultevictor.ValidateDefaultEvictorArgs, - defaultevictor.SetDefaults_DefaultEvictorArgs, - pluginregistry.PluginRegistry, - ) + registerDefaultEvictor(pluginregistry.PluginRegistry) client := fakeclientset.NewSimpleClientset(n1, n2, p1) var evictedPods []string