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

Function TestBackendBlockSelectAll

tempodb/encoding/vparquet5/block_traceql_test.go:1418–1489  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1416}
1417
1418func TestBackendBlockSelectAll(t *testing.T) {
1419 var (
1420 ctx = context.Background()
1421 numTraces = 250
1422 traces = make([]*Trace, 0, numTraces)
1423 wantTraceIdx = rand.Intn(numTraces)
1424 wantTraceID = test.ValidTraceID(nil)
1425 wantTrace = fullyPopulatedTestTrace(wantTraceID)
1426 dc = test.MakeDedicatedColumns()
1427 dcm = dedicatedColumnsToColumnMapping(dc)
1428 )
1429
1430 // TODO - This strips unsupported attributes types for now. Revisit when
1431 // add support for arrays/kvlists in the fetch layer.
1432 trimForSelectAll(wantTrace)
1433
1434 for i := 0; i < numTraces; i++ {
1435 if i == wantTraceIdx {
1436 traces = append(traces, wantTrace)
1437 continue
1438 }
1439
1440 id := test.ValidTraceID(nil)
1441 tr, _ := traceToParquet(&backend.BlockMeta{}, id, test.MakeTrace(1, id), nil)
1442 traces = append(traces, tr)
1443 }
1444
1445 b := makeBackendBlockWithTraces(t, traces)
1446
1447 _, eval, _, _, req, err := traceql.Compile("{}")
1448 require.NoError(t, err)
1449 req.SecondPass = func(inSS *traceql.Spanset) ([]*traceql.Spanset, error) { return eval([]*traceql.Spanset{inSS}) }
1450 req.SecondPassSelectAll = true
1451
1452 resp, err := b.Fetch(ctx, *req, common.DefaultSearchOptions())
1453 require.NoError(t, err)
1454 defer resp.Results.Close()
1455
1456 // This is a dump of all spans in the fully-populated test trace
1457 wantSS := flattenForSelectAll(wantTrace, dcm)
1458
1459 for {
1460 // Seek to our desired trace
1461 ss, err := resp.Results.Next(ctx)
1462 require.NoError(t, err)
1463 if ss == nil {
1464 break
1465 }
1466 if !bytes.Equal(ss.TraceID, wantTraceID) {
1467 continue
1468 }
1469
1470 // Cleanup found data for comparison
1471 // equal will fail on the rownum mismatches. this is an internal detail to the
1472 // fetch layer. just wipe them out here
1473 ss.ReleaseFn = nil
1474 ss.ServiceStats = nil
1475 for _, sp := range ss.Spans {

Callers

nothing calls this directly

Calls 15

ValidTraceIDFunction · 0.92
MakeDedicatedColumnsFunction · 0.92
MakeTraceFunction · 0.92
CompileFunction · 0.92
DefaultSearchOptionsFunction · 0.92
fullyPopulatedTestTraceFunction · 0.70
trimForSelectAllFunction · 0.70
traceToParquetFunction · 0.70
flattenForSelectAllFunction · 0.70
sortAttrsFunction · 0.70

Tested by

no test coverage detected