(t *testing.T)
| 4611 | } |
| 4612 | |
| 4613 | func TestChunkSnapshot(t *testing.T) { |
| 4614 | for _, enableSTStorage := range []bool{false, true} { |
| 4615 | t.Run("enableSTStorage="+strconv.FormatBool(enableSTStorage), func(t *testing.T) { |
| 4616 | head, _ := newTestHead(t, 120*4, compression.None, false) |
| 4617 | defer func() { |
| 4618 | head.opts.EnableMemorySnapshotOnShutdown = false |
| 4619 | require.NoError(t, head.Close()) |
| 4620 | }() |
| 4621 | |
| 4622 | type ex struct { |
| 4623 | seriesLabels labels.Labels |
| 4624 | e exemplar.Exemplar |
| 4625 | } |
| 4626 | |
| 4627 | numSeries := 10 |
| 4628 | expSeries := make(map[string][]chunks.Sample) |
| 4629 | expHist := make(map[string][]chunks.Sample) |
| 4630 | expFloatHist := make(map[string][]chunks.Sample) |
| 4631 | expTombstones := make(map[storage.SeriesRef]tombstones.Intervals) |
| 4632 | expExemplars := make([]ex, 0) |
| 4633 | histograms := tsdbutil.GenerateTestGaugeHistograms(481) |
| 4634 | floatHistogram := tsdbutil.GenerateTestGaugeFloatHistograms(481) |
| 4635 | |
| 4636 | addExemplar := func(app storage.Appender, ref storage.SeriesRef, lbls labels.Labels, ts int64) { |
| 4637 | e := ex{ |
| 4638 | seriesLabels: lbls, |
| 4639 | e: exemplar.Exemplar{ |
| 4640 | Labels: labels.FromStrings("trace_id", strconv.Itoa(rand.Int())), |
| 4641 | Value: rand.Float64(), |
| 4642 | Ts: ts, |
| 4643 | }, |
| 4644 | } |
| 4645 | expExemplars = append(expExemplars, e) |
| 4646 | _, err := app.AppendExemplar(ref, e.seriesLabels, e.e) |
| 4647 | require.NoError(t, err) |
| 4648 | } |
| 4649 | |
| 4650 | checkSamples := func() { |
| 4651 | q, err := NewBlockQuerier(head, math.MinInt64, math.MaxInt64) |
| 4652 | require.NoError(t, err) |
| 4653 | series := query(t, q, labels.MustNewMatcher(labels.MatchRegexp, "foo", "bar.*")) |
| 4654 | require.Equal(t, expSeries, series) |
| 4655 | } |
| 4656 | checkHistograms := func() { |
| 4657 | q, err := NewBlockQuerier(head, math.MinInt64, math.MaxInt64) |
| 4658 | require.NoError(t, err) |
| 4659 | series := query(t, q, labels.MustNewMatcher(labels.MatchRegexp, "hist", "baz.*")) |
| 4660 | require.Equal(t, expHist, series) |
| 4661 | } |
| 4662 | checkFloatHistograms := func() { |
| 4663 | q, err := NewBlockQuerier(head, math.MinInt64, math.MaxInt64) |
| 4664 | require.NoError(t, err) |
| 4665 | series := query(t, q, labels.MustNewMatcher(labels.MatchRegexp, "floathist", "bat.*")) |
| 4666 | require.Equal(t, expFloatHist, series) |
| 4667 | } |
| 4668 | checkTombstones := func() { |
| 4669 | tr, err := head.Tombstones() |
| 4670 | require.NoError(t, err) |
nothing calls this directly
no test coverage detected
searching dependent graphs…