mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 12:15:52 +00:00
remove feature gate from tests.
This commit is contained in:
parent
db3ec322d7
commit
84ef463481
@ -23,49 +23,30 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/spf13/pflag"
|
||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||
featuregatetesting "k8s.io/component-base/featuregate/testing"
|
||||
"k8s.io/controller-manager/config"
|
||||
"k8s.io/controller-manager/pkg/features"
|
||||
migrationconfig "k8s.io/controller-manager/pkg/leadermigration/config"
|
||||
)
|
||||
|
||||
func TestLeaderMigrationOptions(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
flags []string
|
||||
configContent string
|
||||
expectEnabled bool
|
||||
expectErr bool
|
||||
enableFeatureGate bool
|
||||
expectConfig *config.LeaderMigrationConfiguration
|
||||
name string
|
||||
flags []string
|
||||
configContent string
|
||||
expectEnabled bool
|
||||
expectErr bool
|
||||
expectConfig *config.LeaderMigrationConfiguration
|
||||
}{
|
||||
{
|
||||
name: "default (disabled), with feature gate disabled",
|
||||
flags: []string{},
|
||||
enableFeatureGate: false,
|
||||
expectEnabled: false,
|
||||
expectErr: false,
|
||||
name: "enabled, with default configuration",
|
||||
flags: []string{"--enable-leader-migration"},
|
||||
expectEnabled: true,
|
||||
expectErr: false,
|
||||
expectConfig: migrationconfig.DefaultLeaderMigrationConfiguration(),
|
||||
},
|
||||
{
|
||||
name: "enabled, with feature gate disabled",
|
||||
flags: []string{"--enable-leader-migration"},
|
||||
enableFeatureGate: false,
|
||||
expectErr: true,
|
||||
},
|
||||
{
|
||||
name: "enabled, with default configuration",
|
||||
flags: []string{"--enable-leader-migration"},
|
||||
enableFeatureGate: true,
|
||||
expectEnabled: true,
|
||||
expectErr: false,
|
||||
expectConfig: migrationconfig.DefaultLeaderMigrationConfiguration(),
|
||||
},
|
||||
{
|
||||
name: "enabled, with custom configuration file",
|
||||
flags: []string{"--enable-leader-migration"},
|
||||
enableFeatureGate: true,
|
||||
expectEnabled: true,
|
||||
name: "enabled, with custom configuration file",
|
||||
flags: []string{"--enable-leader-migration"},
|
||||
expectEnabled: true,
|
||||
configContent: `
|
||||
apiVersion: controllermanager.config.k8s.io/v1alpha1
|
||||
kind: LeaderMigrationConfiguration
|
||||
@ -81,10 +62,9 @@ controllerLeaders: []
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "enabled, with custom configuration file (version v1beta1)",
|
||||
flags: []string{"--enable-leader-migration"},
|
||||
enableFeatureGate: true,
|
||||
expectEnabled: true,
|
||||
name: "enabled, with custom configuration file (version v1beta1)",
|
||||
flags: []string{"--enable-leader-migration"},
|
||||
expectEnabled: true,
|
||||
configContent: `
|
||||
apiVersion: controllermanager.config.k8s.io/v1beta1
|
||||
kind: LeaderMigrationConfiguration
|
||||
@ -102,7 +82,6 @@ controllerLeaders: []
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.ControllerManagerLeaderMigration, tc.enableFeatureGate)()
|
||||
flags := tc.flags
|
||||
if tc.configContent != "" {
|
||||
configFile, err := ioutil.TempFile("", tc.name)
|
||||
|
Loading…
Reference in New Issue
Block a user