MCPcopy
hub / github.com/prometheus/prometheus / TestChunkSnapshot

Function TestChunkSnapshot

tsdb/head_test.go:4613–4902  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

4611}
4612
4613func 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)

Callers

nothing calls this directly

Calls 15

TombstonesMethod · 0.95
FromStringsFunction · 0.92
MustNewMatcherFunction · 0.92
RequireEqualWithOptionsFunction · 0.92
NewSizeFunction · 0.92
SeriesRefTypeAlias · 0.92
newTestHeadFunction · 0.85
NewBlockQuerierFunction · 0.85
LastChunkSnapshotFunction · 0.85
NewHeadFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…