Update tests to handle codec changes
This commit is contained in:
@@ -20,6 +20,7 @@ import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"k8s.io/kubernetes/pkg/runtime"
|
||||
schedulerapi "k8s.io/kubernetes/plugin/pkg/scheduler/api"
|
||||
latestschedulerapi "k8s.io/kubernetes/plugin/pkg/scheduler/api/latest"
|
||||
"k8s.io/kubernetes/plugin/pkg/scheduler/factory"
|
||||
@@ -92,16 +93,14 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
|
||||
|
||||
for v, tc := range schedulerFiles {
|
||||
policy := schedulerapi.Policy{}
|
||||
err := latestschedulerapi.Codec.DecodeInto([]byte(tc.JSON), &policy)
|
||||
if err != nil {
|
||||
if err := runtime.DecodeInto(latestschedulerapi.Codec, []byte(tc.JSON), &policy); err != nil {
|
||||
t.Errorf("%s: Error decoding: %v", v, err)
|
||||
continue
|
||||
}
|
||||
if !reflect.DeepEqual(policy, tc.ExpectedPolicy) {
|
||||
t.Errorf("%s: Expected:\n\t%#v\nGot:\n\t%#v", v, tc.ExpectedPolicy, policy)
|
||||
}
|
||||
_, err = factory.NewConfigFactory(nil, "some-scheduler-name").CreateFromConfig(policy)
|
||||
if err != nil {
|
||||
if _, err := factory.NewConfigFactory(nil, "some-scheduler-name").CreateFromConfig(policy); err != nil {
|
||||
t.Errorf("%s: Error constructing: %v", v, err)
|
||||
continue
|
||||
}
|
||||
|
@@ -87,8 +87,7 @@ func TestCreateFromConfig(t *testing.T) {
|
||||
{"name" : "PriorityOne", "weight" : 2},
|
||||
{"name" : "PriorityTwo", "weight" : 1} ]
|
||||
}`)
|
||||
err := latestschedulerapi.Codec.DecodeInto(configData, &policy)
|
||||
if err != nil {
|
||||
if err := runtime.DecodeInto(latestschedulerapi.Codec, configData, &policy); err != nil {
|
||||
t.Errorf("Invalid configuration: %v", err)
|
||||
}
|
||||
|
||||
@@ -111,8 +110,7 @@ func TestCreateFromEmptyConfig(t *testing.T) {
|
||||
factory := NewConfigFactory(client, api.DefaultSchedulerName)
|
||||
|
||||
configData = []byte(`{}`)
|
||||
err := latestschedulerapi.Codec.DecodeInto(configData, &policy)
|
||||
if err != nil {
|
||||
if err := runtime.DecodeInto(latestschedulerapi.Codec, configData, &policy); err != nil {
|
||||
t.Errorf("Invalid configuration: %v", err)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user