diff --git a/examples/examples_test.go b/examples/examples_test.go index 835d69ddae0..3230eb76d4e 100644 --- a/examples/examples_test.go +++ b/examples/examples_test.go @@ -31,6 +31,8 @@ import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/capabilities" "github.com/GoogleCloudPlatform/kubernetes/pkg/runtime" "github.com/GoogleCloudPlatform/kubernetes/pkg/util/yaml" + schedulerapi "github.com/GoogleCloudPlatform/kubernetes/plugin/pkg/scheduler/api" + schedulerapilatest "github.com/GoogleCloudPlatform/kubernetes/plugin/pkg/scheduler/api/latest" "github.com/golang/glog" ) @@ -198,8 +200,9 @@ func TestExampleObjectSchemas(t *testing.T) { "http-liveness": &api.Pod{}, }, "../examples": { - "pod": &api.Pod{}, - "replication": &api.ReplicationController{}, + "pod": &api.Pod{}, + "replication": &api.ReplicationController{}, + "scheduler-policy-config": &schedulerapi.Policy{}, }, "../examples/rbd/secret": { "ceph-secret": &api.Secret{}, @@ -336,12 +339,20 @@ func TestExampleObjectSchemas(t *testing.T) { t.Logf("skipping : %s/%s\n", path, name) return } - if err := latest.Codec.DecodeInto(data, expectedType); err != nil { - t.Errorf("%s did not decode correctly: %v\n%s", path, err, string(data)) - return - } - if errors := validateObject(expectedType); len(errors) > 0 { - t.Errorf("%s did not validate correctly: %v", path, errors) + if name == "scheduler-policy-config" { + if err := schedulerapilatest.Codec.DecodeInto(data, expectedType); err != nil { + t.Errorf("%s did not decode correctly: %v\n%s", path, err, string(data)) + return + } + //TODO: Add validate method for &schedulerapi.Policy + } else { + if err := latest.Codec.DecodeInto(data, expectedType); err != nil { + t.Errorf("%s did not decode correctly: %v\n%s", path, err, string(data)) + return + } + if errors := validateObject(expectedType); len(errors) > 0 { + t.Errorf("%s did not validate correctly: %v", path, errors) + } } }) if err != nil { diff --git a/examples/scheduler-policy-config.json b/examples/scheduler-policy-config.json new file mode 100644 index 00000000000..8ce2df8b2de --- /dev/null +++ b/examples/scheduler-policy-config.json @@ -0,0 +1,17 @@ +{ +"kind" : "Policy", +"apiVersion" : "v1", +"predicates" : [ + {"name" : "PodFitsPorts"}, + {"name" : "PodFitsResources"}, + {"name" : "NoDiskConflict"}, + {"name" : "MatchNodeSelector"}, + {"name" : "HostName"} + ], +"priorities" : [ + {"name" : "LeastRequestedPriority", "weight" : 1}, + {"name" : "BalancedResourceAllocation", "weight" : 1}, + {"name" : "ServiceSpreadingPriority", "weight" : 1}, + {"name" : "EqualPriority", "weight" : 1} + ] +}