Skip to content

Commit 2016fab

Browse files
authored
Merge pull request kubernetes#123382 from kerthcet/cleanup/add-testcase-for-defaults
Add testcase covering unknown plugin config in scheduler
2 parents 5d776f9 + 3c9c141 commit 2016fab

File tree

1 file changed

+46
-1
lines changed

1 file changed

+46
-1
lines changed

pkg/scheduler/apis/config/v1/defaults_test.go

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ var pluginConfigs = []configv1.PluginConfig{
117117

118118
func TestSchedulerDefaults(t *testing.T) {
119119
enable := true
120+
unknownPluginConfigs := append([]configv1.PluginConfig{}, pluginConfigs...)
121+
unknownPluginConfigs[0].Args = runtime.RawExtension{Object: &runtime.Unknown{}}
122+
120123
tests := []struct {
121124
name string
122125
config *configv1.KubeSchedulerConfiguration
@@ -599,7 +602,49 @@ func TestSchedulerDefaults(t *testing.T) {
599602
},
600603
},
601604
},
605+
{
606+
name: "unknown plugin config",
607+
config: &configv1.KubeSchedulerConfiguration{
608+
Profiles: []configv1.KubeSchedulerProfile{
609+
{
610+
PluginConfig: unknownPluginConfigs,
611+
},
612+
},
613+
},
614+
expected: &configv1.KubeSchedulerConfiguration{
615+
Parallelism: ptr.To[int32](16),
616+
DebuggingConfiguration: componentbaseconfig.DebuggingConfiguration{
617+
EnableProfiling: &enable,
618+
EnableContentionProfiling: &enable,
619+
},
620+
LeaderElection: componentbaseconfig.LeaderElectionConfiguration{
621+
LeaderElect: ptr.To(true),
622+
LeaseDuration: metav1.Duration{Duration: 15 * time.Second},
623+
RenewDeadline: metav1.Duration{Duration: 10 * time.Second},
624+
RetryPeriod: metav1.Duration{Duration: 2 * time.Second},
625+
ResourceLock: "leases",
626+
ResourceNamespace: "kube-system",
627+
ResourceName: "kube-scheduler",
628+
},
629+
ClientConnection: componentbaseconfig.ClientConnectionConfiguration{
630+
QPS: 50,
631+
Burst: 100,
632+
ContentType: "application/vnd.kubernetes.protobuf",
633+
},
634+
PercentageOfNodesToScore: ptr.To[int32](config.DefaultPercentageOfNodesToScore),
635+
PodInitialBackoffSeconds: ptr.To[int64](1),
636+
PodMaxBackoffSeconds: ptr.To[int64](10),
637+
Profiles: []configv1.KubeSchedulerProfile{
638+
{
639+
Plugins: getDefaultPlugins(),
640+
PluginConfig: unknownPluginConfigs,
641+
SchedulerName: ptr.To("default-scheduler"),
642+
},
643+
},
644+
},
645+
},
602646
}
647+
603648
for _, tc := range tests {
604649
t.Run(tc.name, func(t *testing.T) {
605650
SetDefaults_KubeSchedulerConfiguration(tc.config)
@@ -800,7 +845,7 @@ func TestPluginArgsDefaults(t *testing.T) {
800845
defer featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, k, v)()
801846
}
802847
scheme.Default(tc.in)
803-
if diff := cmp.Diff(tc.in, tc.want); diff != "" {
848+
if diff := cmp.Diff(tc.want, tc.in); diff != "" {
804849
t.Errorf("Got unexpected defaults (-want, +got):\n%s", diff)
805850
}
806851
})

0 commit comments

Comments
 (0)