MCPcopy Index your code
hub / github.com/cortexproject/cortex / createTestLogicalPlan

Function createTestLogicalPlan

pkg/api/queryapi/query_api_test.go:472–505  ·  view source on GitHub ↗
(t *testing.T, start, end int64, stepDuration int64)

Source from the content-addressed store, hash-verified

470}
471
472func createTestLogicalPlan(t *testing.T, start, end int64, stepDuration int64) []byte {
473 startTime, endTime := convertMsToTime(start), convertMsToTime(end)
474 step := convertMsToDuration(stepDuration)
475
476 qOpts := query.Options{
477 Start: startTime,
478 End: startTime,
479 Step: 0,
480 StepsBatch: 10,
481 LookbackDelta: 0,
482 EnablePerStepStats: false,
483 }
484
485 if step != 0 {
486 qOpts.End = endTime
487 qOpts.Step = step
488 }
489
490 // using a different metric name here so that we can check with debugger which query (from query string vs http request body)
491 // is being executed by the queriers
492 expr, err := parser.NewParser("up", parser.WithFunctions(parser.Functions)).ParseExpr()
493 require.NoError(t, err)
494
495 planOpts := logicalplan.PlanOptions{
496 DisableDuplicateLabelCheck: false,
497 }
498
499 logicalPlan, err := logicalplan.NewFromAST(expr, &qOpts, planOpts)
500 require.NoError(t, err)
501 byteval, err := logicalplan.Marshal(logicalPlan.Root())
502 require.NoError(t, err)
503
504 return byteval
505}

Callers 1

Calls 3

convertMsToTimeFunction · 0.85
convertMsToDurationFunction · 0.85
MarshalMethod · 0.45

Tested by

no test coverage detected