This commit is contained in:
Alex Dadgar 2015-12-16 15:01:15 -08:00
parent 561ccdb441
commit 92823b71a8
4 changed files with 10 additions and 48 deletions

View File

@ -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,

View File

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

View File

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

View File

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