MCPcopy
hub / github.com/prometheus/prometheus / TestCompaction_populateBlock

Function TestCompaction_populateBlock

tsdb/compact_test.go:554–1175  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

552}
553
554func TestCompaction_populateBlock(t *testing.T) {
555 for _, tc := range []struct {
556 title string
557 inputSeriesSamples [][]seriesSamples
558 compactMinTime int64
559 compactMaxTime int64 // When not defined the test runner sets a default of math.MaxInt64.
560 irPostingsFunc IndexReaderPostingsFunc
561 expSeriesSamples []seriesSamples
562 expErr error
563 }{
564 {
565 title: "Populate block from empty input should return error.",
566 inputSeriesSamples: [][]seriesSamples{},
567 expErr: errors.New("cannot populate block from no readers"),
568 },
569 {
570 // Populate from single block without chunks. We expect these kind of series being ignored.
571 inputSeriesSamples: [][]seriesSamples{
572 {{lset: map[string]string{"a": "b"}}},
573 },
574 },
575 {
576 title: "Populate from single block. We expect the same samples at the output.",
577 inputSeriesSamples: [][]seriesSamples{
578 {
579 {
580 lset: map[string]string{"a": "b"},
581 chunks: [][]sample{{{t: 0}, {t: 10}}, {{t: 11}, {t: 20}}},
582 },
583 },
584 },
585 expSeriesSamples: []seriesSamples{
586 {
587 lset: map[string]string{"a": "b"},
588 chunks: [][]sample{{{t: 0}, {t: 10}}, {{t: 11}, {t: 20}}},
589 },
590 },
591 },
592 {
593 title: "Populate from two blocks.",
594 inputSeriesSamples: [][]seriesSamples{
595 {
596 {
597 lset: map[string]string{"a": "b"},
598 chunks: [][]sample{{{t: 0}, {t: 10}}, {{t: 11}, {t: 20}}},
599 },
600 {
601 lset: map[string]string{"a": "c"},
602 chunks: [][]sample{{{t: 1}, {t: 9}}, {{t: 10}, {t: 19}}},
603 },
604 {
605 // no-chunk series should be dropped.
606 lset: map[string]string{"a": "empty"},
607 },
608 },
609 {
610 {
611 lset: map[string]string{"a": "b"},

Callers

nothing calls this directly

Calls 15

PopulateBlockMethod · 0.95
NextMethod · 0.95
AtMethod · 0.95
AtHistogramMethod · 0.95
AtFloatHistogramMethod · 0.95
ErrMethod · 0.95
GenerateTestHistogramFunction · 0.92
EmptyPostingsFunction · 0.92
samplesForRangeFunction · 0.85
createIdxChkReadersFunction · 0.85
NewLeveledCompactorFunction · 0.85
MapMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…