diff --git a/nomad/node_endpoint_test.go b/nomad/node_endpoint_test.go index 22f919bb3df..909e2a63715 100644 --- a/nomad/node_endpoint_test.go +++ b/nomad/node_endpoint_test.go @@ -1365,8 +1365,30 @@ func TestClientEndpoint_GetClientAllocs_Blocking(t *testing.T) { t.Fatalf("bad: %#v", resp2.Allocs) } - if resp2.Allocs[0].ModifyTime != now { - t.Fatalf("Invalid modify time %v", resp2.Allocs[0].ModifyTime) + iter, err := state.AllocsByIDPrefix(nil, structs.DefaultNamespace, alloc.ID) + if err != nil { + t.Fatalf("err: %v", err) + } + + getAllocs := func(iter memdb.ResultIterator) []*structs.Allocation { + var allocs []*structs.Allocation + for { + raw := iter.Next() + if raw == nil { + break + } + allocs = append(allocs, raw.(*structs.Allocation)) + } + return allocs + } + out := getAllocs(iter) + + if len(out) != 1 { + t.Fatalf("Expected to get one allocation but got:%v", out) + } + + if out[0].ModifyTime != now { + t.Fatalf("Invalid modify time %v", out[0].ModifyTime) } // Alloc updates fire watches