From 6235122b556b9077f6c7a7d07e0cde32af255e75 Mon Sep 17 00:00:00 2001 From: Michael Schurter Date: Thu, 5 Jan 2017 16:35:08 -0800 Subject: [PATCH] Fix tests post rebase --- client/task_runner_test.go | 34 +++++++++++++++---------------- command/agent/fs_endpoint_test.go | 3 ++- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/client/task_runner_test.go b/client/task_runner_test.go index a9f0820c0..5aeae7633 100644 --- a/client/task_runner_test.go +++ b/client/task_runner_test.go @@ -1263,40 +1263,40 @@ func TestTaskRunner_SimpleRun_Dispatch(t *testing.T) { compressed := snappy.Encode(nil, expected) alloc.Job.Payload = compressed - upd, tr := testTaskRunnerFromAlloc(false, alloc) - tr.MarkReceived() - defer tr.Destroy(structs.NewTaskEvent(structs.TaskKilled)) - defer tr.ctx.AllocDir.Destroy() - go tr.Run() + ctx := testTaskRunnerFromAlloc(t, false, alloc) + ctx.tr.MarkReceived() + defer ctx.tr.Destroy(structs.NewTaskEvent(structs.TaskKilled)) + defer ctx.allocDir.Destroy() + go ctx.tr.Run() select { - case <-tr.WaitCh(): + case <-ctx.tr.WaitCh(): case <-time.After(time.Duration(testutil.TestMultiplier()*15) * time.Second): t.Fatalf("timeout") } - if len(upd.events) != 3 { - t.Fatalf("should have 3 updates: %#v", upd.events) + if len(ctx.upd.events) != 3 { + t.Fatalf("should have 3 updates: %#v", ctx.upd.events) } - if upd.state != structs.TaskStateDead { - t.Fatalf("TaskState %v; want %v", upd.state, structs.TaskStateDead) + if ctx.upd.state != structs.TaskStateDead { + t.Fatalf("TaskState %v; want %v", ctx.upd.state, structs.TaskStateDead) } - if upd.events[0].Type != structs.TaskReceived { - t.Fatalf("First Event was %v; want %v", upd.events[0].Type, structs.TaskReceived) + if ctx.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 { - t.Fatalf("Second Event was %v; want %v", upd.events[1].Type, structs.TaskStarted) + if ctx.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 { - t.Fatalf("Third Event was %v; want %v", upd.events[2].Type, structs.TaskTerminated) + if ctx.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 - payloadPath := filepath.Join(tr.taskDir, allocdir.TaskLocal, fileName) + payloadPath := filepath.Join(ctx.tr.taskDir.LocalDir, fileName) data, err := ioutil.ReadFile(payloadPath) if err != nil { t.Fatalf("Failed to read file: %v", err) diff --git a/command/agent/fs_endpoint_test.go b/command/agent/fs_endpoint_test.go index bf01c7794..abb9a974b 100644 --- a/command/agent/fs_endpoint_test.go +++ b/command/agent/fs_endpoint_test.go @@ -5,6 +5,7 @@ import ( "fmt" "io" "io/ioutil" + "log" "math" "net/http" "net/http/httptest" @@ -449,7 +450,7 @@ func tempAllocDir(t testing.TB) *allocdir.AllocDir { 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 {