Skip to content

Commit

Permalink
fix bug in stackdriver test
Browse files Browse the repository at this point in the history
  • Loading branch information
stevencl1013 committed Jul 21, 2020
1 parent fd3178a commit 2423032
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions exporter/stackdriverexporter/stackdriver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package stackdriverexporter

import (
"context"
"fmt"
"net"
"testing"
"time"
Expand Down Expand Up @@ -65,7 +66,7 @@ func TestStackdriverExport(t *testing.T) {

cloudtracepb.RegisterTraceServiceServer(srv, &testServer{ch: reqCh})

lis, err := net.Listen("tcp", ":8080")
lis, err := net.Listen("tcp", ":8081")
defer func() {
_ = lis.Close()
}()
Expand All @@ -75,12 +76,13 @@ func TestStackdriverExport(t *testing.T) {

sde, err := newStackdriverTraceExporter(&Config{
ProjectID: "idk",
Endpoint: "127.0.0.1:8080",
Endpoint: "127.0.0.1:8081",
UseInsecure: true,
})
require.NoError(t, err)

testTime := time.Now()
spanName := "foobar"

resource := pdata.NewResource()
resource.InitEmpty()
Expand All @@ -93,8 +95,9 @@ func TestStackdriverExport(t *testing.T) {
ispans.Spans().Resize(1)
span := pdata.NewSpan()
span.InitEmpty()
span.SetName("foobar")
span.SetName(spanName)
span.SetStartTime(pdata.TimestampUnixNano(testTime.UnixNano()))
span.CopyTo(ispans.Spans().At(0))
err = sde.ConsumeTraces(ctx, traces)
assert.NoError(t, err)

Expand All @@ -103,7 +106,7 @@ func TestStackdriverExport(t *testing.T) {
t.Errorf("test timed out")
case r := <-reqCh:
assert.Len(t, r.Spans, 1)
assert.Equal(t, "foobar", r.Spans[0].GetName())
assert.Equal(t, fmt.Sprintf("Span.internal-%s", spanName), r.Spans[0].GetDisplayName().Value)
assert.Equal(t, mustTS(testTime), r.Spans[0].StartTime)
}
}

0 comments on commit 2423032

Please sign in to comment.