From cfb68457bcdc6734f2748bef6f5f5ea80d959323 Mon Sep 17 00:00:00 2001 From: Mahmood Ali Date: Thu, 10 Jan 2019 15:36:57 -0500 Subject: [PATCH] tests: WaitForRunning checks for pending only WaitForRunning risks a race condition where the allocation succeeds and completes before WaitForRunning is called (or while it is running). Here, I made the behavior match the function documentation. I considered making it stricter, but callers need to account for allocation terminating immediately after WaitForRunning terminates anyway. --- testutil/wait.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testutil/wait.go b/testutil/wait.go index c85333552..7c947a3c6 100644 --- a/testutil/wait.go +++ b/testutil/wait.go @@ -123,7 +123,7 @@ func WaitForRunning(t testing.T, rpc rpcFn, job *structs.Job) []*structs.AllocLi } for _, alloc := range resp.Allocations { - if alloc.ClientStatus != structs.AllocClientStatusRunning { + if alloc.ClientStatus == structs.AllocClientStatusPending { return false, fmt.Errorf("alloc not running: id=%v tg=%v status=%v", alloc.ID, alloc.TaskGroup, alloc.ClientStatus) }