Skip to content

Commit

Permalink
Move errorkind package and use require package in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Paulo Janotti committed Jul 2, 2019
1 parent 7fe7624 commit 33ad4ac
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 22 deletions.
2 changes: 1 addition & 1 deletion cmd/occollector/app/sender/jaeger_proto_grpc_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

"github.com/open-telemetry/opentelemetry-service/consumer"
"github.com/open-telemetry/opentelemetry-service/data"
"github.com/open-telemetry/opentelemetry-service/errorkind"
"github.com/open-telemetry/opentelemetry-service/errors/errorkind"
jaegertranslator "github.com/open-telemetry/opentelemetry-service/translator/trace/jaeger"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/occollector/app/sender/jaeger_thrift_http_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (

"github.com/open-telemetry/opentelemetry-service/consumer"
"github.com/open-telemetry/opentelemetry-service/data"
"github.com/open-telemetry/opentelemetry-service/errorkind"
"github.com/open-telemetry/opentelemetry-service/errors/errorkind"
jaegertranslator "github.com/open-telemetry/opentelemetry-service/translator/trace/jaeger"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

"github.com/open-telemetry/opentelemetry-service/consumer"
"github.com/open-telemetry/opentelemetry-service/data"
"github.com/open-telemetry/opentelemetry-service/errorkind"
"github.com/open-telemetry/opentelemetry-service/errors/errorkind"
jaegertranslator "github.com/open-telemetry/opentelemetry-service/translator/trace/jaeger"
)

Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion exporter/zipkinexporter/zipkin.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
commonpb "github.com/census-instrumentation/opencensus-proto/gen-go/agent/common/v1"
"github.com/open-telemetry/opentelemetry-service/consumer"
"github.com/open-telemetry/opentelemetry-service/data"
"github.com/open-telemetry/opentelemetry-service/errorkind"
"github.com/open-telemetry/opentelemetry-service/errors/errorkind"
"github.com/open-telemetry/opentelemetry-service/observability"
"github.com/open-telemetry/opentelemetry-service/translator/trace"
spandatatranslator "github.com/open-telemetry/opentelemetry-service/translator/trace/spandata"
Expand Down
2 changes: 1 addition & 1 deletion internal/collector/processor/queued/queued_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (

"github.com/open-telemetry/opentelemetry-service/consumer"
"github.com/open-telemetry/opentelemetry-service/data"
"github.com/open-telemetry/opentelemetry-service/errorkind"
"github.com/open-telemetry/opentelemetry-service/errors/errorkind"
"github.com/open-telemetry/opentelemetry-service/internal/collector/processor"
"github.com/open-telemetry/opentelemetry-service/internal/collector/processor/nodebatcher"
"github.com/open-telemetry/opentelemetry-service/internal/collector/telemetry"
Expand Down
24 changes: 7 additions & 17 deletions internal/collector/processor/queued/queued_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ import (
"time"

tracepb "github.com/census-instrumentation/opencensus-proto/gen-go/trace/v1"
"github.com/stretchr/testify/require"

"github.com/open-telemetry/opentelemetry-service/consumer"
"github.com/open-telemetry/opentelemetry-service/data"
"github.com/open-telemetry/opentelemetry-service/errorkind"
"github.com/open-telemetry/opentelemetry-service/errors/errorkind"
)

func TestQueuedProcessor_noEnqueueOnPermanentError(t *testing.T) {
Expand All @@ -48,31 +49,20 @@ func TestQueuedProcessor_noEnqueueOnPermanentError(t *testing.T) {
).(*queuedSpanProcessor)

c.Add(1)
if err := qp.ConsumeTraceData(ctx, td); err != nil {
// This is asynchronous so it should just enqueue, no errors expected.
t.Fatalf("c.ConsumeTraceData() = %v want nil", err)
}
require.Nil(t, qp.ConsumeTraceData(ctx, td))
c.Wait()
<-time.After(50 * time.Millisecond)

queueSize := qp.queue.Size()
if queueSize != 0 {
t.Fatalf("queueSize = %d, want 0", queueSize)
}
require.Zero(t, qp.queue.Size())

c.consumeTraceDataError = errors.New("transient error")
c.Add(1)
if err := qp.ConsumeTraceData(ctx, td); err != nil {
// This is asynchronous so it should just enqueue, no errors expected.
t.Fatalf("c.ConsumeTraceData() got non-permanent error")
}
// This is asynchronous so it should just enqueue, no errors expected.
require.Nil(t, qp.ConsumeTraceData(ctx, td))
c.Wait()
<-time.After(50 * time.Millisecond)

queueSize = qp.queue.Size()
if queueSize != 1 {
t.Fatalf("queueSize = %d, want 1", queueSize)
}
require.Equal(t, 1, qp.queue.Size())
}

type waitGroupTraceConsumer struct {
Expand Down

0 comments on commit 33ad4ac

Please sign in to comment.