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

Function TestLiveTracesSizesAndLen

pkg/livetraces/livetraces_test.go:23–56  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

21)
22
23func TestLiveTracesSizesAndLen(t *testing.T) {
24 lt := New[*v1.ResourceSpans](func(rs *v1.ResourceSpans) uint64 { return uint64(rs.Size()) }, time.Millisecond, time.Second, testTenantID)
25
26 expectedSz := uint64(0)
27 expectedLen := uint64(0)
28
29 for i := 0; i < 100; i++ {
30 id := test.ValidTraceID(nil)
31 tr := test.MakeTrace(rand.IntN(5)+1, id)
32
33 nowTime := time.Now()
34
35 // add some traces and confirm size/len
36 expectedLen++
37 for _, rs := range tr.ResourceSpans {
38 expectedSz += uint64(rs.Size())
39 lt.Push(id, rs, 0)
40 }
41
42 require.Equal(t, expectedSz, lt.Size())
43 require.Equal(t, expectedLen, lt.Len())
44
45 // cut some traces and confirm size/len
46 for tr := range lt.CutIdle(nowTime, false) {
47 for _, rs := range tr.Batches {
48 expectedSz -= uint64(rs.Size())
49 }
50 expectedLen--
51 }
52
53 require.Equal(t, expectedSz, lt.Size())
54 require.Equal(t, expectedLen, lt.Len())
55 }
56}
57
58func TestCutIdleDueToIdleTime(t *testing.T) {
59 lt := New(func(rs *v1.ResourceSpans) uint64 { return uint64(rs.Size()) }, time.Second, time.Hour, testTenantID)

Callers

nothing calls this directly

Calls 9

ValidTraceIDFunction · 0.92
MakeTraceFunction · 0.92
CutIdleMethod · 0.80
NewFunction · 0.70
SizeMethod · 0.65
NowMethod · 0.65
LenMethod · 0.65
PushMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected