@@ -18,7 +18,6 @@ package scheduler
18
18
19
19
import (
20
20
"context"
21
- "encoding/json"
22
21
"errors"
23
22
"reflect"
24
23
"strings"
@@ -161,19 +160,27 @@ func TestCreateFromConfig(t *testing.T) {
161
160
}
162
161
163
162
// Verify that node label predicate/priority are converted to framework plugins.
164
- wantArgs := `{"Name":"NodeLabel","Args":{"presentLabels":["zone"],"absentLabels":["foo"],"presentLabelsPreference":["l1"],"absentLabelsPreference":["l2"]}}`
163
+ var wantArgs runtime.Object = & schedulerapi.NodeLabelArgs {
164
+ PresentLabels : []string {"zone" },
165
+ AbsentLabels : []string {"foo" },
166
+ PresentLabelsPreference : []string {"l1" },
167
+ AbsentLabelsPreference : []string {"l2" },
168
+ }
165
169
verifyPluginConvertion (t , nodelabel .Name , []string {"FilterPlugin" , "ScorePlugin" }, prof , & factory .profiles [0 ], 6 , wantArgs )
166
170
// Verify that service affinity custom predicate/priority is converted to framework plugin.
167
- wantArgs = `{"Name":"ServiceAffinity","Args":{"affinityLabels":["zone","foo"],"antiAffinityLabelsPreference":["rack","zone"]}}`
171
+ wantArgs = & schedulerapi.ServiceAffinityArgs {
172
+ AffinityLabels : []string {"zone" , "foo" },
173
+ AntiAffinityLabelsPreference : []string {"rack" , "zone" },
174
+ }
168
175
verifyPluginConvertion (t , serviceaffinity .Name , []string {"FilterPlugin" , "ScorePlugin" }, prof , & factory .profiles [0 ], 6 , wantArgs )
169
176
// TODO(#87703): Verify all plugin configs.
170
177
})
171
178
}
172
179
173
180
}
174
181
175
- func verifyPluginConvertion (t * testing.T , name string , extentionPoints []string , prof * profile.Profile , cfg * schedulerapi.KubeSchedulerProfile , wantWeight int32 , wantArgs string ) {
176
- for _ , extensionPoint := range extentionPoints {
182
+ func verifyPluginConvertion (t * testing.T , name string , extensionPoints []string , prof * profile.Profile , cfg * schedulerapi.KubeSchedulerProfile , wantWeight int32 , wantArgs runtime. Object ) {
183
+ for _ , extensionPoint := range extensionPoints {
177
184
plugin , ok := findPlugin (name , extensionPoint , prof )
178
185
if ! ok {
179
186
t .Fatalf ("%q plugin does not exist in framework." , name )
@@ -185,12 +192,8 @@ func verifyPluginConvertion(t *testing.T, name string, extentionPoints []string,
185
192
}
186
193
// Verify that the policy config is converted to plugin config.
187
194
pluginConfig := findPluginConfig (name , cfg )
188
- encoding , err := json .Marshal (pluginConfig )
189
- if err != nil {
190
- t .Errorf ("Failed to marshal %+v: %v" , pluginConfig , err )
191
- }
192
- if string (encoding ) != wantArgs {
193
- t .Errorf ("Config for %v plugin mismatch. got: %v, want: %v" , name , string (encoding ), wantArgs )
195
+ if diff := cmp .Diff (wantArgs , pluginConfig .Args ); diff != "" {
196
+ t .Errorf ("Config for %v plugin mismatch (-want,+got):\n %s" , name , diff )
194
197
}
195
198
}
196
199
}
@@ -250,7 +253,7 @@ func TestCreateFromConfigWithHardPodAffinitySymmetricWeight(t *testing.T) {
250
253
for _ , cfg := range factory .profiles [0 ].PluginConfig {
251
254
if cfg .Name == interpodaffinity .Name {
252
255
foundAffinityCfg = true
253
- wantArgs := & runtime. Unknown { Raw : [] byte ( `{"hardPodAffinityWeight":10}` ) }
256
+ wantArgs := & schedulerapi. InterPodAffinityArgs { HardPodAffinityWeight : 10 }
254
257
255
258
if diff := cmp .Diff (wantArgs , cfg .Args ); diff != "" {
256
259
t .Errorf ("wrong InterPodAffinity args (-want, +got): %s" , diff )
0 commit comments