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

Function TestBackendRequests

modules/frontend/search_sharder_test.go:384–489  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

382}
383
384func TestBackendRequests(t *testing.T) {
385 bm := backend.NewBlockMeta("test", uuid.New(), "wdwad")
386 bm.StartTime = time.Unix(100, 0)
387 bm.EndTime = time.Unix(200, 0)
388 bm.Size_ = defaultTargetBytesPerRequest * 2
389 bm.TotalRecords = 2
390
391 s := &asyncSearchSharder{
392 cfg: SearchSharderConfig{
393 MostRecentShards: defaultMostRecentShards,
394 },
395 reader: &mockReader{metas: []*backend.BlockMeta{bm}},
396 }
397
398 tests := []struct {
399 name string
400 request string
401 expectedReqsURIs []string
402 expectedJobs int
403 expectedBlocks int
404 expectedBlockBytes uint64
405 }{
406 {
407 name: "start and end same as block",
408 request: "/?tags=foo%3Dbar&minDuration=10ms&maxDuration=30ms&limit=50&start=100&end=200",
409 expectedReqsURIs: []string{
410 "/querier?blockID=" + bm.BlockID.String() + "&encoding=none&end=200&footerSize=0&indexPageSize=0&limit=50&maxDuration=30ms&minDuration=10ms&pagesToSearch=1&size=209715200&spss=3&start=100&startPage=0&tags=foo%3Dbar&totalRecords=2&version=wdwad",
411 "/querier?blockID=" + bm.BlockID.String() + "&encoding=none&end=200&footerSize=0&indexPageSize=0&limit=50&maxDuration=30ms&minDuration=10ms&pagesToSearch=1&size=209715200&spss=3&start=100&startPage=1&tags=foo%3Dbar&totalRecords=2&version=wdwad",
412 },
413 expectedJobs: 2,
414 expectedBlocks: 1,
415 expectedBlockBytes: defaultTargetBytesPerRequest * 2,
416 },
417 {
418 name: "start and end in block",
419 request: "/?tags=foo%3Dbar&minDuration=10ms&maxDuration=30ms&limit=50&start=110&end=150",
420 expectedReqsURIs: []string{
421 "/querier?blockID=" + bm.BlockID.String() + "&encoding=none&end=150&footerSize=0&indexPageSize=0&limit=50&maxDuration=30ms&minDuration=10ms&pagesToSearch=1&size=209715200&spss=3&start=110&startPage=0&tags=foo%3Dbar&totalRecords=2&version=wdwad",
422 "/querier?blockID=" + bm.BlockID.String() + "&encoding=none&end=150&footerSize=0&indexPageSize=0&limit=50&maxDuration=30ms&minDuration=10ms&pagesToSearch=1&size=209715200&spss=3&start=110&startPage=1&tags=foo%3Dbar&totalRecords=2&version=wdwad",
423 },
424 expectedJobs: 2,
425 expectedBlocks: 1,
426 expectedBlockBytes: defaultTargetBytesPerRequest * 2,
427 },
428 {
429 name: "skip_ast_transformations propagated to backend block requests",
430 request: "/?start=100&end=200&skip_ast_transformations=or_to_in",
431 expectedReqsURIs: []string{
432 "/querier?blockID=" + bm.BlockID.String() + "&encoding=none&end=200&footerSize=0&indexPageSize=0&pagesToSearch=1&size=209715200&skip_ast_transformations=or_to_in&spss=3&start=100&startPage=0&totalRecords=2&version=wdwad",
433 "/querier?blockID=" + bm.BlockID.String() + "&encoding=none&end=200&footerSize=0&indexPageSize=0&pagesToSearch=1&size=209715200&skip_ast_transformations=or_to_in&spss=3&start=100&startPage=1&totalRecords=2&version=wdwad",
434 },
435 expectedJobs: 2,
436 expectedBlocks: 1,
437 expectedBlockBytes: defaultTargetBytesPerRequest * 2,
438 },
439 {
440 name: "start and end out of block",
441 request: "/?tags=foo%3Dbar&minDuration=10ms&maxDuration=30ms&limit=50&start=10&end=20",

Callers

nothing calls this directly

Calls 9

backendRequestsMethod · 0.95
HTTPRequestMethod · 0.95
NewBlockMetaFunction · 0.92
ParseSearchRequestFunction · 0.92
NewHTTPRequestFunction · 0.92
urisEqualFunction · 0.85
StringMethod · 0.45
RunMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected