merge
This commit is contained in:
parent
561ccdb441
commit
92823b71a8
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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}))
|
||||
|
||||
|
|
|
@ -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}))
|
||||
|
||||
|
|
Loading…
Reference in New Issue