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"
) )
@ -200,6 +202,7 @@ func TestExampleObjectSchemas(t *testing.T) {
"../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,6 +339,13 @@ func TestExampleObjectSchemas(t *testing.T) {
t.Logf("skipping : %s/%s\n", path, name) t.Logf("skipping : %s/%s\n", path, name)
return return
} }
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 { if err := latest.Codec.DecodeInto(data, expectedType); err != nil {
t.Errorf("%s did not decode correctly: %v\n%s", path, err, string(data)) t.Errorf("%s did not decode correctly: %v\n%s", path, err, string(data))
return return
@ -343,6 +353,7 @@ func TestExampleObjectSchemas(t *testing.T) {
if errors := validateObject(expectedType); len(errors) > 0 { if errors := validateObject(expectedType); len(errors) > 0 {
t.Errorf("%s did not validate correctly: %v", path, errors) t.Errorf("%s did not validate correctly: %v", path, errors)
} }
}
}) })
if err != nil { if err != nil {
t.Errorf("Expected no error, Got %v", err) t.Errorf("Expected no error, Got %v", err)

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