Merge pull request #9038 from HaiyangDING/patch-1

Example for policy config file for scheduler
This commit is contained in:
Alex Robinson 2015-06-29 11:29:09 -07:00
commit 277e8aa0ab
2 changed files with 36 additions and 8 deletions

View File

@ -31,6 +31,8 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/capabilities" "github.com/GoogleCloudPlatform/kubernetes/pkg/capabilities"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime" "github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/yaml" "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" "github.com/golang/glog"
) )
@ -198,8 +200,9 @@ func TestExampleObjectSchemas(t *testing.T) {
"http-liveness": &api.Pod{}, "http-liveness": &api.Pod{},
}, },
"../examples": { "../examples": {
"pod": &api.Pod{}, "pod": &api.Pod{},
"replication": &api.ReplicationController{}, "replication": &api.ReplicationController{},
"scheduler-policy-config": &schedulerapi.Policy{},
}, },
"../examples/rbd/secret": { "../examples/rbd/secret": {
"ceph-secret": &api.Secret{}, "ceph-secret": &api.Secret{},
@ -336,12 +339,20 @@ func TestExampleObjectSchemas(t *testing.T) {
t.Logf("skipping : %s/%s\n", path, name) t.Logf("skipping : %s/%s\n", path, name)
return return
} }
if err := latest.Codec.DecodeInto(data, expectedType); err != nil { if name == "scheduler-policy-config" {
t.Errorf("%s did not decode correctly: %v\n%s", path, err, string(data)) if err := schedulerapilatest.Codec.DecodeInto(data, expectedType); err != nil {
return 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) //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 { if err != nil {

View File

@ -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}
]
}