MCPcopy
hub / github.com/prometheus/prometheus / TestHistogramInWALAndMmapChunk

Function TestHistogramInWALAndMmapChunk

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

Source from the content-addressed store, hash-verified

4429}
4430
4431func TestHistogramInWALAndMmapChunk(t *testing.T) {
4432 head, _ := newTestHead(t, 3000, compression.None, false)
4433 t.Cleanup(func() {
4434 // Captures head by reference, so it closes the final head after restarts.
4435 _ = head.Close()
4436 })
4437 require.NoError(t, head.Init(0))
4438
4439 // Series with only histograms.
4440 s1 := labels.FromStrings("a", "b1")
4441 k1 := s1.String()
4442 numHistograms := 300
4443 exp := map[string][]chunks.Sample{}
4444 ts := int64(0)
4445 var app storage.Appender
4446 for _, gauge := range []bool{true, false} {
4447 app = head.Appender(context.Background())
4448 var hists []*histogram.Histogram
4449 if gauge {
4450 hists = tsdbutil.GenerateTestGaugeHistograms(numHistograms)
4451 } else {
4452 hists = tsdbutil.GenerateTestHistograms(numHistograms)
4453 }
4454 for _, h := range hists {
4455 h.NegativeSpans = h.PositiveSpans
4456 h.NegativeBuckets = h.PositiveBuckets
4457 _, err := app.AppendHistogram(0, s1, ts, h, nil)
4458 require.NoError(t, err)
4459 exp[k1] = append(exp[k1], sample{t: ts, h: h.Copy()})
4460 ts++
4461 if ts%5 == 0 {
4462 require.NoError(t, app.Commit())
4463 app = head.Appender(context.Background())
4464 }
4465 }
4466 require.NoError(t, app.Commit())
4467 }
4468 for _, gauge := range []bool{true, false} {
4469 app = head.Appender(context.Background())
4470 var hists []*histogram.FloatHistogram
4471 if gauge {
4472 hists = tsdbutil.GenerateTestGaugeFloatHistograms(numHistograms)
4473 } else {
4474 hists = tsdbutil.GenerateTestFloatHistograms(numHistograms)
4475 }
4476 for _, h := range hists {
4477 h.NegativeSpans = h.PositiveSpans
4478 h.NegativeBuckets = h.PositiveBuckets
4479 _, err := app.AppendHistogram(0, s1, ts, nil, h)
4480 require.NoError(t, err)
4481 exp[k1] = append(exp[k1], sample{t: ts, fh: h.Copy()})
4482 ts++
4483 if ts%5 == 0 {
4484 require.NoError(t, app.Commit())
4485 app = head.Appender(context.Background())
4486 }
4487 }
4488 require.NoError(t, app.Commit())

Callers

nothing calls this directly

Calls 15

AppendHistogramMethod · 0.95
AppendMethod · 0.95
FromStringsFunction · 0.92
GenerateTestHistogramsFunction · 0.92
NewSizeFunction · 0.92
MustNewMatcherFunction · 0.92
newTestHeadFunction · 0.85
NewHeadFunction · 0.85
NewBlockQuerierFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…