@@ -126,10 +126,11 @@ func TestSchedulerCreation(t *testing.T) {
126
126
"Foo" : defaultbinder .New ,
127
127
}
128
128
cases := []struct {
129
- name string
130
- opts []Option
131
- wantErr string
132
- wantProfiles []string
129
+ name string
130
+ opts []Option
131
+ wantErr string
132
+ wantProfiles []string
133
+ wantExtenders []string
133
134
}{
134
135
{
135
136
name : "valid out-of-tree registry" ,
@@ -211,6 +212,27 @@ func TestSchedulerCreation(t *testing.T) {
211
212
)},
212
213
wantErr : "duplicate profile with scheduler name \" foo\" " ,
213
214
},
215
+ {
216
+ name : "With extenders" ,
217
+ opts : []Option {
218
+ WithProfiles (
219
+ schedulerapi.KubeSchedulerProfile {
220
+ SchedulerName : "default-scheduler" ,
221
+ Plugins : & schedulerapi.Plugins {
222
+ QueueSort : schedulerapi.PluginSet {Enabled : []schedulerapi.Plugin {{Name : "PrioritySort" }}},
223
+ Bind : schedulerapi.PluginSet {Enabled : []schedulerapi.Plugin {{Name : "DefaultBinder" }}},
224
+ },
225
+ },
226
+ ),
227
+ WithExtenders (
228
+ schedulerapi.Extender {
229
+ URLPrefix : "http://extender.kube-system/" ,
230
+ },
231
+ ),
232
+ },
233
+ wantProfiles : []string {"default-scheduler" },
234
+ wantExtenders : []string {"http://extender.kube-system/" },
235
+ },
214
236
}
215
237
216
238
for _ , tc := range cases {
@@ -230,6 +252,7 @@ func TestSchedulerCreation(t *testing.T) {
230
252
tc .opts ... ,
231
253
)
232
254
255
+ // Errors
233
256
if len (tc .wantErr ) != 0 {
234
257
if err == nil || ! strings .Contains (err .Error (), tc .wantErr ) {
235
258
t .Errorf ("got error %q, want %q" , err , tc .wantErr )
@@ -239,6 +262,8 @@ func TestSchedulerCreation(t *testing.T) {
239
262
if err != nil {
240
263
t .Fatalf ("Failed to create scheduler: %v" , err )
241
264
}
265
+
266
+ // Profiles
242
267
profiles := make ([]string , 0 , len (s .Profiles ))
243
268
for name := range s .Profiles {
244
269
profiles = append (profiles , name )
@@ -247,6 +272,29 @@ func TestSchedulerCreation(t *testing.T) {
247
272
if diff := cmp .Diff (tc .wantProfiles , profiles ); diff != "" {
248
273
t .Errorf ("unexpected profiles (-want, +got):\n %s" , diff )
249
274
}
275
+
276
+ // Extenders
277
+ if len (tc .wantExtenders ) != 0 {
278
+ // Scheduler.Extenders
279
+ extenders := make ([]string , 0 , len (s .Extenders ))
280
+ for _ , e := range s .Extenders {
281
+ extenders = append (extenders , e .Name ())
282
+ }
283
+ if diff := cmp .Diff (tc .wantExtenders , extenders ); diff != "" {
284
+ t .Errorf ("unexpected extenders (-want, +got):\n %s" , diff )
285
+ }
286
+
287
+ // framework.Handle.Extenders()
288
+ for _ , p := range s .Profiles {
289
+ extenders := make ([]string , 0 , len (p .Extenders ()))
290
+ for _ , e := range p .Extenders () {
291
+ extenders = append (extenders , e .Name ())
292
+ }
293
+ if diff := cmp .Diff (tc .wantExtenders , extenders ); diff != "" {
294
+ t .Errorf ("unexpected extenders (-want, +got):\n %s" , diff )
295
+ }
296
+ }
297
+ }
250
298
})
251
299
}
252
300
}
0 commit comments