Skip to content
This repository has been archived by the owner on Aug 13, 2019. It is now read-only.

Commit

Permalink
Avoid potential collision of createIdxChkReaders in querier_test.go (#…
Browse files Browse the repository at this point in the history
…585)

* Make chink ref monotonically increasing number in the `createIdxChkReaders` test func.
Signed-off-by: naivewong <[email protected]>
  • Loading branch information
naivewong authored and krasi-georgiev committed Apr 18, 2019
1 parent e2c6eb2 commit 7a12d45
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions querier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,11 @@ func createIdxChkReaders(tc []seriesSamples) (IndexReader, ChunkReader, int64, i
blockMint := int64(math.MaxInt64)
blockMaxt := int64(math.MinInt64)

var chunkRef uint64
for i, s := range tc {
i = i + 1 // 0 is not a valid posting.
metas := make([]chunks.Meta, 0, len(s.chunks))
for _, chk := range s.chunks {
// Collisions can be there, but for tests, its fine.
ref := rand.Uint64()

if chk[0].t < blockMint {
blockMint = chk[0].t
}
Expand All @@ -223,15 +221,16 @@ func createIdxChkReaders(tc []seriesSamples) (IndexReader, ChunkReader, int64, i
metas = append(metas, chunks.Meta{
MinTime: chk[0].t,
MaxTime: chk[len(chk)-1].t,
Ref: ref,
Ref: chunkRef,
})

chunk := chunkenc.NewXORChunk()
app, _ := chunk.Appender()
for _, smpl := range chk {
app.Append(smpl.t, smpl.v)
}
chkReader[ref] = chunk
chkReader[chunkRef] = chunk
chunkRef += 1
}

ls := labels.FromMap(s.lset)
Expand Down

0 comments on commit 7a12d45

Please sign in to comment.