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 e8d117d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 28 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
22 changes: 11 additions & 11 deletions test/e2e/e2ethanos/services.go
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/thanos-io/thanos/pkg/receive"
)

const infologLevel = "info"
const infoLogLevel = "info"

// Same as default for now.
var defaultBackoffConfig = util.BackoffConfig{
Expand Down Expand Up @@ -73,7 +73,7 @@ func NewPrometheus(sharedDir string, name string, config, promImage string) (*e2
"--config.file": filepath.Join(container, "prometheus.yml"),
"--storage.tsdb.path": container,
"--storage.tsdb.max-block-duration": "2h",
"--log.level": infologLevel,
"--log.level": infoLogLevel,
"--web.listen-address": ":9090",
})...),
e2e.NewHTTPReadinessProbe(9090, "/-/ready", 200, 200),
Expand Down Expand Up @@ -102,7 +102,7 @@ func NewPrometheusWithSidecar(sharedDir string, netName string, name string, con
"--http-address": ":8080",
"--prometheus.url": "http://" + prom.NetworkEndpointFor(netName, 9090),
"--tsdb.path": dataDir,
"--log.level": infologLevel,
"--log.level": infoLogLevel,
})...),
e2e.NewHTTPReadinessProbe(8080, "/-/ready", 200, 200),
8080,
Expand All @@ -124,7 +124,7 @@ func NewQuerier(sharedDir, name string, storeAddresses, fileSDStoreAddresses, ru
"--http-address": ":8080",
"--query.replica-label": replicaLabel,
"--store.sd-dns-interval": "5s",
"--log.level": "debug", // remove later.
"--log.level": infoLogLevel,
"--query.max-concurrent": "1",
"--store.sd-interval": "5s",
})
Expand Down Expand Up @@ -213,7 +213,7 @@ func NewReceiver(sharedDir string, networkName string, name string, replicationF
"--remote-write.address": ":8081",
"--label": fmt.Sprintf(`receive="%s"`, name),
"--tsdb.path": filepath.Join(container, "data"),
"--log.level": logLevel,
"--log.level": infoLogLevel,
"--receive.replication-factor": strconv.Itoa(replicationFactor),
"--receive.local-endpoint": localEndpoint,
"--receive.hashrings": string(b),
Expand Down Expand Up @@ -262,7 +262,7 @@ func NewReceiverWithConfigWatcher(sharedDir string, networkName string, name str
"--remote-write.address": ":8081",
"--label": fmt.Sprintf(`receive="%s"`, name),
"--tsdb.path": filepath.Join(container, "data"),
"--log.level": infologLevel,
"--log.level": infoLogLevel,
"--receive.replication-factor": strconv.Itoa(replicationFactor),
"--receive.local-endpoint": localEndpoint,
"--receive.hashrings-file": filepath.Join(container, "hashrings.json"),
Expand Down Expand Up @@ -312,7 +312,7 @@ func NewRuler(sharedDir string, name string, ruleSubDir string, amCfg []alert.Al
"--eval-interval": "3s",
"--alertmanagers.config": string(amCfgBytes),
"--alertmanagers.sd-dns-interval": "1s",
"--log.level": infologLevel,
"--log.level": infoLogLevel,
"--query.config": string(queryCfgBytes),
"--query.sd-dns-interval": "1s",
"--resend-delay": "5s",
Expand Down Expand Up @@ -352,7 +352,7 @@ receivers:
e2e.NewCommandWithoutEntrypoint("/bin/alertmanager", e2e.BuildArgs(map[string]string{
"--config.file": filepath.Join(container, "config.yaml"),
"--web.listen-address": "0.0.0.0:8080",
"--log.level": infologLevel,
"--log.level": infoLogLevel,
"--storage.path": container,
"--web.get-concurrency": "1",
"--web.timeout": "2m",
Expand Down Expand Up @@ -391,7 +391,7 @@ func NewStoreGW(sharedDir string, name string, bucketConfig client.BucketConfig,
"--grpc-address": ":9091",
"--grpc-grace-period": "0s",
"--http-address": ":8080",
"--log.level": infologLevel,
"--log.level": infoLogLevel,
"--data-dir": container,
"--objstore.config": string(bktConfigBytes),
// Accelerated sync time for quicker test (3m by default).
Expand Down Expand Up @@ -434,7 +434,7 @@ func NewCompactor(sharedDir string, name string, bucketConfig client.BucketConfi
DefaultImage(),
e2e.NewCommand("compact", append(e2e.BuildArgs(map[string]string{
"--debug.name": fmt.Sprintf("compact-%s", name),
"--log.level": infologLevel,
"--log.level": infoLogLevel,
"--data-dir": container,
"--objstore.config": string(bktConfigBytes),
"--http-address": ":8080",
Expand All @@ -461,7 +461,7 @@ func NewQueryFrontend(name string, downstreamURL string, cacheConfig queryfronte
"--debug.name": fmt.Sprintf("query-frontend-%s", name),
"--http-address": ":8080",
"--query-frontend.downstream-url": downstreamURL,
"--log.level": infologLevel,
"--log.level": infoLogLevel,
"--query-range.response-cache-config": string(cacheConfigBytes),
})

Expand Down

0 comments on commit e8d117d

Please sign in to comment.