(t *testing.T, marshalingFormat api.MarshallingFormat)
| 25 | } |
| 26 | |
| 27 | func testSearchProgressShouldQuitAny(t *testing.T, marshalingFormat api.MarshallingFormat) { |
| 28 | // new combiner should not quit |
| 29 | c := NewSearch(0, false, marshalingFormat, false) |
| 30 | should := c.ShouldQuit() |
| 31 | require.False(t, should) |
| 32 | |
| 33 | // 500 response should quit |
| 34 | c = NewSearch(0, false, marshalingFormat, false) |
| 35 | err := c.AddResponse(toHTTPResponseWithFormat(t, &tempopb.SearchResponse{}, 500, nil, marshalingFormat)) |
| 36 | require.NoError(t, err) |
| 37 | should = c.ShouldQuit() |
| 38 | require.True(t, should) |
| 39 | |
| 40 | // 429 response should quit |
| 41 | c = NewSearch(0, false, marshalingFormat, false) |
| 42 | err = c.AddResponse(toHTTPResponseWithFormat(t, &tempopb.SearchResponse{}, 429, nil, marshalingFormat)) |
| 43 | require.NoError(t, err) |
| 44 | should = c.ShouldQuit() |
| 45 | require.True(t, should) |
| 46 | |
| 47 | // unparseable body should not quit, but should return an error |
| 48 | c = NewSearch(0, false, marshalingFormat, false) |
| 49 | err = c.AddResponse(&testPipelineResponse{r: &http.Response{Body: io.NopCloser(strings.NewReader("foo")), StatusCode: 200}}) |
| 50 | require.Error(t, err) |
| 51 | should = c.ShouldQuit() |
| 52 | require.False(t, should) |
| 53 | |
| 54 | // under limit should not quit |
| 55 | c = NewSearch(2, false, marshalingFormat, false) |
| 56 | err = c.AddResponse(toHTTPResponseWithFormat(t, &tempopb.SearchResponse{ |
| 57 | Traces: []*tempopb.TraceSearchMetadata{ |
| 58 | { |
| 59 | TraceID: "1", |
| 60 | }, |
| 61 | }, |
| 62 | }, 200, nil, marshalingFormat)) |
| 63 | require.NoError(t, err) |
| 64 | should = c.ShouldQuit() |
| 65 | require.False(t, should) |
| 66 | |
| 67 | // over limit should quit |
| 68 | c = NewSearch(1, false, marshalingFormat, false) |
| 69 | err = c.AddResponse(toHTTPResponseWithFormat(t, &tempopb.SearchResponse{ |
| 70 | Traces: []*tempopb.TraceSearchMetadata{ |
| 71 | { |
| 72 | TraceID: "1", |
| 73 | }, |
| 74 | { |
| 75 | TraceID: "2", |
| 76 | }, |
| 77 | }, |
| 78 | }, 200, nil, marshalingFormat)) |
| 79 | require.NoError(t, err) |
| 80 | should = c.ShouldQuit() |
| 81 | require.True(t, should) |
| 82 | } |
| 83 | |
| 84 | func TestSearchProgressShouldQuitMostRecentJSON(t *testing.T) { |
no test coverage detected