diff --git a/nomad/mock/mock.go b/nomad/mock/mock.go index 012677f18b8..2e0057c8e2b 100644 --- a/nomad/mock/mock.go +++ b/nomad/mock/mock.go @@ -231,12 +231,6 @@ func Alloc() *structs.Allocation { }, }, }, - Services: map[string]string{"web-frontend": "nomad-registered-task-1234"}, - TaskStates: map[string]*structs.TaskState{ - "web": &structs.TaskState{ - State: structs.TaskStatePending, - }, - }, Job: Job(), DesiredStatus: structs.AllocDesiredStatusRun, ClientStatus: structs.AllocClientStatusPending, diff --git a/nomad/structs/funcs_test.go b/nomad/structs/funcs_test.go index a3bf238858b..93ce5cb308b 100644 --- a/nomad/structs/funcs_test.go +++ b/nomad/structs/funcs_test.go @@ -26,43 +26,23 @@ func TestFilterTerminalAllocs(t *testing.T) { l := []*Allocation{ &Allocation{ID: "bar", DesiredStatus: AllocDesiredStatusEvict}, &Allocation{ID: "baz", DesiredStatus: AllocDesiredStatusStop}, - &Allocation{ - ID: "zip", - DesiredStatus: AllocDesiredStatusRun, - TaskStates: map[string]*TaskState{ - "a": &TaskState{State: TaskStatePending}, - }, - }, &Allocation{ ID: "foo", DesiredStatus: AllocDesiredStatusRun, - TaskStates: map[string]*TaskState{ - "a": &TaskState{State: TaskStatePending}, - }, + ClientStatus: AllocClientStatusPending, }, &Allocation{ ID: "bam", DesiredStatus: AllocDesiredStatusRun, - TaskStates: map[string]*TaskState{ - "a": &TaskState{State: TaskStatePending}, - "b": &TaskState{State: TaskStateDead}, - }, - }, - &Allocation{ - ID: "fizz", - DesiredStatus: AllocDesiredStatusRun, - TaskStates: map[string]*TaskState{ - "a": &TaskState{State: TaskStateDead}, - "b": &TaskState{State: TaskStateDead}, - }, + ClientStatus: AllocClientStatusDead, }, } out := FilterTerminalAllocs(l) - if len(out) != 3 { + if len(out) != 1 { t.Fatalf("bad: %#v", out) } - if out[0].ID != "zip" && out[1].ID != "foo" && out[2].ID != "bam" { + if out[0].ID != "foo" { t.Fatalf("bad: %#v", out) } } diff --git a/scheduler/context_test.go b/scheduler/context_test.go index 1f573028620..006e1ae994c 100644 --- a/scheduler/context_test.go +++ b/scheduler/context_test.go @@ -61,9 +61,7 @@ func TestEvalContext_ProposedAlloc(t *testing.T) { MemoryMB: 2048, }, DesiredStatus: structs.AllocDesiredStatusRun, - TaskStates: map[string]*structs.TaskState{ - "foo": &structs.TaskState{State: structs.TaskStatePending}, - }, + ClientStatus: structs.AllocClientStatusPending, } alloc2 := &structs.Allocation{ ID: structs.GenerateUUID(), @@ -75,9 +73,7 @@ func TestEvalContext_ProposedAlloc(t *testing.T) { MemoryMB: 1024, }, DesiredStatus: structs.AllocDesiredStatusRun, - TaskStates: map[string]*structs.TaskState{ - "foo": &structs.TaskState{State: structs.TaskStatePending}, - }, + ClientStatus: structs.AllocClientStatusPending, } noErr(t, state.UpsertAllocs(1000, []*structs.Allocation{alloc1, alloc2})) diff --git a/scheduler/rank_test.go b/scheduler/rank_test.go index 68716ea7609..d53aa996f57 100644 --- a/scheduler/rank_test.go +++ b/scheduler/rank_test.go @@ -203,9 +203,7 @@ func TestBinPackIterator_ExistingAlloc(t *testing.T) { MemoryMB: 2048, }, DesiredStatus: structs.AllocDesiredStatusRun, - TaskStates: map[string]*structs.TaskState{ - "foo": &structs.TaskState{State: structs.TaskStatePending}, - }, + ClientStatus: structs.AllocClientStatusPending, } alloc2 := &structs.Allocation{ ID: structs.GenerateUUID(), @@ -217,9 +215,7 @@ func TestBinPackIterator_ExistingAlloc(t *testing.T) { MemoryMB: 1024, }, DesiredStatus: structs.AllocDesiredStatusRun, - TaskStates: map[string]*structs.TaskState{ - "foo": &structs.TaskState{State: structs.TaskStatePending}, - }, + ClientStatus: structs.AllocClientStatusPending, } noErr(t, state.UpsertAllocs(1000, []*structs.Allocation{alloc1, alloc2})) @@ -283,9 +279,7 @@ func TestBinPackIterator_ExistingAlloc_PlannedEvict(t *testing.T) { MemoryMB: 2048, }, DesiredStatus: structs.AllocDesiredStatusRun, - TaskStates: map[string]*structs.TaskState{ - "foo": &structs.TaskState{State: structs.TaskStatePending}, - }, + ClientStatus: structs.AllocClientStatusPending, } alloc2 := &structs.Allocation{ ID: structs.GenerateUUID(), @@ -297,9 +291,7 @@ func TestBinPackIterator_ExistingAlloc_PlannedEvict(t *testing.T) { MemoryMB: 1024, }, DesiredStatus: structs.AllocDesiredStatusRun, - TaskStates: map[string]*structs.TaskState{ - "foo": &structs.TaskState{State: structs.TaskStatePending}, - }, + ClientStatus: structs.AllocClientStatusPending, } noErr(t, state.UpsertAllocs(1000, []*structs.Allocation{alloc1, alloc2}))