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

Function testSearchResponseCombiner

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

Source from the content-addressed store, hash-verified

255}
256
257func testSearchResponseCombiner(t *testing.T, marshalingFormat api.MarshallingFormat) {
258 for _, keepMostRecent := range []bool{true, false} {
259 tests := []struct {
260 name string
261 response1 PipelineResponse
262 response2 PipelineResponse
263
264 expectedStatus int
265 expectedResponse *tempopb.SearchResponse
266 expectedHTTPError error
267 expectedGRPCError error
268 }{
269 {
270 name: "empty returns",
271 response1: toHTTPResponseWithFormat(t, &tempopb.SearchResponse{Metrics: &tempopb.SearchMetrics{}}, 200, nil, marshalingFormat),
272 response2: toHTTPResponseWithFormat(t, &tempopb.SearchResponse{Metrics: &tempopb.SearchMetrics{}}, 200, nil, marshalingFormat),
273 expectedStatus: 200,
274 expectedResponse: &tempopb.SearchResponse{
275 Traces: []*tempopb.TraceSearchMetadata{},
276 Metrics: &tempopb.SearchMetrics{
277 CompletedJobs: 2,
278 },
279 },
280 },
281 {
282 name: "404+200",
283 response1: toHTTPResponseWithFormat(t, nil, 404, nil, marshalingFormat),
284 response2: toHTTPResponseWithFormat(t, &tempopb.SearchResponse{Metrics: &tempopb.SearchMetrics{}}, 200, nil, marshalingFormat),
285 expectedStatus: 404,
286 expectedGRPCError: status.Error(codes.NotFound, ""),
287 },
288 {
289 name: "200+400",
290 response1: toHTTPResponseWithFormat(t, &tempopb.SearchResponse{Metrics: &tempopb.SearchMetrics{}}, 200, nil, marshalingFormat),
291 response2: toHTTPResponseWithFormat(t, nil, 400, nil, marshalingFormat),
292 expectedStatus: 400,
293 expectedGRPCError: status.Error(codes.InvalidArgument, ""),
294 },
295 {
296 name: "200+429",
297 response1: toHTTPResponseWithFormat(t, &tempopb.SearchResponse{Metrics: &tempopb.SearchMetrics{}}, 200, nil, marshalingFormat),
298 response2: toHTTPResponseWithFormat(t, nil, 429, nil, marshalingFormat),
299 expectedStatus: 429,
300 expectedGRPCError: status.Error(codes.ResourceExhausted, ""),
301 },
302 {
303 name: "500+404",
304 response1: toHTTPResponseWithFormat(t, nil, 500, nil, marshalingFormat),
305 response2: toHTTPResponseWithFormat(t, nil, 404, nil, marshalingFormat),
306 expectedStatus: 500,
307 expectedGRPCError: status.Error(codes.Internal, ""),
308 },
309 {
310 name: "404+500 - first bad response wins",
311 response1: toHTTPResponseWithFormat(t, nil, 404, nil, marshalingFormat),
312 response2: toHTTPResponseWithFormat(t, nil, 500, nil, marshalingFormat),
313 expectedStatus: 404,
314 expectedGRPCError: status.Error(codes.NotFound, ""),

Calls 8

toHTTPResponseWithFormatFunction · 0.85
NewTypedSearchFunction · 0.85
ErrorMethod · 0.65
AddResponseMethod · 0.65
HTTPFinalMethod · 0.65
GRPCFinalMethod · 0.65
RunMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected