Fix tests post rebase
This commit is contained in:
parent
579f378bee
commit
90f6ac7490
|
@ -1263,40 +1263,40 @@ func TestTaskRunner_SimpleRun_Dispatch(t *testing.T) {
|
||||||
compressed := snappy.Encode(nil, expected)
|
compressed := snappy.Encode(nil, expected)
|
||||||
alloc.Job.Payload = compressed
|
alloc.Job.Payload = compressed
|
||||||
|
|
||||||
upd, tr := testTaskRunnerFromAlloc(false, alloc)
|
ctx := testTaskRunnerFromAlloc(t, false, alloc)
|
||||||
tr.MarkReceived()
|
ctx.tr.MarkReceived()
|
||||||
defer tr.Destroy(structs.NewTaskEvent(structs.TaskKilled))
|
defer ctx.tr.Destroy(structs.NewTaskEvent(structs.TaskKilled))
|
||||||
defer tr.ctx.AllocDir.Destroy()
|
defer ctx.allocDir.Destroy()
|
||||||
go tr.Run()
|
go ctx.tr.Run()
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-tr.WaitCh():
|
case <-ctx.tr.WaitCh():
|
||||||
case <-time.After(time.Duration(testutil.TestMultiplier()*15) * time.Second):
|
case <-time.After(time.Duration(testutil.TestMultiplier()*15) * time.Second):
|
||||||
t.Fatalf("timeout")
|
t.Fatalf("timeout")
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(upd.events) != 3 {
|
if len(ctx.upd.events) != 3 {
|
||||||
t.Fatalf("should have 3 updates: %#v", upd.events)
|
t.Fatalf("should have 3 updates: %#v", ctx.upd.events)
|
||||||
}
|
}
|
||||||
|
|
||||||
if upd.state != structs.TaskStateDead {
|
if ctx.upd.state != structs.TaskStateDead {
|
||||||
t.Fatalf("TaskState %v; want %v", upd.state, structs.TaskStateDead)
|
t.Fatalf("TaskState %v; want %v", ctx.upd.state, structs.TaskStateDead)
|
||||||
}
|
}
|
||||||
|
|
||||||
if upd.events[0].Type != structs.TaskReceived {
|
if ctx.upd.events[0].Type != structs.TaskReceived {
|
||||||
t.Fatalf("First Event was %v; want %v", upd.events[0].Type, structs.TaskReceived)
|
t.Fatalf("First Event was %v; want %v", ctx.upd.events[0].Type, structs.TaskReceived)
|
||||||
}
|
}
|
||||||
|
|
||||||
if upd.events[1].Type != structs.TaskStarted {
|
if ctx.upd.events[1].Type != structs.TaskStarted {
|
||||||
t.Fatalf("Second Event was %v; want %v", upd.events[1].Type, structs.TaskStarted)
|
t.Fatalf("Second Event was %v; want %v", ctx.upd.events[1].Type, structs.TaskStarted)
|
||||||
}
|
}
|
||||||
|
|
||||||
if upd.events[2].Type != structs.TaskTerminated {
|
if ctx.upd.events[2].Type != structs.TaskTerminated {
|
||||||
t.Fatalf("Third Event was %v; want %v", upd.events[2].Type, structs.TaskTerminated)
|
t.Fatalf("Third Event was %v; want %v", ctx.upd.events[2].Type, structs.TaskTerminated)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check that the file was written to disk properly
|
// Check that the file was written to disk properly
|
||||||
payloadPath := filepath.Join(tr.taskDir, allocdir.TaskLocal, fileName)
|
payloadPath := filepath.Join(ctx.tr.taskDir.LocalDir, fileName)
|
||||||
data, err := ioutil.ReadFile(payloadPath)
|
data, err := ioutil.ReadFile(payloadPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to read file: %v", err)
|
t.Fatalf("Failed to read file: %v", err)
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"log"
|
||||||
"math"
|
"math"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
|
@ -449,7 +450,7 @@ func tempAllocDir(t testing.TB) *allocdir.AllocDir {
|
||||||
t.Fatalf("failed to chmod dir: %v", err)
|
t.Fatalf("failed to chmod dir: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return allocdir.NewAllocDir(dir)
|
return allocdir.NewAllocDir(log.New(os.Stderr, "", log.LstdFlags), dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
type nopWriteCloser struct {
|
type nopWriteCloser struct {
|
||||||
|
|
Loading…
Reference in New Issue