MCPcopy Create free account
hub / github.com/deepflowio/deepflow / TestLabel_AddAndGet

Function TestLabel_AddAndGet

server/controller/prometheus/cache/cache_test.go:358–374  ·  view source on GitHub ↗

============================================================================ 第一部分:正确性测试 — 基本功能 ============================================================================

(t *testing.T)

Source from the content-addressed store, hash-verified

356// ============================================================================
357
358func TestLabel_AddAndGet(t *testing.T) {
359 l := newTestLabel()
360 batch := generateProtoLabels(100)
361 populateLabelDeps(l, 100)
362
363 l.Add(batch)
364
365 for _, item := range batch {
366 id, ok := l.GetIDByKey(NewLabelKey(item.GetName(), item.GetValue()))
367 assert.True(t, ok)
368 assert.Equal(t, int(item.GetId()), id)
369 }
370
371 // 不存在的 key
372 _, ok := l.GetIDByKey(NewLabelKey("nonexistent", "nonexistent"))
373 assert.False(t, ok)
374}
375
376func TestMetricName_AddAndGet(t *testing.T) {
377 mn := newTestMetricName()

Callers

nothing calls this directly

Calls 9

newTestLabelFunction · 0.85
generateProtoLabelsFunction · 0.85
populateLabelDepsFunction · 0.85
NewLabelKeyFunction · 0.85
GetNameMethod · 0.65
AddMethod · 0.45
GetIDByKeyMethod · 0.45
GetValueMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected