nolint: gosec // G115
(t *testing.T)
| 297 | |
| 298 | // nolint: gosec // G115 |
| 299 | func TestExemplarsCutoff(t *testing.T) { |
| 300 | s := &queryRangeSharder{} |
| 301 | now := time.Now() |
| 302 | cutoff := now.Add(-1 * time.Hour) |
| 303 | |
| 304 | testCases := []struct { |
| 305 | name string |
| 306 | req tempopb.QueryRangeRequest |
| 307 | expectedBeforeCut uint32 |
| 308 | expectedAfterCut uint32 |
| 309 | }{ |
| 310 | { |
| 311 | // Instant queries zero exemplars before calling exemplarsCutoff; both sides must be 0. |
| 312 | name: "zero exemplars (instant mode) spanning cutoff", |
| 313 | req: tempopb.QueryRangeRequest{ |
| 314 | Start: uint64(cutoff.Add(-20 * time.Minute).UnixNano()), |
| 315 | End: uint64(now.UnixNano()), |
| 316 | Exemplars: 0, |
| 317 | }, |
| 318 | expectedBeforeCut: 0, |
| 319 | expectedAfterCut: 0, |
| 320 | }, |
| 321 | { |
| 322 | // When all data is after the cutoff, all exemplars should go to the 'after' portion |
| 323 | name: "all data after cutoff", |
| 324 | req: tempopb.QueryRangeRequest{ |
| 325 | Start: uint64(cutoff.Add(50 * time.Minute).UnixNano()), |
| 326 | End: uint64(now.UnixNano()), |
| 327 | Exemplars: 100, |
| 328 | }, |
| 329 | expectedBeforeCut: 0, |
| 330 | expectedAfterCut: 100, |
| 331 | }, |
| 332 | { |
| 333 | // When all data is before the cutoff, all exemplars should go to the 'before' portion |
| 334 | name: "all data before cutoff", |
| 335 | req: tempopb.QueryRangeRequest{ |
| 336 | Start: uint64(cutoff.Add(-2 * time.Hour).UnixNano()), |
| 337 | End: uint64(cutoff.Add(-10 * time.Minute).UnixNano()), |
| 338 | Exemplars: 100, |
| 339 | }, |
| 340 | expectedBeforeCut: 100, |
| 341 | expectedAfterCut: 0, |
| 342 | }, |
| 343 | { |
| 344 | name: "data spans the cutoff - 75% after", |
| 345 | req: tempopb.QueryRangeRequest{ |
| 346 | Start: uint64(cutoff.Add(-20 * time.Minute).UnixNano()), |
| 347 | End: uint64(now.UnixNano()), |
| 348 | Exemplars: 100, |
| 349 | }, |
| 350 | expectedBeforeCut: 25, |
| 351 | expectedAfterCut: 75, |
| 352 | }, |
| 353 | { |
| 354 | name: "data spans the cutoff - 25% after", |
| 355 | req: tempopb.QueryRangeRequest{ |
| 356 | Start: uint64(cutoff.Add(-3 * time.Hour).UnixNano()), |
nothing calls this directly
no test coverage detected