From bc7e8fea9e8528ee2ba3dc0ecaeabe3022d4ece8 Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Sun, 11 Oct 2015 18:35:09 -0400 Subject: [PATCH] nomad: make tests more robust --- nomad/worker_test.go | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/nomad/worker_test.go b/nomad/worker_test.go index 81837d99e..a56dfefe1 100644 --- a/nomad/worker_test.go +++ b/nomad/worker_test.go @@ -52,7 +52,12 @@ func TestWorker_dequeueEvaluation(t *testing.T) { // Create the evaluation eval1 := mock.Eval() - s1.evalBroker.Enqueue(eval1) + testutil.WaitForResult(func() (bool, error) { + err := s1.evalBroker.Enqueue(eval1) + return err == nil, err + }, func(err error) { + t.Fatalf("err: %v", err) + }) // Create a worker w := &Worker{srv: s1, logger: s1.logger} @@ -82,7 +87,12 @@ func TestWorker_dequeueEvaluation_paused(t *testing.T) { // Create the evaluation eval1 := mock.Eval() - s1.evalBroker.Enqueue(eval1) + testutil.WaitForResult(func() (bool, error) { + err := s1.evalBroker.Enqueue(eval1) + return err == nil, err + }, func(err error) { + t.Fatalf("err: %v", err) + }) // Create a worker w := &Worker{srv: s1, logger: s1.logger} @@ -153,7 +163,12 @@ func TestWorker_sendAck(t *testing.T) { // Create the evaluation eval1 := mock.Eval() - s1.evalBroker.Enqueue(eval1) + testutil.WaitForResult(func() (bool, error) { + err := s1.evalBroker.Enqueue(eval1) + return err == nil, err + }, func(err error) { + t.Fatalf("err: %v", err) + }) // Create a worker w := &Worker{srv: s1, logger: s1.logger}