MCPcopy
hub / github.com/prometheus/prometheus / TestMemSeriesIsolation

Function TestMemSeriesIsolation

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

Source from the content-addressed store, hash-verified

3102}
3103
3104func TestMemSeriesIsolation(t *testing.T) {
3105 if defaultIsolationDisabled {
3106 t.Skip("skipping test since tsdb isolation is disabled")
3107 }
3108
3109 // Put a series, select it. GC it and then access it.
3110 lastValue := func(h *Head, maxAppendID uint64) int {
3111 idx, err := h.Index()
3112
3113 require.NoError(t, err)
3114
3115 iso := h.iso.State(math.MinInt64, math.MaxInt64)
3116 iso.maxAppendID = maxAppendID
3117
3118 chunks, err := h.chunksRange(math.MinInt64, math.MaxInt64, iso)
3119 require.NoError(t, err)
3120 // Hm.. here direct block chunk querier might be required?
3121 querier := blockQuerier{
3122 blockBaseQuerier: &blockBaseQuerier{
3123 index: idx,
3124 chunks: chunks,
3125 tombstones: tombstones.NewMemTombstones(),
3126
3127 mint: 0,
3128 maxt: 10000,
3129 },
3130 }
3131
3132 require.NoError(t, err)
3133 defer querier.Close()
3134
3135 ss := querier.Select(context.Background(), false, nil, labels.MustNewMatcher(labels.MatchEqual, "foo", "bar"))
3136 _, seriesSet, ws, err := expandSeriesSet(ss)
3137 require.NoError(t, err)
3138 require.Empty(t, ws)
3139
3140 for _, series := range seriesSet {
3141 return int(series[len(series)-1].f)
3142 }
3143 return -1
3144 }
3145
3146 addSamples := func(h *Head) int {
3147 i := 1
3148 for ; i <= 1000; i++ {
3149 var app storage.Appender
3150 // To initialize bounds.
3151 if h.MinTime() == math.MaxInt64 {
3152 app = &initAppender{head: h}
3153 } else {
3154 a := h.appender()
3155 a.cleanupAppendIDsBelow = 0
3156 app = a
3157 }
3158
3159 _, err := app.Append(0, labels.FromStrings("foo", "bar"), int64(i), float64(i))
3160 require.NoError(t, err)
3161 require.NoError(t, app.Commit())

Callers

nothing calls this directly

Calls 15

SelectMethod · 0.95
AppendMethod · 0.95
NewMemTombstonesFunction · 0.92
MustNewMatcherFunction · 0.92
FromStringsFunction · 0.92
NewSizeFunction · 0.92
newTestHeadFunction · 0.85
DefaultHeadOptionsFunction · 0.85
NewHeadFunction · 0.85
SkipMethod · 0.80
chunksRangeMethod · 0.80
mmapHeadChunksMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…