Skip to content

Commit 4ce3c20

Browse files
committed
add test and fix test
1 parent 77d081f commit 4ce3c20

File tree

5 files changed

+25
-5
lines changed

5 files changed

+25
-5
lines changed

‎tempodb/encoding/vparquet3/block_traceql_meta_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
)
1515

1616
func TestBackendBlockSearchFetchMetaData(t *testing.T) {
17-
wantTr := fullyPopulatedTestTrace(nil)
17+
wantTr := fullyPopulatedTestTraceWithOption(nil, true)
1818
b := makeBackendBlockWithTraces(t, []*Trace{wantTr})
1919
ctx := context.Background()
2020

‎tempodb/encoding/vparquet3/block_traceql_test.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,11 +391,19 @@ func parse(t *testing.T, q string) traceql.Condition {
391391
}
392392

393393
func fullyPopulatedTestTrace(id common.ID) *Trace {
394+
return fullyPopulatedTestTraceWithOption(id, false)
395+
}
396+
397+
func fullyPopulatedTestTraceWithOption(id common.ID, parentIDTest bool) *Trace {
394398
// Helper functions to make pointers
395399
strPtr := func(s string) *string { return &s }
396400
intPtr := func(i int64) *int64 { return &i }
397401
fltPtr := func(f float64) *float64 { return &f }
398402
boolPtr := func(b bool) *bool { return &b }
403+
parentID := []byte{}
404+
if parentIDTest {
405+
parentID = []byte("parentid")
406+
}
399407

400408
links := tempopb.LinkSlice{
401409
Links: []*v1.Span_Link{
@@ -463,7 +471,7 @@ func fullyPopulatedTestTrace(id common.ID) *Trace {
463471
HttpMethod: strPtr("get"),
464472
HttpUrl: strPtr("url/hello/world"),
465473
HttpStatusCode: intPtr(500),
466-
ParentSpanID: []byte("parentid"),
474+
ParentSpanID: parentID,
467475
StatusCode: int(v1.Status_STATUS_CODE_ERROR),
468476
StatusMessage: v1.Status_STATUS_CODE_ERROR.String(),
469477
TraceState: "tracestate",

‎tempodb/encoding/vparquet4/block_traceql_meta_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
)
1515

1616
func TestBackendBlockSearchFetchMetaData(t *testing.T) {
17-
wantTr := fullyPopulatedTestTrace(nil)
17+
wantTr := fullyPopulatedTestTraceWithOption(nil, true)
1818
b := makeBackendBlockWithTraces(t, []*Trace{wantTr})
1919
ctx := context.Background()
2020

‎tempodb/encoding/vparquet4/block_traceql_test.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,8 +474,16 @@ func parse(t *testing.T, q string) traceql.Condition {
474474
}
475475

476476
func fullyPopulatedTestTrace(id common.ID) *Trace {
477+
return fullyPopulatedTestTraceWithOption(id, false)
478+
}
479+
480+
func fullyPopulatedTestTraceWithOption(id common.ID, parentIDTest bool) *Trace {
477481
linkTraceID, _ := util.HexStringToTraceID("1234567890abcdef1234567890abcdef")
478482
linkSpanID, _ := util.HexStringToSpanID("1234567890abcdef")
483+
parentID := []byte{}
484+
if parentIDTest {
485+
parentID = []byte("parentid")
486+
}
479487

480488
links := []Link{
481489
{
@@ -562,7 +570,7 @@ func fullyPopulatedTestTrace(id common.ID) *Trace {
562570
HttpMethod: ptr("get"),
563571
HttpUrl: ptr("url/hello/world"),
564572
HttpStatusCode: ptr(int64(500)),
565-
ParentSpanID: []byte("parentid"),
573+
ParentSpanID: parentID,
566574
StatusCode: int(v1.Status_STATUS_CODE_ERROR),
567575
StatusMessage: v1.Status_STATUS_CODE_ERROR.String(),
568576
TraceState: "tracestate",
@@ -655,7 +663,6 @@ func fullyPopulatedTestTrace(id common.ID) *Trace {
655663
Spans: []Span{
656664
{
657665
SpanID: []byte("spanid2"),
658-
ParentSpanID: []byte("parentid2"),
659666
Name: "world",
660667
StartTimeUnixNano: uint64(200 * time.Second),
661668
DurationNano: uint64(200 * time.Second),

‎tempodb/tempodb_search_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,13 @@ func traceQLRunner(t *testing.T, _ *tempopb.Trace, wantMeta *tempopb.TraceSearch
9595
{Query: `{ ."res-dedicated.02" = "res-2a" }`},
9696
{Query: `{ resource."k8s.namespace.name" = "k8sNamespace" }`},
9797
}
98+
parentID := util.SpanIDToHexString([]byte{4, 5, 6})
99+
parentIDQuery := &tempopb.SearchRequest{
100+
Query: fmt.Sprintf("{ span:parentID = %q }", parentID),
101+
}
98102

99103
searchesThatMatch = append(searchesThatMatch, quotedAttributesThatMatch...)
104+
searchesThatMatch = append(searchesThatMatch, parentIDQuery)
100105
for _, req := range searchesThatMatch {
101106
fetcher := traceql.NewSpansetFetcherWrapper(func(ctx context.Context, req traceql.FetchSpansRequest) (traceql.FetchSpansResponse, error) {
102107
return r.Fetch(ctx, meta, req, common.DefaultSearchOptions())

0 commit comments

Comments
 (0)