Skip to content

Commit

Permalink
store/cache: add more tests (thanos-io#1071)
Browse files Browse the repository at this point in the history
  • Loading branch information
GiedriusS authored and bwplotka committed Apr 23, 2019
1 parent 6b06010 commit 8b818b0
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions pkg/store/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,28 @@ func TestIndexCacheEdge(t *testing.T) {

fits = cache.ensureFits([]byte{42})
testutil.Equals(t, fits, true)

fits = cache.ensureFits([]byte{})
testutil.Equals(t, fits, true)

fits = cache.ensureFits([]byte{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1})
testutil.Equals(t, fits, false)

metrics = prometheus.NewRegistry()
cache, err = newIndexCache(metrics, 0)
testutil.Ok(t, err)

fits = cache.ensureFits([]byte{42, 24})
testutil.Equals(t, fits, false)

fits = cache.ensureFits([]byte{42})
testutil.Equals(t, fits, false)

fits = cache.ensureFits([]byte{})
testutil.Equals(t, fits, true)

fits = cache.ensureFits([]byte{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1})
testutil.Equals(t, fits, false)
}

// TestIndexCacheSmoke runs the smoke tests for the index cache.
Expand Down Expand Up @@ -58,4 +80,10 @@ func TestIndexCacheSmoke(t *testing.T) {

cache.lru.RemoveOldest()
testutil.Equals(t, cache.curSize, uint64(0))

cache.setSeries(blid, 1234, []byte{1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1})
cache.setSeries(blid, 1237, []byte{1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1})
cache.setSeries(blid, 1235, []byte{1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 5})
testutil.Equals(t, cache.curSize, uint64(20))

}

0 comments on commit 8b818b0

Please sign in to comment.