MCPcopy
hub / github.com/prometheus/prometheus / TestCumulativeBucketIterator

Function TestCumulativeBucketIterator

model/histogram/histogram_test.go:97–298  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

95}
96
97func TestCumulativeBucketIterator(t *testing.T) {
98 cases := []struct {
99 histogram Histogram
100 expectedBuckets []Bucket[uint64]
101 }{
102 {
103 histogram: Histogram{
104 Schema: 0,
105 PositiveSpans: []Span{
106 {Offset: 0, Length: 2},
107 {Offset: 1, Length: 2},
108 },
109 PositiveBuckets: []int64{1, 1, -1, 0},
110 },
111 expectedBuckets: []Bucket[uint64]{
112 {Lower: math.Inf(-1), Upper: 1, Count: 1, LowerInclusive: true, UpperInclusive: true, Index: 0},
113 {Lower: math.Inf(-1), Upper: 2, Count: 3, LowerInclusive: true, UpperInclusive: true, Index: 1},
114
115 {Lower: math.Inf(-1), Upper: 4, Count: 3, LowerInclusive: true, UpperInclusive: true, Index: 2},
116
117 {Lower: math.Inf(-1), Upper: 8, Count: 4, LowerInclusive: true, UpperInclusive: true, Index: 3},
118 {Lower: math.Inf(-1), Upper: 16, Count: 5, LowerInclusive: true, UpperInclusive: true, Index: 4},
119 },
120 },
121 {
122 histogram: Histogram{
123 Schema: 0,
124 PositiveSpans: []Span{
125 {Offset: 0, Length: 5},
126 {Offset: 1, Length: 1},
127 },
128 PositiveBuckets: []int64{1, 2, -2, 1, -1, 0},
129 },
130 expectedBuckets: []Bucket[uint64]{
131 {Lower: math.Inf(-1), Upper: 1, Count: 1, LowerInclusive: true, UpperInclusive: true, Index: 0},
132 {Lower: math.Inf(-1), Upper: 2, Count: 4, LowerInclusive: true, UpperInclusive: true, Index: 1},
133 {Lower: math.Inf(-1), Upper: 4, Count: 5, LowerInclusive: true, UpperInclusive: true, Index: 2},
134 {Lower: math.Inf(-1), Upper: 8, Count: 7, LowerInclusive: true, UpperInclusive: true, Index: 3},
135
136 {Lower: math.Inf(-1), Upper: 16, Count: 8, LowerInclusive: true, UpperInclusive: true, Index: 4},
137
138 {Lower: math.Inf(-1), Upper: 32, Count: 8, LowerInclusive: true, UpperInclusive: true, Index: 5},
139 {Lower: math.Inf(-1), Upper: 64, Count: 9, LowerInclusive: true, UpperInclusive: true, Index: 6},
140 },
141 },
142 {
143 histogram: Histogram{
144 Schema: 0,
145 PositiveSpans: []Span{
146 {Offset: 0, Length: 7},
147 },
148 PositiveBuckets: []int64{1, 2, -2, 1, -1, 0, 0},
149 },
150 expectedBuckets: []Bucket[uint64]{
151 {Lower: math.Inf(-1), Upper: 1, Count: 1, LowerInclusive: true, UpperInclusive: true, Index: 0},
152 {Lower: math.Inf(-1), Upper: 2, Count: 4, LowerInclusive: true, UpperInclusive: true, Index: 1},
153 {Lower: math.Inf(-1), Upper: 4, Count: 5, LowerInclusive: true, UpperInclusive: true, Index: 2},
154 {Lower: math.Inf(-1), Upper: 8, Count: 7, LowerInclusive: true, UpperInclusive: true, Index: 3},

Callers

nothing calls this directly

Calls 4

RunMethod · 0.65
NextMethod · 0.65
AtMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…