Skip to content

Commit

Permalink
resolved changes
Browse files Browse the repository at this point in the history
Signed-off-by: chahatsagarmain <[email protected]>
  • Loading branch information
chahatsagarmain committed Jan 18, 2025
1 parent 24b9b7e commit bcc716a
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions cmd/collector/app/span_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"go.opentelemetry.io/collector/config/confignet"
"go.opentelemetry.io/collector/pdata/ptrace"
"go.uber.org/zap"
"go.uber.org/zap/zaptest"

cFlags "github.com/jaegertracing/jaeger/cmd/collector/app/flags"
"github.com/jaegertracing/jaeger/cmd/collector/app/handler"
Expand Down Expand Up @@ -846,25 +847,15 @@ func TestOTLPReceiverWithV2Storage(t *testing.T) {
sSpans := rSpans.ScopeSpans().AppendEmpty()
span := sSpans.Spans().AppendEmpty()
span.SetName("test-trace")
byteId := [8]byte{1, 2, 3, 4, 5, 6, 7}
span.SetSpanID(byteId)

mockWriter.On("WriteTraces", mock.Anything, mock.Anything).Run(func(args mock.Arguments) {
td := args.Get(1).(ptrace.Traces)

equal := td.ResourceSpans().Len() == traces.ResourceSpans().Len()

if equal {
rSpan := td.ResourceSpans().At(0)
equal = rSpan.ScopeSpans().Len() == 1 &&
rSpan.ScopeSpans().At(0).Spans().Len() == 1 &&
rSpan.ScopeSpans().At(0).Spans().At(0).Name() == "test-trace" &&
rSpan.ScopeSpans().At(0).Spans().At(0).SpanID() == byteId
}
if !equal {
t.Error("Traces don't match expected structure")
}
}).Return(nil)
var receivedTraces ptrace.Traces
var mu sync.Mutex
mockWriter.On("WriteTraces", mock.Anything, mock.Anything).
Run(func(args mock.Arguments) {
mu.Lock()
receivedTraces = args.Get(1).(ptrace.Traces)
mu.Unlock()
}).Return(nil)

spanProcessor, err := NewSpanProcessor(
mockWriter,
Expand All @@ -875,7 +866,7 @@ func TestOTLPReceiverWithV2Storage(t *testing.T) {
)
require.NoError(t, err)
defer spanProcessor.Close()
logger, _ := testutils.NewLogger()
logger := zaptest.NewLogger(t)

portHttp := "4318"
portGrpc := "4317"
Expand Down Expand Up @@ -915,5 +906,14 @@ func TestOTLPReceiverWithV2Storage(t *testing.T) {

require.Equal(t, http.StatusOK, resp.StatusCode)

time.Sleep(100 * time.Millisecond)

mu.Lock()
receivedSpan := receivedTraces.ResourceSpans().At(0).
ScopeSpans().At(0).
Spans().At(0)
require.Equal(t, span.Name(), receivedSpan.Name())
mu.Unlock()

mockWriter.AssertExpectations(t)
}

0 comments on commit bcc716a

Please sign in to comment.