(t *testing.T)
| 513 | } |
| 514 | |
| 515 | func Test_convertV2RequestToV1(t *testing.T) { |
| 516 | var v2Req cortexpb.PreallocWriteRequestV2 |
| 517 | |
| 518 | fh := tsdbutil.GenerateTestFloatHistogram(1) |
| 519 | ph := cortexpb.WrapHistogram(cortexpb.FloatHistogramToHistogramProto(4, fh)) |
| 520 | |
| 521 | symbols := []string{"", "__name__", "test_metric", "b", "c", "baz", "qux", "d", "e", "foo", "bar", "f", "g", "h", "i", "Test gauge for test purposes", "Maybe op/sec who knows (:", "Test counter for test purposes"} |
| 522 | timeseries := []cortexpb.PreallocTimeseriesV2{ |
| 523 | { |
| 524 | TimeSeriesV2: &cortexpb.TimeSeriesV2{ |
| 525 | LabelsRefs: []uint32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, |
| 526 | Metadata: cortexpb.MetadataV2{ |
| 527 | Type: cortexpb.METRIC_TYPE_COUNTER, |
| 528 | |
| 529 | HelpRef: 15, |
| 530 | UnitRef: 16, |
| 531 | }, |
| 532 | Samples: []cortexpb.Sample{{Value: 1, TimestampMs: 1}}, |
| 533 | Exemplars: []cortexpb.ExemplarV2{{LabelsRefs: []uint32{11, 12}, Value: 1, Timestamp: 1}}, |
| 534 | }, |
| 535 | }, |
| 536 | { |
| 537 | TimeSeriesV2: &cortexpb.TimeSeriesV2{ |
| 538 | LabelsRefs: []uint32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, |
| 539 | Samples: []cortexpb.Sample{{Value: 2, TimestampMs: 2}}, |
| 540 | }, |
| 541 | }, |
| 542 | { |
| 543 | TimeSeriesV2: &cortexpb.TimeSeriesV2{ |
| 544 | LabelsRefs: []uint32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, |
| 545 | Samples: []cortexpb.Sample{{Value: 3, TimestampMs: 3}}, |
| 546 | }, |
| 547 | }, |
| 548 | { |
| 549 | TimeSeriesV2: &cortexpb.TimeSeriesV2{ |
| 550 | LabelsRefs: []uint32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, |
| 551 | Histograms: []cortexpb.WrappedHistogram{ph, ph}, |
| 552 | Exemplars: []cortexpb.ExemplarV2{{LabelsRefs: []uint32{11, 12}, Value: 1, Timestamp: 1}}, |
| 553 | }, |
| 554 | }, |
| 555 | } |
| 556 | |
| 557 | v2Req.Symbols = symbols |
| 558 | v2Req.Timeseries = timeseries |
| 559 | v1Req, err := convertV2RequestToV1(&v2Req, false) |
| 560 | assert.NoError(t, err) |
| 561 | expectedSamples := 3 |
| 562 | expectedExemplars := 2 |
| 563 | expectedHistograms := 2 |
| 564 | countSamples := 0 |
| 565 | countExemplars := 0 |
| 566 | countHistograms := 0 |
| 567 | |
| 568 | for _, ts := range v1Req.Timeseries { |
| 569 | countSamples += len(ts.Samples) |
| 570 | countExemplars += len(ts.Exemplars) |
| 571 | countHistograms += len(ts.Histograms) |
| 572 | } |
nothing calls this directly
no test coverage detected