MCPcopy Create free account
hub / github.com/cortexproject/cortex / TestQuerier

Function TestQuerier

pkg/querier/querier_test.go:542–584  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

540}
541
542func TestQuerier(t *testing.T) {
543 var cfg Config
544 flagext.DefaultValues(&cfg)
545 const chunks = 24
546
547 opts := promql.EngineOpts{
548 Logger: promslog.NewNopLogger(),
549 MaxSamples: 1e6,
550 Timeout: 1 * time.Minute,
551 }
552 for _, thanosEngine := range []bool{false, true} {
553 for _, query := range queries {
554 encs := encodings
555 if len(query.encodings) > 0 {
556 encs = query.encodings
557 }
558 for _, enc := range encs {
559 t.Run(fmt.Sprintf("thanosEngine=%t,encoding=%s,query=%s", thanosEngine, enc.String(), query.query), func(t *testing.T) {
560 var queryEngine promql.QueryEngine
561 if thanosEngine {
562 queryEngine = engine.New(engine.Opts{
563 EngineOpts: opts,
564 LogicalOptimizers: logicalplan.AllOptimizers,
565 })
566 } else {
567 queryEngine = promql.NewEngine(opts)
568 }
569 // Disable active query tracker to avoid mmap error.
570 cfg.ActiveQueryTrackerDir = ""
571
572 chunkStore, through := makeMockChunkStore(t, chunks, enc)
573 distributor := mockDistibutorFor(t, chunkStore.chunks)
574
575 overrides := validation.NewOverrides(DefaultLimitsConfig(), nil)
576
577 queryables := []QueryableWithFilter{UseAlwaysQueryable(NewMockStoreQueryable(chunkStore))}
578 queryable, _, _ := New(cfg, overrides, distributor, queryables, nil, log.NewNopLogger(), nil)
579 testRangeQuery(t, queryable, queryEngine, through, query, enc)
580 })
581 }
582 }
583 }
584}
585
586func TestQuerierMetric(t *testing.T) {
587 var cfg Config

Callers

nothing calls this directly

Calls 11

DefaultValuesFunction · 0.92
NewOverridesFunction · 0.92
makeMockChunkStoreFunction · 0.85
mockDistibutorForFunction · 0.85
DefaultLimitsConfigFunction · 0.85
UseAlwaysQueryableFunction · 0.85
NewMockStoreQueryableFunction · 0.85
testRangeQueryFunction · 0.85
NewFunction · 0.70
RunMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected