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.
This commit is contained in:
Mahmood Ali 2019-01-10 15:36:57 -05:00
parent 614f63f40d
commit b7d421a149

View file

@ -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)
}