MCPcopy
hub / github.com/grafana/tempo / TestSkipASTTransformationsMerge

Function TestSkipASTTransformationsMerge

modules/frontend/search_sharder_test.go:1413–1495  ·  modules/frontend/search_sharder_test.go::TestSkipASTTransformationsMerge

TestSkipASTTransformationsMerge verifies that the per-request skip_ast_transformations URL parameter is merged with the global config list rather than overwritten by it.

(t *testing.T)

Source from the content-addressed store, hash-verified

1411// TestSkipASTTransformationsMerge verifies that the per-request skip_ast_transformations
1412// URL parameter is merged with the global config list rather than overwritten by it.
1413func TestSkipASTTransformationsMerge(t *testing.T) {
1414 tests := []struct {
1415 name string
1416 globalSkip []string
1417 requestSkip string // URL param value; empty means param is absent
1418 expectedSkip []string
1419 }{
1420 {
1421 name: "global config only",
1422 globalSkip: []string{"global_skip"},
1423 requestSkip: "",
1424 expectedSkip: []string{"global_skip"},
1425 },
1426 {
1427 name: "per-request only",
1428 globalSkip: nil,
1429 requestSkip: "per_req_skip",
1430 expectedSkip: []string{"per_req_skip"},
1431 },
1432 {
1433 name: "merge global and per-request",
1434 globalSkip: []string{"global_skip"},
1435 requestSkip: "per_req_skip",
1436 expectedSkip: []string{"global_skip", "per_req_skip"},
1437 },
1438 {
1439 name: "duplicated entries",
1440 globalSkip: []string{"or_to_in"},
1441 requestSkip: "or_to_in",
1442 expectedSkip: []string{"or_to_in"},
1443 },
1444 {
1445 name: "neither",
1446 globalSkip: nil,
1447 requestSkip: "",
1448 expectedSkip: nil,
1449 },
1450 }
1451
1452 for _, tc := range tests {
1453 t.Run(tc.name, func(t *testing.T) {
1454 var capturedSkip []string
1455
1456 next := pipeline.AsyncRoundTripperFunc[combiner.PipelineResponse](func(r pipeline.Request) (pipeline.Responses[combiner.PipelineResponse], error) {
1457 req, err := api.ParseSearchRequest(r.HTTPRequest())
1458 if err == nil {
1459 capturedSkip = req.SkipASTTransformations
1460 }
1461 return pipeline.NewAsyncResponse(nil), nil
1462 })
1463
1464 o, err := overrides.NewOverrides(overrides.Config{}, nil, prometheus.DefaultRegisterer)
1465 require.NoError(t, err)
1466
1467 sharder := newAsyncSearchSharder(&mockReader{}, o, SearchSharderConfig{
1468 ConcurrentRequests: defaultConcurrentRequests,
1469 TargetBytesPerRequest: defaultTargetBytesPerRequest,
1470 }, tc.globalSkip, newJobsPerQueryHistogram(), log.NewNopLogger())

Callers

nothing calls this directly

Calls 13

ContextMethod · 0.95
ParseSearchRequestFunction · 0.92
NewAsyncResponseFunction · 0.92
NewOverridesFunction · 0.92
NewHTTPRequestFunction · 0.92
newAsyncSearchSharderFunction · 0.85
newJobsPerQueryHistogramFunction · 0.85
HTTPRequestMethod · 0.65
WrapMethod · 0.65
RoundTripMethod · 0.65
NextMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected