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

Function testSearchCombinesResults

modules/frontend/combiner/search_test.go:196–247  ·  view source on GitHub ↗
(t *testing.T, marshalingFormat api.MarshallingFormat)

Source from the content-addressed store, hash-verified

194}
195
196func testSearchCombinesResults(t *testing.T, marshalingFormat api.MarshallingFormat) {
197 for _, keepMostRecent := range []bool{true, false} {
198 start := time.Date(1, 2, 3, 4, 5, 6, 7, time.UTC)
199 traceID := "traceID"
200
201 c := NewSearch(10, keepMostRecent, marshalingFormat, false)
202 sr := toHTTPResponseWithFormat(t, &tempopb.SearchResponse{
203 Traces: []*tempopb.TraceSearchMetadata{
204 {
205 TraceID: traceID,
206 StartTimeUnixNano: uint64(start.Add(time.Second).UnixNano()),
207 DurationMs: uint32(time.Second.Milliseconds()),
208 }, // 1 second after start and shorter duration
209 {
210 TraceID: traceID,
211 StartTimeUnixNano: uint64(start.UnixNano()),
212 DurationMs: uint32(time.Hour.Milliseconds()),
213 }, // earliest start time and longer duration
214 {
215 TraceID: traceID,
216 StartTimeUnixNano: uint64(start.Add(time.Hour).UnixNano()),
217 DurationMs: uint32(time.Millisecond.Milliseconds()),
218 }, // 1 hour after start and shorter duration
219 },
220 Metrics: &tempopb.SearchMetrics{},
221 }, 200, nil, marshalingFormat)
222 err := c.AddResponse(sr)
223 require.NoError(t, err)
224
225 expected := &tempopb.SearchResponse{
226 Traces: []*tempopb.TraceSearchMetadata{
227 {
228 TraceID: traceID,
229 StartTimeUnixNano: uint64(start.UnixNano()),
230 DurationMs: uint32(time.Hour.Milliseconds()),
231 RootServiceName: search.RootSpanNotYetReceivedText,
232 },
233 },
234 Metrics: &tempopb.SearchMetrics{
235 CompletedJobs: 1,
236 },
237 }
238
239 resp, err := c.HTTPFinal()
240 require.NoError(t, err)
241
242 actual := &tempopb.SearchResponse{}
243 fromHTTPResponse(t, resp, actual)
244
245 require.Equal(t, expected, actual)
246 }
247}
248
249func TestSearchResponseCombinerJSON(t *testing.T) {
250 testSearchResponseCombiner(t, api.MarshallingFormatJSON)

Calls 7

NewSearchFunction · 0.85
toHTTPResponseWithFormatFunction · 0.85
fromHTTPResponseFunction · 0.85
AddMethod · 0.65
AddResponseMethod · 0.65
HTTPFinalMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected