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

Function TestRunValidation

cmd/tempo-vulture/validation_test.go:225–384  ·  view source on GitHub ↗

func TestValidateTraceSearch(t *testing.T) { tests := []struct { name string traces []traceInfo searchError error searchResponse []*tempopb.TraceSearchMetadata expectedFailures int }{ { name: "successful search", traces: []traceInfo{ {id: "trace-1

(t *testing.T)

Source from the content-addressed store, hash-verified

223// }
224
225func TestRunValidation(t *testing.T) {
226 tests := []struct {
227 name string
228 config ValidationConfig
229 writeError error
230 retrievalError error
231 retrievalTrace *tempopb.Trace
232 expectedFailures int
233 expectedExitCode int
234 expectedTotalTraces int
235 expectEarlyReturn bool // For write failures
236 }{
237 {
238 name: "complete success - no search",
239 config: ValidationConfig{
240 Cycles: 2,
241 TempoOrgID: "test-org",
242 WriteBackoffDuration: time.Millisecond, // Fast for testing
243 SearchBackoffDuration: 0, // Disable search
244 },
245 retrievalTrace: &tempopb.Trace{
246 ResourceSpans: []*v1.ResourceSpans{
247 {
248 ScopeSpans: []*v1.ScopeSpans{
249 {
250 Spans: []*v1.Span{
251 {Name: "test-span"},
252 },
253 },
254 },
255 },
256 },
257 },
258 expectedFailures: 0,
259 expectedExitCode: 0,
260 expectedTotalTraces: 2,
261 },
262 {
263 name: "write failure - early return",
264 config: ValidationConfig{
265 Cycles: 3,
266 TempoOrgID: "test-org",
267 WriteBackoffDuration: time.Millisecond,
268 SearchBackoffDuration: 0,
269 },
270 writeError: errors.New("write failed"),
271 expectedFailures: 1,
272 expectedExitCode: 1,
273 expectedTotalTraces: 3,
274 expectEarlyReturn: true,
275 },
276 {
277 name: "retrieval failure - continues processing",
278 config: ValidationConfig{
279 Cycles: 2,
280 TempoOrgID: "test-org",
281 WriteBackoffDuration: time.Millisecond,
282 SearchBackoffDuration: 0,

Callers

nothing calls this directly

Calls 9

NowMethod · 0.95
TraceIDMethod · 0.95
RunValidationMethod · 0.95
GetEmittedBatchesMethod · 0.95
GetRequestsCountMethod · 0.95
NewTraceInfoFunction · 0.92
ExitCodeMethod · 0.80
RunMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected