From 646fd8a2f99b40e9cccf4f9c4d2532ff63ca9ff8 Mon Sep 17 00:00:00 2001 From: Alex Dadgar Date: Wed, 3 May 2017 12:38:49 -0700 Subject: [PATCH] Fix tests --- command/agent/consul/int_test.go | 12 +++++++++++- command/agent/fs_endpoint_test.go | 21 +++++++++++---------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/command/agent/consul/int_test.go b/command/agent/consul/int_test.go index 9243b5822..319f46825 100644 --- a/command/agent/consul/int_test.go +++ b/command/agent/consul/int_test.go @@ -10,6 +10,7 @@ import ( "testing" "time" + "github.com/boltdb/bolt" consulapi "github.com/hashicorp/consul/api" "github.com/hashicorp/consul/testutil" "github.com/hashicorp/nomad/client" @@ -71,6 +72,15 @@ func TestConsul_Integration(t *testing.T) { } defer os.RemoveAll(conf.AllocDir) + tmp, err := ioutil.TempFile("", "state-db") + if err != nil { + t.Fatalf("error creating state db file: %v", err) + } + db, err := bolt.Open(tmp.Name(), 0600, nil) + if err != nil { + t.Fatalf("error creating state db: %v", err) + } + alloc := mock.Alloc() task := alloc.Job.TaskGroups[0].Tasks[0] task.Driver = "mock_driver" @@ -131,7 +141,7 @@ func TestConsul_Integration(t *testing.T) { serviceClient.Run() close(consulRan) }() - tr := client.NewTaskRunner(logger, conf, logUpdate, taskDir, alloc, task, vclient, serviceClient) + tr := client.NewTaskRunner(logger, conf, db, logUpdate, taskDir, alloc, task, vclient, serviceClient) tr.MarkReceived() go tr.Run() defer func() { diff --git a/command/agent/fs_endpoint_test.go b/command/agent/fs_endpoint_test.go index 0e9b73254..2feee179c 100644 --- a/command/agent/fs_endpoint_test.go +++ b/command/agent/fs_endpoint_test.go @@ -19,6 +19,7 @@ import ( "time" "github.com/hashicorp/nomad/client/allocdir" + "github.com/hashicorp/nomad/nomad/structs" "github.com/hashicorp/nomad/testutil" "github.com/ugorji/go/codec" ) @@ -123,7 +124,7 @@ func TestStreamFramer_Flush(t *testing.T) { sf.Run() // Create a decoder - dec := codec.NewDecoder(r, jsonHandle) + dec := codec.NewDecoder(r, structs.JsonHandle) f := "foo" fe := "bar" @@ -191,7 +192,7 @@ func TestStreamFramer_Batch(t *testing.T) { sf.Run() // Create a decoder - dec := codec.NewDecoder(r, jsonHandle) + dec := codec.NewDecoder(r, structs.JsonHandle) f := "foo" fe := "bar" @@ -268,7 +269,7 @@ func TestStreamFramer_Heartbeat(t *testing.T) { sf.Run() // Create a decoder - dec := codec.NewDecoder(r, jsonHandle) + dec := codec.NewDecoder(r, structs.JsonHandle) // Start the reader resultCh := make(chan struct{}) @@ -320,7 +321,7 @@ func TestStreamFramer_Order(t *testing.T) { sf.Run() // Create a decoder - dec := codec.NewDecoder(r, jsonHandle) + dec := codec.NewDecoder(r, structs.JsonHandle) files := []string{"1", "2", "3", "4", "5"} input := bytes.NewBuffer(make([]byte, 0, 100000)) @@ -592,7 +593,7 @@ func TestHTTP_Stream_Modify(t *testing.T) { r, w := io.Pipe() defer r.Close() defer w.Close() - dec := codec.NewDecoder(r, jsonHandle) + dec := codec.NewDecoder(r, structs.JsonHandle) data := []byte("helloworld") @@ -668,7 +669,7 @@ func TestHTTP_Stream_Truncate(t *testing.T) { r, w := io.Pipe() defer r.Close() defer w.Close() - dec := codec.NewDecoder(r, jsonHandle) + dec := codec.NewDecoder(r, structs.JsonHandle) data := []byte("helloworld") @@ -778,7 +779,7 @@ func TestHTTP_Stream_Delete(t *testing.T) { wrappedW := &WriteCloseChecker{WriteCloser: w} defer r.Close() defer w.Close() - dec := codec.NewDecoder(r, jsonHandle) + dec := codec.NewDecoder(r, structs.JsonHandle) data := []byte("helloworld") @@ -869,7 +870,7 @@ func TestHTTP_Logs_NoFollow(t *testing.T) { wrappedW := &WriteCloseChecker{WriteCloser: w} defer r.Close() defer w.Close() - dec := codec.NewDecoder(r, jsonHandle) + dec := codec.NewDecoder(r, structs.JsonHandle) var received []byte @@ -955,7 +956,7 @@ func TestHTTP_Logs_Follow(t *testing.T) { wrappedW := &WriteCloseChecker{WriteCloser: w} defer r.Close() defer w.Close() - dec := codec.NewDecoder(r, jsonHandle) + dec := codec.NewDecoder(r, structs.JsonHandle) var received []byte @@ -1071,7 +1072,7 @@ func BenchmarkHTTP_Logs_Follow(t *testing.B) { wrappedW := &WriteCloseChecker{WriteCloser: w} defer r.Close() defer w.Close() - dec := codec.NewDecoder(r, jsonHandle) + dec := codec.NewDecoder(r, structs.JsonHandle) var received []byte