(t *testing.T)
| 7081 | } |
| 7082 | |
| 7083 | func 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 | |
| 7106 | func TestHeadAppender_AppendFloatWithSameTimestampAsPreviousHistogram(t *testing.T) { |
| 7107 | head, _ := newTestHead(t, DefaultBlockDuration, compression.None, false) |
nothing calls this directly
no test coverage detected
searching dependent graphs…