Added a test for adjustQueuedAllocations
This commit is contained in:
parent
cc37ec33cf
commit
d1682e052a
|
@ -502,7 +502,8 @@ func TestServiceSched_Plan_Partial_Progress(t *testing.T) {
|
|||
node := mock.Node()
|
||||
noErr(t, h.State.UpsertNode(h.NextIndex(), node))
|
||||
|
||||
// Create a job
|
||||
// Create a job with a high resource ask so that all the allocations can't
|
||||
// be placed on a single node.
|
||||
job := mock.Job()
|
||||
job.TaskGroups[0].Count = 3
|
||||
job.TaskGroups[0].Tasks[0].Resources.CPU = 3600
|
||||
|
|
|
@ -913,3 +913,37 @@ func TestDesiredUpdates(t *testing.T) {
|
|||
t.Fatalf("desiredUpdates() returned %#v; want %#v", desired, expected)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUtil_AdjustQueuedAllocations(t *testing.T) {
|
||||
logger := log.New(os.Stderr, "", log.LstdFlags)
|
||||
alloc1 := mock.Alloc()
|
||||
alloc2 := mock.Alloc()
|
||||
alloc2.CreateIndex = 4
|
||||
alloc3 := mock.Alloc()
|
||||
alloc3.CreateIndex = 3
|
||||
alloc4 := mock.Alloc()
|
||||
alloc4.CreateIndex = 6
|
||||
|
||||
planResult := structs.PlanResult{
|
||||
NodeUpdate: map[string][]*structs.Allocation{
|
||||
"node-1": []*structs.Allocation{alloc1},
|
||||
},
|
||||
NodeAllocation: map[string][]*structs.Allocation{
|
||||
"node-1": []*structs.Allocation{
|
||||
alloc2,
|
||||
},
|
||||
"node-2": []*structs.Allocation{
|
||||
alloc3, alloc4,
|
||||
},
|
||||
},
|
||||
RefreshIndex: 3,
|
||||
AllocIndex: 4,
|
||||
}
|
||||
|
||||
queuedAllocs := map[string]int{"web": 2}
|
||||
adjustQueuedAllocations(logger, &planResult, queuedAllocs)
|
||||
|
||||
if queuedAllocs["web"] != 1 {
|
||||
t.Fatalf("expected: %v, actual: %v", 1, queuedAllocs["web"])
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue