Add a least-requested priority function

This commit is contained in:
Brendan Burns
2014-10-06 15:58:18 -07:00
parent 467a7a2cc1
commit 4230a8ca61
10 changed files with 218 additions and 25 deletions

View File

@@ -202,9 +202,9 @@ type storeToMinionLister struct {
cache.Store
}
func (s *storeToMinionLister) List() (machines []string, err error) {
func (s *storeToMinionLister) List() (machines api.MinionList, err error) {
for _, m := range s.Store.List() {
machines = append(machines, m.(*api.Minion).ID)
machines.Items = append(machines.Items, *(m.(*api.Minion)))
}
return machines, nil
}

View File

@@ -223,10 +223,14 @@ func TestStoreToMinionLister(t *testing.T) {
}
sml := storeToMinionLister{store}
got, err := sml.List()
gotNodes, err := sml.List()
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
got := make([]string, len(gotNodes.Items))
for ix := range gotNodes.Items {
got[ix] = gotNodes.Items[ix].ID
}
if !ids.HasAll(got...) || len(got) != len(ids) {
t.Errorf("Expected %v, got %v", ids, got)
}

View File

@@ -81,8 +81,10 @@ func TestScheduler(t *testing.T) {
var gotPod *api.Pod
var gotBinding *api.Binding
c := &Config{
MinionLister: scheduler.FakeMinionLister{"machine1"},
Algorithm: item.algo,
MinionLister: scheduler.FakeMinionLister(
api.MinionList{Items: []api.Minion{{TypeMeta: api.TypeMeta{ID: "machine1"}}}},
),
Algorithm: item.algo,
Binder: fakeBinder{func(b *api.Binding) error {
gotBinding = b
return item.injectBindError