MCPcopy
hub / github.com/prometheus/prometheus / TestPostingsCardinalityStats

Function TestPostingsCardinalityStats

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

Source from the content-addressed store, hash-verified

7081}
7082
7083func TestPostingsCardinalityStats(t *testing.T) {
7084 head := &Head{postings: index.NewMemPostings()}
7085 head.postings.Add(1, labels.FromStrings(labels.MetricName, "t", "n", "v1"))
7086 head.postings.Add(2, labels.FromStrings(labels.MetricName, "t", "n", "v2"))
7087
7088 statsForMetricName := head.PostingsCardinalityStats(labels.MetricName, 10)
7089 head.postings.Add(3, labels.FromStrings(labels.MetricName, "t", "n", "v3"))
7090 // Using cache.
7091 require.Equal(t, statsForMetricName, head.PostingsCardinalityStats(labels.MetricName, 10))
7092
7093 statsForSomeLabel := head.PostingsCardinalityStats("n", 10)
7094 // Cache should be evicted because of the change of label name.
7095 require.NotEqual(t, statsForMetricName, statsForSomeLabel)
7096 head.postings.Add(4, labels.FromStrings(labels.MetricName, "t", "n", "v4"))
7097 // Using cache.
7098 require.Equal(t, statsForSomeLabel, head.PostingsCardinalityStats("n", 10))
7099 // Cache should be evicted because of the change of limit parameter.
7100 statsForSomeLabel1 := head.PostingsCardinalityStats("n", 1)
7101 require.NotEqual(t, statsForSomeLabel1, statsForSomeLabel)
7102 // Using cache.
7103 require.Equal(t, statsForSomeLabel1, head.PostingsCardinalityStats("n", 1))
7104}
7105
7106func TestHeadAppender_AppendFloatWithSameTimestampAsPreviousHistogram(t *testing.T) {
7107 head, _ := newTestHead(t, DefaultBlockDuration, compression.None, false)

Callers

nothing calls this directly

Calls 4

NewMemPostingsFunction · 0.92
FromStringsFunction · 0.92
AddMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…