Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
dadgar committed Dec 16, 2015
1 parent 2752a95 commit bc13dca
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 48 deletions.
6 changes: 0 additions & 6 deletions nomad/mock/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
28 changes: 4 additions & 24 deletions nomad/structs/funcs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
8 changes: 2 additions & 6 deletions scheduler/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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}))

Expand Down
16 changes: 4 additions & 12 deletions scheduler/rank_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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}))

Expand Down Expand Up @@ -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(),
Expand All @@ -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}))

Expand Down

0 comments on commit bc13dca

Please sign in to comment.