Skip to content

Commit

Permalink
store: Cleaned up API for test/benchmark purposes.
Browse files Browse the repository at this point in the history
Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>
  • Loading branch information
bwplotka committed Feb 25, 2021
1 parent 55dcf83 commit 04ea1a1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 17 deletions.
5 changes: 1 addition & 4 deletions pkg/api/query/v1.go
Expand Up @@ -21,7 +21,6 @@ package v1

import (
"context"
"fmt"
"math"
"net/http"
"sort"
Expand Down Expand Up @@ -327,7 +326,6 @@ func (qapi *QueryAPI) query(r *http.Request) (interface{}, []error, *api.ApiErro
}

func (qapi *QueryAPI) queryRange(r *http.Request) (interface{}, []error, *api.ApiError) {
reqTime := time.Now()
start, err := parseTime(r.FormValue("start"))
if err != nil {
return nil, nil, &api.ApiError{Typ: api.ErrorBadData, Err: err}
Expand All @@ -342,7 +340,7 @@ func (qapi *QueryAPI) queryRange(r *http.Request) (interface{}, []error, *api.Ap
}

step, apiErr := qapi.parseStep(r, qapi.defaultRangeQueryStep, int64(end.Sub(start)/time.Second))
if err != nil {
if apiErr != nil {
return nil, nil, apiErr
}

Expand Down Expand Up @@ -432,7 +430,6 @@ func (qapi *QueryAPI) queryRange(r *http.Request) (interface{}, []error, *api.Ap
return nil, nil, &api.ApiError{Typ: api.ErrorExec, Err: res.Err}
}

fmt.Println("Request took:", time.Since(reqTime))
return &queryData{
ResultType: res.Value.Type(),
Result: res.Value,
Expand Down
2 changes: 1 addition & 1 deletion pkg/store/bucket.go
Expand Up @@ -2367,7 +2367,7 @@ func chunkOffsetsToByteRanges(offsets []uint32, start uint32) byteRanges {
ranges[idx] = byteRange{
// The byte range offset is required to be relative to the start of the read slice.
offset: int(offsets[idx] - start),
length: maxChunkSize,
length: EstimatedMaxChunkSize,
}

if idx > 0 {
Expand Down
15 changes: 3 additions & 12 deletions pkg/store/bucket_test.go
Expand Up @@ -1638,9 +1638,6 @@ func TestSeries_ErrorUnmarshallingRequestHints(t *testing.T) {
indexCache, err := storecache.NewInMemoryIndexCacheWithConfig(logger, nil, storecache.InMemoryIndexCacheConfig{})
testutil.Ok(tb, err)

chunkPool, err := NewDefaultChunkBytesPool(1000000)
testutil.Ok(t, err)

store, err := NewBucketStore(
logger,
nil,
Expand All @@ -1649,7 +1646,7 @@ func TestSeries_ErrorUnmarshallingRequestHints(t *testing.T) {
tmpDir,
indexCache,
nil,
chunkPool,
nil,
NewChunksLimiterFactory(10000/MaxSamplesPerChunk),
NewSeriesLimiterFactory(0),
NewGapBasedPartitioner(PartitionerMaxGapSize),
Expand Down Expand Up @@ -1738,9 +1735,6 @@ func TestSeries_BlockWithMultipleChunks(t *testing.T) {
indexCache, err := storecache.NewInMemoryIndexCacheWithConfig(logger, nil, storecache.InMemoryIndexCacheConfig{})
testutil.Ok(tb, err)

chunkPool, err := NewDefaultChunkBytesPool(1000000)
testutil.Ok(t, err)

store, err := NewBucketStore(
logger,
nil,
Expand All @@ -1749,7 +1743,7 @@ func TestSeries_BlockWithMultipleChunks(t *testing.T) {
tmpDir,
indexCache,
nil,
chunkPool,
nil,
NewChunksLimiterFactory(100000/MaxSamplesPerChunk),
NewSeriesLimiterFactory(0),
NewGapBasedPartitioner(PartitionerMaxGapSize),
Expand Down Expand Up @@ -2055,9 +2049,6 @@ func setupStoreForHintsTest(t *testing.T) (testutil.TB, *BucketStore, []*storepb
indexCache, err := storecache.NewInMemoryIndexCacheWithConfig(logger, nil, storecache.InMemoryIndexCacheConfig{})
testutil.Ok(tb, err)

chunkPool, err := NewDefaultChunkBytesPool(1000000)
testutil.Ok(t, err)

store, err := NewBucketStore(
logger,
nil,
Expand All @@ -2066,7 +2057,7 @@ func setupStoreForHintsTest(t *testing.T) (testutil.TB, *BucketStore, []*storepb
tmpDir,
indexCache,
nil,
chunkPool,
nil,
NewChunksLimiterFactory(10000/MaxSamplesPerChunk),
NewSeriesLimiterFactory(0),
NewGapBasedPartitioner(PartitionerMaxGapSize),
Expand Down

0 comments on commit 04ea1a1

Please sign in to comment.