mirror of
https://github.com/kemko/nomad.git
synced 2026-01-09 03:45:41 +03:00
fix blocking query due to ctx change
This commit is contained in:
@@ -122,9 +122,11 @@ RUN_QUERY:
|
||||
|
||||
// We haven't reached the min-index yet.
|
||||
if minIndex > 0 && index <= minIndex {
|
||||
if expired := ws.WatchCtx(ctx); !expired {
|
||||
goto RUN_QUERY
|
||||
if err := ws.WatchCtx(ctx); err != nil {
|
||||
return nil, index, err
|
||||
}
|
||||
|
||||
goto RUN_QUERY
|
||||
}
|
||||
|
||||
return resp, index, nil
|
||||
|
||||
@@ -51,7 +51,7 @@ func TestStateStore_Blocking_Timeout(t *testing.T) {
|
||||
defer cancel()
|
||||
|
||||
_, idx, err := state.BlockingQuery(noopFn, 10, deadlineCtx)
|
||||
assert.Nil(t, err)
|
||||
assert.EqualError(t, err, context.DeadlineExceeded.Error())
|
||||
assert.EqualValues(t, 5, idx)
|
||||
assert.WithinDuration(t, timeout, time.Now(), 5*time.Millisecond)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user