MCPcopy
hub / github.com/grafana/tempo / FuzzExemplarsForBlock

Function FuzzExemplarsForBlock

modules/frontend/metrics_query_range_sharder_test.go:272–296  ·  view source on GitHub ↗
(f *testing.F)

Source from the content-addressed store, hash-verified

270}
271
272func FuzzExemplarsForBlock(f *testing.F) {
273 f.Add(uint32(100), uint32(60)) // limit = 100, duration = 60s
274 f.Add(uint32(0), uint32(30)) // limit = 0, duration = 30s
275 f.Add(uint32(1000), uint32(0)) // limit = 1000, duration = 0s
276
277 s := &queryRangeSharder{}
278
279 f.Fuzz(func(t *testing.T, limit uint32, value uint32) {
280 now := time.Now()
281 block := &backend.BlockMeta{
282 BlockID: backend.MustParse(uuid.NewString()),
283 StartTime: now.Add(-time.Duration(value) * time.Second),
284 EndTime: now,
285 }
286
287 totalDurationNanos := int64(value) * 1e9
288 result := s.exemplarsForBlock(block, limit, totalDurationNanos)
289
290 if limit == 0 || value == 0 {
291 assert.Equal(t, uint32(0), result, "result should be 0")
292 } else {
293 assert.Greater(t, result, uint32(0), "result should be greater than 0")
294 }
295 })
296}
297
298// nolint: gosec // G115
299func TestExemplarsCutoff(t *testing.T) {

Callers

nothing calls this directly

Calls 6

exemplarsForBlockMethod · 0.95
MustParseFunction · 0.92
DurationMethod · 0.80
AddMethod · 0.65
NowMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected