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

Function TestValidateTraceRetrieval

cmd/tempo-vulture/validation_test.go:81–164  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

79}
80
81func TestValidateTraceRetrieval(t *testing.T) {
82 tests := []struct {
83 name string
84 queryError error
85 traceResponse *tempopb.Trace
86 expectError bool
87 }{
88 {
89 name: "successful retrieval",
90 // We'll create matching trace ID dynamically
91 traceResponse: &tempopb.Trace{
92 ResourceSpans: []*v1.ResourceSpans{
93 {
94 ScopeSpans: []*v1.ScopeSpans{
95 {
96 Spans: []*v1.Span{
97 {
98 // TraceId will be set dynamically to match
99 Name: "test-span",
100 },
101 },
102 },
103 },
104 },
105 },
106 },
107 expectError: false,
108 },
109 {
110 name: "query error",
111 queryError: errors.New("query failed"),
112 expectError: true,
113 },
114 {
115 name: "empty trace spans",
116 traceResponse: &tempopb.Trace{
117 ResourceSpans: []*v1.ResourceSpans{}, // Empty!
118 },
119 expectError: true,
120 },
121 }
122
123 for _, tt := range tests {
124 t.Run(tt.name, func(t *testing.T) {
125 // Create a TraceInfo
126 mockClock := &MockClock{
127 now: time.Date(2025, 1, 1, 12, 0, 0, 0, time.UTC),
128 }
129
130 vs := &ValidationService{
131 config: ValidationConfig{TempoOrgID: "test-org"},
132 clock: mockClock,
133 logger: zap.NewNop(),
134 }
135
136 traceInfo := util.NewTraceInfo(mockClock.Now(), "test-org")
137
138 // Set matching trace ID in the mock response

Callers

nothing calls this directly

Calls 8

NowMethod · 0.95
TraceIDMethod · 0.95
GetRequestsCountMethod · 0.95
NewTraceInfoFunction · 0.92
ErrorMethod · 0.65
RunMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected