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

Function TestLogClusterCache_PutGet

pkg/drain/log_cluster_cache_test.go:12–35  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestLogClusterCache_PutGet(t *testing.T) {
13 t.Parallel()
14
15 evictions := prometheus.NewCounter(prometheus.CounterOpts{Name: "evictions"})
16 expired := prometheus.NewCounter(prometheus.CounterOpts{Name: "expired"})
17
18 cache := newLogClusterCache(1*time.Hour, 100, evictions, expired)
19
20 cluster1 := &LogCluster{id: 1, Tokens: []string{"GET", "/users"}, ParamString: "<_>"}
21 cluster2 := &LogCluster{id: 2, Tokens: []string{"POST", "/users"}, ParamString: "<_>"}
22
23 cache.Put(cluster1)
24 cache.Put(cluster2)
25
26 // Get should retrieve clusters
27 retrieved1 := cache.Get(1)
28 require.NotNil(t, retrieved1)
29 assert.Equal(t, cluster1.id, retrieved1.id)
30 assert.Equal(t, cluster1.Tokens, retrieved1.Tokens)
31
32 retrieved2 := cache.Get(2)
33 require.NotNil(t, retrieved2)
34 assert.Equal(t, cluster2.id, retrieved2.id)
35}
36
37func TestLogClusterCache_GetQuietly(t *testing.T) {
38 t.Parallel()

Callers

nothing calls this directly

Calls 5

newLogClusterCacheFunction · 0.85
NewCounterMethod · 0.65
GetMethod · 0.65
PutMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected