fix blocking query due to ctx change

This commit is contained in:
Alex Dadgar
2017-08-31 15:34:55 -07:00
parent 394567fc5e
commit 633dbb81d1
2 changed files with 5 additions and 3 deletions

View File

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

View File

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