Skip to content

Commit

Permalink
Fix Translator Tests
Browse files Browse the repository at this point in the history
Signed-off-by: Mahad Zaryab <[email protected]>
  • Loading branch information
mahadzaryab1 committed Feb 23, 2025
1 parent a674b10 commit a9e6376
Showing 1 changed file with 36 additions and 13 deletions.
49 changes: 36 additions & 13 deletions internal/storage/v2/v1adapter/translator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (

"github.com/jaegertracing/jaeger-idl/model/v1"
"github.com/jaegertracing/jaeger/internal/jptrace"
"github.com/jaegertracing/jaeger/internal/storage/v2/api/tracestore"
)

func TestProtoFromTraces_AddsWarnings(t *testing.T) {
Expand Down Expand Up @@ -285,32 +286,42 @@ func TestV1TraceToOtelTrace_ReturnEmptyOtelTrace(t *testing.T) {
}

func TestV1TraceIDsFromSeq2(t *testing.T) {
now := time.Now()

testCases := []struct {
name string
seqTraceIDs iter.Seq2[[]pcommon.TraceID, error]
seqTraceIDs iter.Seq2[[]tracestore.GetTraceParams, error]
expectedIDs []model.TraceID
expectedError error
}{
{
name: "empty sequence",
seqTraceIDs: func(func([]pcommon.TraceID, error) bool) {},
seqTraceIDs: func(func([]tracestore.GetTraceParams, error) bool) {},
expectedIDs: nil,
expectedError: nil,
},
{
name: "sequence with error",
seqTraceIDs: func(yield func([]pcommon.TraceID, error) bool) {
seqTraceIDs: func(yield func([]tracestore.GetTraceParams, error) bool) {
yield(nil, assert.AnError)
},
expectedIDs: nil,
expectedError: assert.AnError,
},
{
name: "sequence with one chunk of trace IDs",
seqTraceIDs: func(yield func([]pcommon.TraceID, error) bool) {
traceID1 := pcommon.TraceID([16]byte{0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3})
traceID2 := pcommon.TraceID([16]byte{0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 5})
yield([]pcommon.TraceID{traceID1, traceID2}, nil)
seqTraceIDs: func(yield func([]tracestore.GetTraceParams, error) bool) {
param1 := tracestore.GetTraceParams{
TraceID: pcommon.TraceID([16]byte{0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3}),
Start: now,
End: now.Add(time.Minute),
}
param2 := tracestore.GetTraceParams{
TraceID: pcommon.TraceID([16]byte{0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 5}),
Start: now,
End: now.Add(time.Minute),
}
yield([]tracestore.GetTraceParams{param1, param2}, nil)
},
expectedIDs: []model.TraceID{
model.NewTraceID(2, 3),
Expand All @@ -320,12 +331,24 @@ func TestV1TraceIDsFromSeq2(t *testing.T) {
},
{
name: "sequence with multiple chunks of trace IDs",
seqTraceIDs: func(yield func([]pcommon.TraceID, error) bool) {
traceID1 := pcommon.TraceID([16]byte{0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3})
traceID2 := pcommon.TraceID([16]byte{0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 5})
traceID3 := pcommon.TraceID([16]byte{0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 7})
yield([]pcommon.TraceID{traceID1}, nil)
yield([]pcommon.TraceID{traceID2, traceID3}, nil)
seqTraceIDs: func(yield func([]tracestore.GetTraceParams, error) bool) {
param1 := tracestore.GetTraceParams{
TraceID: pcommon.TraceID([16]byte{0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3}),
Start: now,
End: now.Add(time.Minute),
}
param2 := tracestore.GetTraceParams{
TraceID: pcommon.TraceID([16]byte{0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 5}),
Start: now,
End: now.Add(time.Minute),
}
param3 := tracestore.GetTraceParams{
TraceID: pcommon.TraceID([16]byte{0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 7}),
Start: now,
End: now.Add(time.Minute),
}
yield([]tracestore.GetTraceParams{param1}, nil)
yield([]tracestore.GetTraceParams{param2, param3}, nil)
},
expectedIDs: []model.TraceID{
model.NewTraceID(2, 3),
Expand Down

0 comments on commit a9e6376

Please sign in to comment.