Skip to content

Commit

Permalink
store: Fixed broken context passing leading to test never ending.
Browse files Browse the repository at this point in the history
Fixes #740

Signed-off-by: Bartek Plotka <[email protected]>
  • Loading branch information
bwplotka committed Jan 16, 2019
1 parent 4e20faf commit f204838
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions pkg/store/bucket_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,14 @@ func TestBucketStore_e2e(t *testing.T) {
}
}()

ctx, _ = context.WithTimeout(ctx, 30*time.Second)

err = runutil.Retry(100*time.Millisecond, ctx.Done(), func() error {
rctx, rcancel := context.WithTimeout(ctx, 30*time.Second)
defer rcancel()
testutil.Ok(t, runutil.Retry(100*time.Millisecond, rctx.Done(), func() error {
if store.numBlocks() < 6 {
return errors.New("not all blocks loaded")
}
return nil
})
testutil.Ok(t, err)
}))

mint, maxt := store.TimeRange()
testutil.Equals(t, minTime, mint)
Expand All @@ -120,14 +119,13 @@ func TestBucketStore_e2e(t *testing.T) {
}
srv := newStoreSeriesServer(ctx)

err = store.Series(&storepb.SeriesRequest{
testutil.Ok(t, store.Series(&storepb.SeriesRequest{
Matchers: []storepb.LabelMatcher{
{Type: storepb.LabelMatcher_RE, Name: "a", Value: "1|2"},
},
MinTime: timestamp.FromTime(start),
MaxTime: timestamp.FromTime(now),
}, srv)
testutil.Ok(t, err)
}, srv))
testutil.Equals(t, len(pbseries), len(srv.SeriesSet))

for i, s := range srv.SeriesSet {
Expand All @@ -141,14 +139,13 @@ func TestBucketStore_e2e(t *testing.T) {
}
srv = newStoreSeriesServer(ctx)

err = store.Series(&storepb.SeriesRequest{
testutil.Ok(t, store.Series(&storepb.SeriesRequest{
Matchers: []storepb.LabelMatcher{
{Type: storepb.LabelMatcher_EQ, Name: "b", Value: "2"},
},
MinTime: timestamp.FromTime(start),
MaxTime: timestamp.FromTime(now),
}, srv)
testutil.Ok(t, err)
}, srv))
testutil.Equals(t, len(pbseries), len(srv.SeriesSet))

for i, s := range srv.SeriesSet {
Expand All @@ -163,15 +160,14 @@ func TestBucketStore_e2e(t *testing.T) {
}
srv = newStoreSeriesServer(ctx)

err = store.Series(&storepb.SeriesRequest{
testutil.Ok(t, store.Series(&storepb.SeriesRequest{
Matchers: []storepb.LabelMatcher{
{Type: storepb.LabelMatcher_EQ, Name: "a", Value: "1"},
{Type: storepb.LabelMatcher_EQ, Name: "ext2", Value: "value2"},
},
MinTime: timestamp.FromTime(start),
MaxTime: timestamp.FromTime(now),
}, srv)
testutil.Ok(t, err)
}, srv))
testutil.Equals(t, len(pbseries), len(srv.SeriesSet))

for i, s := range srv.SeriesSet {
Expand All @@ -180,15 +176,14 @@ func TestBucketStore_e2e(t *testing.T) {
}

srv = newStoreSeriesServer(ctx)
err = store.Series(&storepb.SeriesRequest{
testutil.Ok(t, store.Series(&storepb.SeriesRequest{
Matchers: []storepb.LabelMatcher{
{Type: storepb.LabelMatcher_EQ, Name: "a", Value: "1"},
{Type: storepb.LabelMatcher_EQ, Name: "ext2", Value: "wrong-value"},
},
MinTime: timestamp.FromTime(start),
MaxTime: timestamp.FromTime(now),
}, srv)
testutil.Ok(t, err)
}, srv))
testutil.Equals(t, 0, len(srv.SeriesSet))
})

Expand Down

0 comments on commit f204838

Please sign in to comment.