(t *testing.T, marshalingFormat api.MarshallingFormat)
| 194 | } |
| 195 | |
| 196 | func 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 | |
| 249 | func TestSearchResponseCombinerJSON(t *testing.T) { |
| 250 | testSearchResponseCombiner(t, api.MarshallingFormatJSON) |
no test coverage detected