MCPcopy
hub / github.com/prometheus/prometheus / testScrapeLoopAppendCacheEntryButErrNotFound

Function testScrapeLoopAppendCacheEntryButErrNotFound

scrape/scrape_test.go:3138–3172  ·  view source on GitHub ↗
(t *testing.T, appV2 bool)

Source from the content-addressed store, hash-verified

3136}
3137
3138func testScrapeLoopAppendCacheEntryButErrNotFound(t *testing.T, appV2 bool) {
3139 appTest := teststorage.NewAppendable()
3140 sl, _ := newTestScrapeLoop(t, withAppendable(appTest, appV2))
3141
3142 fakeRef := storage.SeriesRef(1)
3143 expValue := float64(1)
3144 metric := []byte(`metric{n="1"} 1`)
3145 p, warning := textparse.New(metric, "text/plain", labels.NewSymbolTable(), textparse.ParserOptions{})
3146 require.NotNil(t, p)
3147 require.NoError(t, warning)
3148
3149 var lset labels.Labels
3150 _, err := p.Next()
3151 require.NoError(t, err)
3152 p.Labels(&lset)
3153 hash := lset.Hash()
3154
3155 // Create a fake entry in the cache
3156 sl.cache.addRef(metric, fakeRef, lset, hash)
3157 now := time.Now()
3158
3159 app := sl.appender()
3160 _, _, _, err = app.append(metric, "text/plain", now)
3161 require.NoError(t, err)
3162 require.NoError(t, app.Commit())
3163
3164 expected := []sample{
3165 {
3166 L: lset,
3167 T: timestamp.FromTime(now),
3168 V: expValue,
3169 },
3170 }
3171 teststorage.RequireEqual(t, expected, appTest.ResultSamples())
3172}
3173
3174type appendableFunc func(ctx context.Context) storage.Appender
3175

Calls 15

HashMethod · 0.95
ResultSamplesMethod · 0.95
NewAppendableFunction · 0.92
SeriesRefTypeAlias · 0.92
NewFunction · 0.92
NewSymbolTableFunction · 0.92
FromTimeFunction · 0.92
RequireEqualFunction · 0.92
newTestScrapeLoopFunction · 0.85
withAppendableFunction · 0.85
addRefMethod · 0.80
NextMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…