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

Function TestBackendRange

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

Source from the content-addressed store, hash-verified

724}
725
726func TestBackendRange(t *testing.T) {
727 now := int(time.Now().Unix())
728 fiveMinutesAgo := int(time.Now().Add(-5 * time.Minute).Unix())
729 tenMinutesAgo := int(time.Now().Add(-10 * time.Minute).Unix())
730 fifteenMinutesAgo := int(time.Now().Add(-15 * time.Minute).Unix())
731 twentyMinutesAgo := int(time.Now().Add(-20 * time.Minute).Unix())
732
733 tests := []struct {
734 request string
735 queryBackendAfter time.Duration
736 expectedStart uint32
737 expectedEnd uint32
738 }{
739 // start/end is outside queryBackendAfter
740 {
741 request: "/?tags=foo%3Dbar&minDuration=10ms&maxDuration=30ms&limit=50&start=10&end=20",
742 queryBackendAfter: time.Minute,
743 expectedStart: 10,
744 expectedEnd: 20,
745 },
746 // start/end is inside queryBackendAfter
747 {
748 request: "/?tags=foo%3Dbar&minDuration=10ms&maxDuration=30ms&limit=50&start=" + strconv.Itoa(tenMinutesAgo) + "&end=" + strconv.Itoa(now),
749 queryBackendAfter: 15 * time.Minute,
750 expectedStart: uint32(fifteenMinutesAgo),
751 expectedEnd: uint32(fifteenMinutesAgo),
752 },
753 // queryBackendAfter = 0 results in no ingester query
754 {
755 request: "/?tags=foo%3Dbar&minDuration=10ms&maxDuration=30ms&limit=50&start=" + strconv.Itoa(tenMinutesAgo) + "&end=" + strconv.Itoa(now),
756 queryBackendAfter: 0,
757 expectedStart: uint32(tenMinutesAgo),
758 expectedEnd: uint32(now),
759 },
760 // start/end = 20 - 10 mins ago - break across query backend after
761 // ingester start/End = 15 - 10 mins ago
762 // backend start/End = 20 - 10 mins ago
763 {
764 request: "/?tags=foo%3Dbar&minDuration=10ms&maxDuration=30ms&limit=50&start=" + strconv.Itoa(twentyMinutesAgo) + "&end=" + strconv.Itoa(tenMinutesAgo),
765 queryBackendAfter: 5 * time.Minute,
766 expectedStart: uint32(twentyMinutesAgo),
767 expectedEnd: uint32(tenMinutesAgo),
768 },
769 // start/end = 10 - now mins ago - break across query backend after
770 // ingester start/End = 10 - now mins ago
771 // backend start/End = 15 - 10 mins ago
772 {
773 request: "/?tags=foo%3Dbar&minDuration=10ms&maxDuration=30ms&limit=50&start=" + strconv.Itoa(tenMinutesAgo) + "&end=" + strconv.Itoa(now),
774 queryBackendAfter: 5 * time.Minute,
775 expectedStart: uint32(tenMinutesAgo),
776 expectedEnd: uint32(fiveMinutesAgo),
777 },
778 // start/end = 20 - now mins ago - break across query backend after
779 // ingester start/End = 15 - now mins ago
780 // backend start/End = 20 - 5 mins ago
781 {
782 request: "/?tags=foo%3Dbar&minDuration=10ms&maxDuration=30ms&limit=50&start=" + strconv.Itoa(twentyMinutesAgo) + "&end=" + strconv.Itoa(now),
783 queryBackendAfter: 5 * time.Minute,

Callers

nothing calls this directly

Calls 5

ParseSearchRequestFunction · 0.92
backendRangeFunction · 0.85
NowMethod · 0.65
AddMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected