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

Function TestCombineProtoTotals

pkg/model/trace/combine_test.go:19–65  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

17)
18
19func TestCombineProtoTotals(t *testing.T) {
20 methods := []func(a, b *tempopb.Trace) (*tempopb.Trace, int){
21 func(a, b *tempopb.Trace) (*tempopb.Trace, int) {
22 c := NewCombiner(0, false)
23 _, err := c.Consume(a)
24 require.NoError(t, err)
25 _, err = c.Consume(b)
26 require.NoError(t, err)
27 return c.Result()
28 },
29 }
30
31 sameTrace := test.MakeTraceWithSpanCount(10, 10, []byte{0x01, 0x03})
32 tests := []struct {
33 traceA *tempopb.Trace
34 traceB *tempopb.Trace
35 expectedTotal int
36 }{
37 {
38 traceA: nil,
39 traceB: test.MakeTraceWithSpanCount(10, 10, []byte{0x01, 0x03}),
40 expectedTotal: -1,
41 },
42 {
43 traceA: test.MakeTraceWithSpanCount(10, 10, []byte{0x01, 0x03}),
44 traceB: nil,
45 expectedTotal: -1,
46 },
47 {
48 traceA: test.MakeTraceWithSpanCount(10, 10, []byte{0x01, 0x03}),
49 traceB: test.MakeTraceWithSpanCount(10, 10, []byte{0x01, 0x01}),
50 expectedTotal: 200,
51 },
52 {
53 traceA: sameTrace,
54 traceB: sameTrace,
55 expectedTotal: 100,
56 },
57 }
58
59 for _, tt := range tests {
60 for _, m := range methods {
61 _, actualTotal := m(tt.traceA, tt.traceB)
62 assert.Equal(t, tt.expectedTotal, actualTotal)
63 }
64 }
65}
66
67func TestCombinerChecksMaxBytes(t *testing.T) {
68 // Ensure that the combiner checks max bytes when consuming a trace.

Callers

nothing calls this directly

Calls 6

ConsumeMethod · 0.95
ResultMethod · 0.95
MakeTraceWithSpanCountFunction · 0.92
mFunction · 0.85
NewCombinerFunction · 0.70
EqualMethod · 0.45

Tested by

no test coverage detected