Skip to content

Commit

Permalink
[pkg/translator/jaeger] Make the assertion more robust on flaky test (o…
Browse files Browse the repository at this point in the history
  • Loading branch information
dgoscn committed Sep 29, 2022
1 parent 0ab9000 commit accb099
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions pkg/translator/jaeger/jaegerproto_to_traces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,6 @@ func TestSetInternalSpanStatus(t *testing.T) {
}

func TestProtoBatchesToInternalTraces(t *testing.T) {
t.Skip("skipping flaky test, see https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/12591")
batches := []*model.Batch{
{
Process: generateProtoProcess(),
Expand Down Expand Up @@ -459,8 +458,29 @@ func TestProtoBatchesToInternalTraces(t *testing.T) {
twoSpans.CopyTo(tgt)

got, err := ProtoToTraces(batches)

assert.NoError(t, err)
assert.EqualValues(t, expected, got)

assert.Equal(t, expected.ResourceSpans().Len(), got.ResourceSpans().Len())
assert.Equal(t, expected.SpanCount(), got.SpanCount())

lenbatches := expected.ResourceSpans().Len()
found := 0

for i := 0; i < lenbatches; i++ {
rsExpected := expected.ResourceSpans().At(i)
for j := 0; j < lenbatches; j++ {
got.ResourceSpans().RemoveIf(func(rs ptrace.ResourceSpans) bool {
nameExpected := rsExpected.ScopeSpans().At(0).Spans().At(0).Name()
nameGot := got.ResourceSpans().At(j).ScopeSpans().At(0).Scope().Name()
if nameExpected == nameGot {
assert.Equal(t, nameGot, found)
assert.Equal(t, got.SpanCount(), found)
}
return nameExpected == nameGot
})
}
}
}

func TestJSpanKindToInternal(t *testing.T) {
Expand Down

0 comments on commit accb099

Please sign in to comment.