| 427 | } |
| 428 | |
| 429 | func sampledResponseHTTPHandler(t *testing.T) http.HandlerFunc { |
| 430 | return func(w http.ResponseWriter, _ *http.Request) { |
| 431 | w.Header().Set("Content-Type", "application/x-protobuf") |
| 432 | |
| 433 | resp := prompb.ReadResponse{ |
| 434 | Results: []*prompb.QueryResult{ |
| 435 | { |
| 436 | Timeseries: []*prompb.TimeSeries{ |
| 437 | { |
| 438 | Labels: []prompb.Label{ |
| 439 | {Name: "foo2", Value: "bar"}, |
| 440 | }, |
| 441 | Samples: []prompb.Sample{ |
| 442 | {Value: float64(1), Timestamp: int64(0)}, |
| 443 | {Value: float64(2), Timestamp: int64(5)}, |
| 444 | }, |
| 445 | Exemplars: []prompb.Exemplar{}, |
| 446 | }, |
| 447 | { |
| 448 | Labels: []prompb.Label{ |
| 449 | {Name: "foo1", Value: "bar"}, |
| 450 | }, |
| 451 | Samples: []prompb.Sample{ |
| 452 | {Value: float64(3), Timestamp: int64(0)}, |
| 453 | {Value: float64(4), Timestamp: int64(5)}, |
| 454 | }, |
| 455 | Exemplars: []prompb.Exemplar{}, |
| 456 | }, |
| 457 | }, |
| 458 | }, |
| 459 | }, |
| 460 | } |
| 461 | b, err := proto.Marshal(&resp) |
| 462 | require.NoError(t, err) |
| 463 | |
| 464 | _, err = w.Write(snappy.Encode(nil, b)) |
| 465 | require.NoError(t, err) |
| 466 | } |
| 467 | } |
| 468 | |
| 469 | func delayedResponseHTTPHandler(t *testing.T, delay time.Duration) http.HandlerFunc { |
| 470 | return func(w http.ResponseWriter, _ *http.Request) { |