From c4e1dc339dcb14faf5810cb918718bf981297cd4 Mon Sep 17 00:00:00 2001 From: Chelsea Holland Komlo Date: Tue, 5 Dec 2017 10:12:40 -0500 Subject: [PATCH] fix up test --- client/driver/rkt_test.go | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/client/driver/rkt_test.go b/client/driver/rkt_test.go index c41f749ed..d492aa2ea 100644 --- a/client/driver/rkt_test.go +++ b/client/driver/rkt_test.go @@ -19,6 +19,7 @@ import ( "github.com/hashicorp/nomad/client/config" "github.com/hashicorp/nomad/nomad/structs" "github.com/hashicorp/nomad/testutil" + "github.com/stretchr/testify/assert" ctestutils "github.com/hashicorp/nomad/client/testutil" ) @@ -334,6 +335,7 @@ func TestRktDriver_Start_Wait_AllocDir(t *testing.T) { } func TestRktDriverUser(t *testing.T) { + assert := assert.New(t) if !testutil.IsTravis() { t.Parallel() } @@ -366,18 +368,19 @@ func TestRktDriverUser(t *testing.T) { defer ctx.AllocDir.Destroy() d := NewRktDriver(ctx.DriverCtx) - if _, err := d.Prestart(ctx.ExecCtx, task); err != nil { - t.Fatalf("error in prestart: %v", err) - } + _, err := d.Prestart(ctx.ExecCtx, task) + assert.Nil(err) resp, err := d.Start(ctx.ExecCtx, task) - if err == nil { - resp.Handle.Kill() - t.Fatalf("Should've failed") - } - msg := "unknown user alice" - if !strings.Contains(err.Error(), msg) { - t.Fatalf("Expecting '%v' in '%v'", msg, err) + assert.Nil(err) + defer resp.Handle.Kill() + + select { + case res := <-resp.Handle.WaitCh(): + assert.False(res.Successful()) + case <-time.After(time.Duration(testutil.TestMultiplier()*15) * time.Second): + t.Fatalf("timeout") } + } func TestRktTrustPrefix(t *testing.T) {