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

Function TestCombines

pkg/model/object_decoder_test.go:47–173  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

45}
46
47func TestCombines(t *testing.T) {
48 t1 := test.MakeTrace(10, []byte{0x01, 0x02})
49 t2 := test.MakeTrace(10, []byte{0x01, 0x03})
50
51 trace.SortTrace(t1)
52 trace.SortTrace(t2)
53
54 // split t2 into 3 traces
55 t2a := &tempopb.Trace{}
56 t2b := &tempopb.Trace{}
57 t2c := &tempopb.Trace{}
58 for _, b := range t2.ResourceSpans {
59 switch rand.Int() % 3 {
60 case 0:
61 t2a.ResourceSpans = append(t2a.ResourceSpans, b)
62 case 1:
63 t2b.ResourceSpans = append(t2b.ResourceSpans, b)
64 case 2:
65 t2c.ResourceSpans = append(t2c.ResourceSpans, b)
66 }
67 }
68
69 for _, e := range AllEncodings {
70 tests := []struct {
71 name string
72 traces [][]byte
73 expected *tempopb.Trace
74 expectedStart uint32
75 expectedEnd uint32
76 expectError bool
77 }{
78 {
79 name: "one trace",
80 traces: [][]byte{mustMarshalToObjectWithRange(t1, e, 10, 20)},
81 expected: t1,
82 expectedStart: 10,
83 expectedEnd: 20,
84 },
85 {
86 name: "same trace - replace end",
87 traces: [][]byte{mustMarshalToObjectWithRange(t1, e, 10, 20), mustMarshalToObjectWithRange(t1, e, 30, 40)},
88 expected: t1,
89 expectedStart: 10,
90 expectedEnd: 40,
91 },
92 {
93 name: "same trace - replace start",
94 traces: [][]byte{mustMarshalToObjectWithRange(t1, e, 10, 20), mustMarshalToObjectWithRange(t1, e, 5, 15)},
95 expected: t1,
96 expectedStart: 5,
97 expectedEnd: 20,
98 },
99 {
100 name: "same trace - replace both",
101 traces: [][]byte{mustMarshalToObjectWithRange(t1, e, 10, 20), mustMarshalToObjectWithRange(t1, e, 5, 30)},
102 expected: t1,
103 expectedStart: 5,
104 expectedEnd: 30,

Callers

nothing calls this directly

Calls 11

MakeTraceFunction · 0.92
SortTraceFunction · 0.92
MustNewObjectDecoderFunction · 0.85
IntMethod · 0.80
CombineMethod · 0.65
ErrorMethod · 0.65
PrepareForReadMethod · 0.65
FastRangeMethod · 0.65
RunMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected