Skip to content

Commit

Permalink
Disable active query tracker in querier test (#5318)
Browse files Browse the repository at this point in the history
* remove parallel tests if we create a query engine

Signed-off-by: Ben Ye <benye@amazon.com>

* disable active query tracker

Signed-off-by: Ben Ye <benye@amazon.com>

---------

Signed-off-by: Ben Ye <benye@amazon.com>
  • Loading branch information
yeya24 authored May 4, 2023
1 parent ae56807 commit 04566a5
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 64 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ require (
github.com/sony/gobreaker v0.5.0
github.com/spf13/afero v1.9.5
github.com/stretchr/testify v1.8.2
github.com/thanos-community/promql-engine v0.0.0-20230424192336-6fec99413de8
github.com/thanos-community/promql-engine v0.0.0-20230503192559-c9c196cc08b3
github.com/thanos-io/objstore v0.0.0-20230201072718-11ffbc490204
github.com/thanos-io/thanos v0.31.1-0.20230418080134-0c2af2155056
github.com/uber/jaeger-client-go v2.30.0+incompatible
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1864,8 +1864,8 @@ github.com/tchap/go-patricia v2.2.6+incompatible/go.mod h1:bmLyhP68RS6kStMGxByiQ
github.com/tencentyun/cos-go-sdk-v5 v0.7.40 h1:W6vDGKCHe4wBACI1d2UgE6+50sJFhRWU4O8IB2ozzxM=
github.com/thanos-community/galaxycache v0.0.0-20211122094458-3a32041a1f1e h1:f1Zsv7OAU9iQhZwigp50Yl38W10g/vd5NC8Rdk1Jzng=
github.com/thanos-community/galaxycache v0.0.0-20211122094458-3a32041a1f1e/go.mod h1:jXcofnrSln/cLI6/dhlBxPQZEEQHVPCcFaH75M+nSzM=
github.com/thanos-community/promql-engine v0.0.0-20230424192336-6fec99413de8 h1:BQZw3InOmxnOb27fpdG/5gWEOydSQu+ylCsxGLRtMaY=
github.com/thanos-community/promql-engine v0.0.0-20230424192336-6fec99413de8/go.mod h1:PbimG7ocz5JmFRLlQ7yMcewnkunNBmvMyVgAoNmyvDw=
github.com/thanos-community/promql-engine v0.0.0-20230503192559-c9c196cc08b3 h1:WkhJnkQIHooPQ3A9vRvb0yub8+q3pTNshLvg0rU8YiA=
github.com/thanos-community/promql-engine v0.0.0-20230503192559-c9c196cc08b3/go.mod h1:PbimG7ocz5JmFRLlQ7yMcewnkunNBmvMyVgAoNmyvDw=
github.com/thanos-io/objstore v0.0.0-20230201072718-11ffbc490204 h1:W4w5Iph7j32Sf1QFWLJDCqvO0WgZS0jHGID+qnq3wV0=
github.com/thanos-io/objstore v0.0.0-20230201072718-11ffbc490204/go.mod h1:STSgpY8M6EKF2G/raUFdbIMf2U9GgYlEjAEHJxjvpAo=
github.com/thanos-io/thanos v0.31.1-0.20230418080134-0c2af2155056 h1:x0jPHfsMnf8DtdxD4B2nMZAbIXza3y/wWgmVLV+3Gxc=
Expand Down
2 changes: 0 additions & 2 deletions pkg/querier/blocks_consistency_checker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import (
)

func TestBlocksConsistencyChecker_Check(t *testing.T) {
//parallel testing causes data race

now := time.Now()
uploadGracePeriod := 10 * time.Minute
deletionGracePeriod := 5 * time.Minute
Expand Down
1 change: 1 addition & 0 deletions pkg/querier/blocks_store_queryable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1336,6 +1336,7 @@ func TestBlocksStoreQuerier_SelectSortedShouldHonorQueryStoreAfter(t *testing.T)
}

func TestBlocksStoreQuerier_PromQLExecution(t *testing.T) {
t.Parallel()
logger := log.NewNopLogger()
opts := promql.EngineOpts{
Logger: logger,
Expand Down
8 changes: 4 additions & 4 deletions pkg/querier/chunk_store_queryable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ import (
var _ SeriesWithChunks = &chunkSeries{}

func TestChunkQueryable(t *testing.T) {
t.Parallel()
opts := promql.EngineOpts{
Logger: log.NewNopLogger(),
ActiveQueryTracker: promql.NewActiveQueryTracker(t.TempDir(), 10, log.NewNopLogger()),
MaxSamples: 1e6,
Timeout: 1 * time.Minute,
Logger: log.NewNopLogger(),
MaxSamples: 1e6,
Timeout: 1 * time.Minute,
}
for _, thanosEngine := range []bool{false, true} {
for _, testcase := range testcases {
Expand Down
2 changes: 0 additions & 2 deletions pkg/querier/error_translate_queryable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ import (
)

func TestApiStatusCodes(t *testing.T) {
t.Parallel()

for ix, tc := range []struct {
err error
expectedString string
Expand Down
50 changes: 28 additions & 22 deletions pkg/querier/querier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ var (
)

func TestShouldSortSeriesIfQueryingMultipleQueryables(t *testing.T) {
t.Parallel()
start := time.Now().Add(-2 * time.Hour)
end := time.Now()
ctx := user.InjectOrgID(context.Background(), "0")
Expand Down Expand Up @@ -274,13 +275,10 @@ func TestShouldSortSeriesIfQueryingMultipleQueryables(t *testing.T) {
wQueriables = append(wQueriables, &wrappedSampleAndChunkQueryable{QueryableWithFilter: queriable})
}
queryable := NewQueryable(wDistributorQueriable, wQueriables, batch.NewChunkMergeIterator, cfg, overrides, purger.NewNoopTombstonesLoader())
queryTracker := promql.NewActiveQueryTracker(t.TempDir(), 10, log.NewNopLogger())

opts := promql.EngineOpts{
Logger: log.NewNopLogger(),
ActiveQueryTracker: queryTracker,
MaxSamples: 1e6,
Timeout: 1 * time.Minute,
Logger: log.NewNopLogger(),
MaxSamples: 1e6,
Timeout: 1 * time.Minute,
}
var queryEngine v1.QueryEngine
if thanosEngine {
Expand Down Expand Up @@ -310,6 +308,7 @@ func TestShouldSortSeriesIfQueryingMultipleQueryables(t *testing.T) {
}

func TestQuerier(t *testing.T) {
t.Parallel()
var cfg Config
flagext.DefaultValues(&cfg)

Expand All @@ -322,10 +321,9 @@ func TestQuerier(t *testing.T) {
db, _ := mockTSDB(t, []labels.Labels{lset}, model.Time(0), int(chunks*samplesPerChunk), sampleRate, chunkOffset, int(samplesPerChunk))

opts := promql.EngineOpts{
Logger: log.NewNopLogger(),
ActiveQueryTracker: promql.NewActiveQueryTracker(t.TempDir(), 10, log.NewNopLogger()),
MaxSamples: 1e6,
Timeout: 1 * time.Minute,
Logger: log.NewNopLogger(),
MaxSamples: 1e6,
Timeout: 1 * time.Minute,
}
for _, thanosEngine := range []bool{false, true} {
for _, query := range queries {
Expand All @@ -345,6 +343,8 @@ func TestQuerier(t *testing.T) {
}
cfg.IngesterStreaming = streaming
cfg.Iterators = iterators
// Disable active query tracker to avoid mmap error.
cfg.ActiveQueryTrackerDir = ""

chunkStore, through := makeMockChunkStore(t, chunks, encoding.e)
distributor := mockDistibutorFor(t, chunkStore, through)
Expand Down Expand Up @@ -405,6 +405,7 @@ func mockTSDB(t *testing.T, labels []labels.Labels, mint model.Time, samples int
}

func TestNoHistoricalQueryToIngester(t *testing.T) {
t.Parallel()
testCases := []struct {
name string
mint, maxt time.Time
Expand Down Expand Up @@ -448,14 +449,14 @@ func TestNoHistoricalQueryToIngester(t *testing.T) {
},
}

queryTracker := promql.NewActiveQueryTracker(t.TempDir(), 10, log.NewNopLogger())
opts := promql.EngineOpts{
Logger: log.NewNopLogger(),
ActiveQueryTracker: queryTracker,
MaxSamples: 1e6,
Timeout: 1 * time.Minute,
Logger: log.NewNopLogger(),
MaxSamples: 1e6,
Timeout: 1 * time.Minute,
}
cfg := Config{}
// Disable active query tracker to avoid mmap error.
cfg.ActiveQueryTrackerDir = ""
for _, ingesterStreaming := range []bool{true, false} {
for _, thanosEngine := range []bool{true, false} {
cfg.IngesterStreaming = ingesterStreaming
Expand Down Expand Up @@ -557,6 +558,8 @@ func TestQuerier_ValidateQueryTimeRange_MaxQueryIntoFuture(t *testing.T) {

cfg := Config{}
flagext.DefaultValues(&cfg)
// Disable active query tracker to avoid mmap error.
cfg.ActiveQueryTrackerDir = ""

for _, ingesterStreaming := range []bool{true, false} {
cfg.IngesterStreaming = ingesterStreaming
Expand Down Expand Up @@ -648,6 +651,8 @@ func TestQuerier_ValidateQueryTimeRange_MaxQueryLength(t *testing.T) {
//parallel testing causes data race
var cfg Config
flagext.DefaultValues(&cfg)
// Disable active query tracker to avoid mmap error.
cfg.ActiveQueryTrackerDir = ""

limits := DefaultLimitsConfig()
limits.MaxQueryLength = model.Duration(maxQueryLength)
Expand Down Expand Up @@ -785,6 +790,8 @@ func TestQuerier_ValidateQueryTimeRange_MaxQueryLookback(t *testing.T) {
flagext.DefaultValues(&cfg)
cfg.IngesterStreaming = ingesterStreaming
cfg.IngesterMetadataStreaming = ingesterStreaming
// Disable active query tracker to avoid mmap error.
cfg.ActiveQueryTrackerDir = ""

limits := DefaultLimitsConfig()
limits.MaxQueryLookback = testData.maxQueryLookback
Expand Down Expand Up @@ -1219,7 +1226,7 @@ func (q *mockStoreQuerier) Close() error {
}

func TestShortTermQueryToLTS(t *testing.T) {
//parallel testing causes data race
t.Parallel()
testCases := []struct {
name string
mint, maxt time.Time
Expand Down Expand Up @@ -1257,17 +1264,16 @@ func TestShortTermQueryToLTS(t *testing.T) {
},
}

queryTracker := promql.NewActiveQueryTracker(t.TempDir(), 10, log.NewNopLogger())

engine := promql.NewEngine(promql.EngineOpts{
Logger: log.NewNopLogger(),
ActiveQueryTracker: queryTracker,
MaxSamples: 1e6,
Timeout: 1 * time.Minute,
Logger: log.NewNopLogger(),
MaxSamples: 1e6,
Timeout: 1 * time.Minute,
})

cfg := Config{}
flagext.DefaultValues(&cfg)
// Disable active query tracker to avoid mmap error.
cfg.ActiveQueryTrackerDir = ""

for _, ingesterStreaming := range []bool{true, false} {
cfg.IngesterStreaming = ingesterStreaming
Expand Down
15 changes: 13 additions & 2 deletions vendor/github.com/thanos-community/promql-engine/engine/engine.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 04566a5

Please sign in to comment.