diff --git a/CHANGELOG.md b/CHANGELOG.md index 46aa3b6cc5e..17e71f08402 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Changed +- Rename `sdk/metric/processor/test` to `sdk/metric/processor/processortest` +- Rename `sdk/metric/controller/test` to `sdk/metric/controller/controllertest` +- Rename `api/testharness` to `api/apitest` +- Rename `api/trace/testtrace` to `api/trace/tracetest` - The `go.opentelemetry.io/otel/bridge/opentracing` bridge package has been made into its own module. This removes the package dependencies of this bridge from the rest of the OpenTelemetry based project. (#1038) - Renamed `go.opentelemetry.io/otel/api/standard` package to `go.opentelemetry.io/otel/semconv` to avoid the ambiguous and generic name `standard` and better describe the package as containing OpenTelemetry semantic conventions. (#1016) diff --git a/api/testharness/harness.go b/api/apitest/harness.go similarity index 99% rename from api/testharness/harness.go rename to api/apitest/harness.go index 046325b272f..6237264ee7b 100644 --- a/api/testharness/harness.go +++ b/api/apitest/harness.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package testharness +package apitest import ( "context" diff --git a/api/testharness/package.go b/api/apitest/package.go similarity index 89% rename from api/testharness/package.go rename to api/apitest/package.go index da4a89cefde..5e8ff5422de 100644 --- a/api/testharness/package.go +++ b/api/apitest/package.go @@ -12,4 +12,4 @@ // See the License for the specific language governing permissions and // limitations under the License. -package testharness // import "go.opentelemetry.io/otel/api/testharness" +package apitest // import "go.opentelemetry.io/otel/api/apitest" diff --git a/api/global/internal/trace_test.go b/api/global/internal/trace_test.go index d391c3073ec..53781843151 100644 --- a/api/global/internal/trace_test.go +++ b/api/global/internal/trace_test.go @@ -22,7 +22,7 @@ import ( "go.opentelemetry.io/otel/api/global" "go.opentelemetry.io/otel/api/global/internal" - "go.opentelemetry.io/otel/api/trace/testtrace" + "go.opentelemetry.io/otel/api/trace/tracetest" ) func TestTraceWithSDK(t *testing.T) { @@ -34,8 +34,8 @@ func TestTraceWithSDK(t *testing.T) { // This is started before an SDK was registered and should be dropped. _, span1 := tracer1.Start(ctx, "span1") - sr := new(testtrace.StandardSpanRecorder) - tp := testtrace.NewProvider(testtrace.WithSpanRecorder(sr)) + sr := new(tracetest.StandardSpanRecorder) + tp := tracetest.NewProvider(tracetest.WithSpanRecorder(sr)) global.SetTraceProvider(tp) // This span was started before initialization, it is expected to be dropped. @@ -50,7 +50,7 @@ func TestTraceWithSDK(t *testing.T) { _, span3 := tracer2.Start(ctx, "span3") span3.End() - filterNames := func(spans []*testtrace.Span) []string { + filterNames := func(spans []*tracetest.Span) []string { names := make([]string, len(spans)) for i := range spans { names[i] = spans[i].Name() diff --git a/api/trace/testtrace/b3_propagator_benchmark_test.go b/api/trace/tracetest/b3_propagator_benchmark_test.go similarity index 99% rename from api/trace/testtrace/b3_propagator_benchmark_test.go rename to api/trace/tracetest/b3_propagator_benchmark_test.go index 42870dc8d90..8d41ca38a45 100644 --- a/api/trace/testtrace/b3_propagator_benchmark_test.go +++ b/api/trace/tracetest/b3_propagator_benchmark_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package testtrace_test +package tracetest_test import ( "context" diff --git a/api/trace/testtrace/b3_propagator_data_test.go b/api/trace/tracetest/b3_propagator_data_test.go similarity index 99% rename from api/trace/testtrace/b3_propagator_data_test.go rename to api/trace/tracetest/b3_propagator_data_test.go index 262bbe8be6e..ba170e3f45e 100644 --- a/api/trace/testtrace/b3_propagator_data_test.go +++ b/api/trace/tracetest/b3_propagator_data_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package testtrace_test +package tracetest_test import ( "fmt" diff --git a/api/trace/testtrace/b3_propagator_test.go b/api/trace/tracetest/b3_propagator_test.go similarity index 99% rename from api/trace/testtrace/b3_propagator_test.go rename to api/trace/tracetest/b3_propagator_test.go index 5384a145557..56e2a8177a7 100644 --- a/api/trace/testtrace/b3_propagator_test.go +++ b/api/trace/tracetest/b3_propagator_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package testtrace_test +package tracetest_test import ( "context" diff --git a/api/trace/testtrace/config.go b/api/trace/tracetest/config.go similarity index 99% rename from api/trace/testtrace/config.go rename to api/trace/tracetest/config.go index b4557676c18..8cd93d77935 100644 --- a/api/trace/testtrace/config.go +++ b/api/trace/tracetest/config.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package testtrace +package tracetest import ( "context" diff --git a/api/trace/testtrace/event.go b/api/trace/tracetest/event.go similarity index 97% rename from api/trace/testtrace/event.go rename to api/trace/tracetest/event.go index 84598df4252..4e58d33cb4a 100644 --- a/api/trace/testtrace/event.go +++ b/api/trace/tracetest/event.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package testtrace +package tracetest import ( "time" diff --git a/api/trace/testtrace/package.go b/api/trace/tracetest/package.go similarity index 88% rename from api/trace/testtrace/package.go rename to api/trace/tracetest/package.go index 5401ed7efd8..7bc9078a0bf 100644 --- a/api/trace/testtrace/package.go +++ b/api/trace/tracetest/package.go @@ -12,4 +12,4 @@ // See the License for the specific language governing permissions and // limitations under the License. -package testtrace // import "go.opentelemetry.io/otel/api/trace/testtrace" +package tracetest // import "go.opentelemetry.io/otel/api/trace/tracetest" diff --git a/api/trace/testtrace/propagator_test.go b/api/trace/tracetest/propagator_test.go similarity index 99% rename from api/trace/testtrace/propagator_test.go rename to api/trace/tracetest/propagator_test.go index 4cbab89fc9f..4d35e70a64e 100644 --- a/api/trace/testtrace/propagator_test.go +++ b/api/trace/tracetest/propagator_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package testtrace_test +package tracetest_test import ( "context" diff --git a/api/trace/testtrace/provider.go b/api/trace/tracetest/provider.go similarity index 98% rename from api/trace/testtrace/provider.go rename to api/trace/tracetest/provider.go index 9bd58daf226..8388fc87e75 100644 --- a/api/trace/testtrace/provider.go +++ b/api/trace/tracetest/provider.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package testtrace +package tracetest import ( "sync" diff --git a/api/trace/testtrace/span.go b/api/trace/tracetest/span.go similarity index 99% rename from api/trace/testtrace/span.go rename to api/trace/tracetest/span.go index 4df34756a53..c161f5951e4 100644 --- a/api/trace/testtrace/span.go +++ b/api/trace/tracetest/span.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package testtrace +package tracetest import ( "context" diff --git a/api/trace/testtrace/span_test.go b/api/trace/tracetest/span_test.go similarity index 91% rename from api/trace/testtrace/span_test.go rename to api/trace/tracetest/span_test.go index 6697f04e282..433e5a71219 100644 --- a/api/trace/testtrace/span_test.go +++ b/api/trace/tracetest/span_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package testtrace_test +package tracetest_test import ( "context" @@ -24,7 +24,7 @@ import ( "go.opentelemetry.io/otel/api/kv" "go.opentelemetry.io/otel/api/trace" - "go.opentelemetry.io/otel/api/trace/testtrace" + "go.opentelemetry.io/otel/api/trace/tracetest" "go.opentelemetry.io/otel/codes" "go.opentelemetry.io/otel/internal/matchers" ottest "go.opentelemetry.io/otel/internal/testing" @@ -32,7 +32,7 @@ import ( func TestSpan(t *testing.T) { t.Run("#Tracer", func(t *testing.T) { - tp := testtrace.NewProvider() + tp := tracetest.NewProvider() t.Run("returns the tracer used to start the span", func(t *testing.T) { t.Parallel() @@ -46,7 +46,7 @@ func TestSpan(t *testing.T) { }) t.Run("#End", func(t *testing.T) { - tp := testtrace.NewProvider() + tp := tracetest.NewProvider() t.Run("ends the span", func(t *testing.T) { t.Parallel() @@ -55,7 +55,7 @@ func TestSpan(t *testing.T) { tracer := tp.Tracer(t.Name()) _, span := tracer.Start(context.Background(), "test") - subject, ok := span.(*testtrace.Span) + subject, ok := span.(*tracetest.Span) e.Expect(ok).ToBeTrue() e.Expect(subject.Ended()).ToBeFalse() @@ -86,7 +86,7 @@ func TestSpan(t *testing.T) { tracer := tp.Tracer(t.Name()) _, span := tracer.Start(context.Background(), "test") - subject, ok := span.(*testtrace.Span) + subject, ok := span.(*tracetest.Span) e.Expect(ok).ToBeTrue() subject.End() @@ -109,7 +109,7 @@ func TestSpan(t *testing.T) { tracer := tp.Tracer(t.Name()) _, span := tracer.Start(context.Background(), "test") - subject, ok := span.(*testtrace.Span) + subject, ok := span.(*tracetest.Span) e.Expect(ok).ToBeTrue() expectedEndTime := time.Now().AddDate(5, 0, 0) @@ -125,7 +125,7 @@ func TestSpan(t *testing.T) { }) t.Run("#RecordError", func(t *testing.T) { - tp := testtrace.NewProvider() + tp := tracetest.NewProvider() t.Run("records an error", func(t *testing.T) { t.Parallel() @@ -152,13 +152,13 @@ func TestSpan(t *testing.T) { tracer := tp.Tracer(t.Name()) ctx, span := tracer.Start(context.Background(), "test") - subject, ok := span.(*testtrace.Span) + subject, ok := span.(*tracetest.Span) e.Expect(ok).ToBeTrue() testTime := time.Now() subject.RecordError(ctx, s.err, trace.WithErrorTime(testTime)) - expectedEvents := []testtrace.Event{{ + expectedEvents := []tracetest.Event{{ Timestamp: testTime, Name: "error", Attributes: map[kv.Key]kv.Value{ @@ -180,7 +180,7 @@ func TestSpan(t *testing.T) { tracer := tp.Tracer(t.Name()) ctx, span := tracer.Start(context.Background(), "test") - subject, ok := span.(*testtrace.Span) + subject, ok := span.(*tracetest.Span) e.Expect(ok).ToBeTrue() errMsg := "test error message" @@ -189,7 +189,7 @@ func TestSpan(t *testing.T) { expStatusCode := codes.Unknown subject.RecordError(ctx, testErr, trace.WithErrorTime(testTime), trace.WithErrorStatus(expStatusCode)) - expectedEvents := []testtrace.Event{{ + expectedEvents := []tracetest.Event{{ Timestamp: testTime, Name: "error", Attributes: map[kv.Key]kv.Value{ @@ -209,7 +209,7 @@ func TestSpan(t *testing.T) { tracer := tp.Tracer(t.Name()) ctx, span := tracer.Start(context.Background(), "test") - subject, ok := span.(*testtrace.Span) + subject, ok := span.(*tracetest.Span) e.Expect(ok).ToBeTrue() subject.End() @@ -226,7 +226,7 @@ func TestSpan(t *testing.T) { tracer := tp.Tracer(t.Name()) ctx, span := tracer.Start(context.Background(), "test") - subject, ok := span.(*testtrace.Span) + subject, ok := span.(*tracetest.Span) e.Expect(ok).ToBeTrue() subject.RecordError(ctx, nil) @@ -236,7 +236,7 @@ func TestSpan(t *testing.T) { }) t.Run("#IsRecording", func(t *testing.T) { - tp := testtrace.NewProvider() + tp := tracetest.NewProvider() t.Run("returns true", func(t *testing.T) { t.Parallel() @@ -250,7 +250,7 @@ func TestSpan(t *testing.T) { }) t.Run("#SpanContext", func(t *testing.T) { - tp := testtrace.NewProvider() + tp := tracetest.NewProvider() t.Run("returns a valid SpanContext", func(t *testing.T) { t.Parallel() @@ -275,7 +275,7 @@ func TestSpan(t *testing.T) { }) t.Run("#Name", func(t *testing.T) { - tp := testtrace.NewProvider() + tp := tracetest.NewProvider() t.Run("returns the most recently set name on the span", func(t *testing.T) { t.Parallel() @@ -285,7 +285,7 @@ func TestSpan(t *testing.T) { originalName := "test" _, span := tracer.Start(context.Background(), originalName) - subject, ok := span.(*testtrace.Span) + subject, ok := span.(*tracetest.Span) e.Expect(ok).ToBeTrue() e.Expect(subject.Name()).ToEqual(originalName) @@ -308,7 +308,7 @@ func TestSpan(t *testing.T) { originalName := "test" _, span := tracer.Start(context.Background(), originalName) - subject, ok := span.(*testtrace.Span) + subject, ok := span.(*tracetest.Span) e.Expect(ok).ToBeTrue() subject.End() @@ -319,7 +319,7 @@ func TestSpan(t *testing.T) { }) t.Run("#Attributes", func(t *testing.T) { - tp := testtrace.NewProvider() + tp := tracetest.NewProvider() t.Run("returns an empty map by default", func(t *testing.T) { t.Parallel() @@ -328,7 +328,7 @@ func TestSpan(t *testing.T) { tracer := tp.Tracer(t.Name()) _, span := tracer.Start(context.Background(), "test") - subject, ok := span.(*testtrace.Span) + subject, ok := span.(*tracetest.Span) e.Expect(ok).ToBeTrue() e.Expect(subject.Attributes()).ToEqual(map[kv.Key]kv.Value{}) @@ -342,7 +342,7 @@ func TestSpan(t *testing.T) { tracer := tp.Tracer(t.Name()) _, span := tracer.Start(context.Background(), "test") - subject, ok := span.(*testtrace.Span) + subject, ok := span.(*tracetest.Span) e.Expect(ok).ToBeTrue() attr1 := kv.String("key1", "value1") @@ -368,7 +368,7 @@ func TestSpan(t *testing.T) { tracer := tp.Tracer(t.Name()) _, span := tracer.Start(context.Background(), "test") - subject, ok := span.(*testtrace.Span) + subject, ok := span.(*tracetest.Span) e.Expect(ok).ToBeTrue() expectedAttr := kv.String("key", "value") @@ -391,7 +391,7 @@ func TestSpan(t *testing.T) { tracer := tp.Tracer(t.Name()) _, span := tracer.Start(context.Background(), "test") - subject, ok := span.(*testtrace.Span) + subject, ok := span.(*tracetest.Span) e.Expect(ok).ToBeTrue() var wg sync.WaitGroup @@ -415,7 +415,7 @@ func TestSpan(t *testing.T) { }) t.Run("#Links", func(t *testing.T) { - tp := testtrace.NewProvider() + tp := tracetest.NewProvider() t.Run("returns an empty map by default", func(t *testing.T) { t.Parallel() @@ -424,7 +424,7 @@ func TestSpan(t *testing.T) { tracer := tp.Tracer(t.Name()) _, span := tracer.Start(context.Background(), "test") - subject, ok := span.(*testtrace.Span) + subject, ok := span.(*tracetest.Span) e.Expect(ok).ToBeTrue() e.Expect(len(subject.Links())).ToEqual(0) @@ -432,7 +432,7 @@ func TestSpan(t *testing.T) { }) t.Run("#Events", func(t *testing.T) { - tp := testtrace.NewProvider() + tp := tracetest.NewProvider() t.Run("returns an empty slice by default", func(t *testing.T) { t.Parallel() @@ -441,7 +441,7 @@ func TestSpan(t *testing.T) { tracer := tp.Tracer(t.Name()) _, span := tracer.Start(context.Background(), "test") - subject, ok := span.(*testtrace.Span) + subject, ok := span.(*tracetest.Span) e.Expect(ok).ToBeTrue() e.Expect(len(subject.Events())).ToEqual(0) @@ -455,7 +455,7 @@ func TestSpan(t *testing.T) { tracer := tp.Tracer(t.Name()) _, span := tracer.Start(context.Background(), "test") - subject, ok := span.(*testtrace.Span) + subject, ok := span.(*tracetest.Span) e.Expect(ok).ToBeTrue() event1Name := "event1" @@ -508,7 +508,7 @@ func TestSpan(t *testing.T) { tracer := tp.Tracer(t.Name()) _, span := tracer.Start(context.Background(), "test") - subject, ok := span.(*testtrace.Span) + subject, ok := span.(*tracetest.Span) e.Expect(ok).ToBeTrue() subject.AddEvent(context.Background(), "test") @@ -526,7 +526,7 @@ func TestSpan(t *testing.T) { }) t.Run("#Status", func(t *testing.T) { - tp := testtrace.NewProvider() + tp := tracetest.NewProvider() t.Run("defaults to OK", func(t *testing.T) { t.Parallel() @@ -535,7 +535,7 @@ func TestSpan(t *testing.T) { tracer := tp.Tracer(t.Name()) _, span := tracer.Start(context.Background(), "test") - subject, ok := span.(*testtrace.Span) + subject, ok := span.(*tracetest.Span) e.Expect(ok).ToBeTrue() e.Expect(subject.StatusCode()).ToEqual(codes.OK) @@ -574,7 +574,7 @@ func TestSpan(t *testing.T) { tracer := tp.Tracer(t.Name()) _, span := tracer.Start(context.Background(), "test") - subject, ok := span.(*testtrace.Span) + subject, ok := span.(*tracetest.Span) e.Expect(ok).ToBeTrue() subject.SetStatus(codes.OK, "OK") @@ -592,7 +592,7 @@ func TestSpan(t *testing.T) { tracer := tp.Tracer(t.Name()) _, span := tracer.Start(context.Background(), "test") - subject, ok := span.(*testtrace.Span) + subject, ok := span.(*tracetest.Span) e.Expect(ok).ToBeTrue() originalStatus := codes.OK @@ -608,7 +608,7 @@ func TestSpan(t *testing.T) { }) t.Run("#SpanKind", func(t *testing.T) { - tp := testtrace.NewProvider() + tp := tracetest.NewProvider() t.Run("returns the value given at start", func(t *testing.T) { t.Parallel() @@ -618,7 +618,7 @@ func TestSpan(t *testing.T) { _, span := tracer.Start(context.Background(), "test", trace.WithSpanKind(trace.SpanKindConsumer)) - subject, ok := span.(*testtrace.Span) + subject, ok := span.(*tracetest.Span) e.Expect(ok).ToBeTrue() subject.End() diff --git a/api/trace/testtrace/trace_context_propagator_benchmark_test.go b/api/trace/tracetest/trace_context_propagator_benchmark_test.go similarity index 99% rename from api/trace/testtrace/trace_context_propagator_benchmark_test.go rename to api/trace/tracetest/trace_context_propagator_benchmark_test.go index f6ebc4d8567..33d583a699d 100644 --- a/api/trace/testtrace/trace_context_propagator_benchmark_test.go +++ b/api/trace/tracetest/trace_context_propagator_benchmark_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package testtrace_test +package tracetest_test import ( "context" diff --git a/api/trace/testtrace/trace_context_propagator_test.go b/api/trace/tracetest/trace_context_propagator_test.go similarity index 99% rename from api/trace/testtrace/trace_context_propagator_test.go rename to api/trace/tracetest/trace_context_propagator_test.go index 10a7434e920..5125fb328b5 100644 --- a/api/trace/testtrace/trace_context_propagator_test.go +++ b/api/trace/tracetest/trace_context_propagator_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package testtrace_test +package tracetest_test import ( "context" diff --git a/api/trace/testtrace/tracer.go b/api/trace/tracetest/tracer.go similarity index 99% rename from api/trace/testtrace/tracer.go rename to api/trace/tracetest/tracer.go index 6fd2598b774..c8d06adebdf 100644 --- a/api/trace/testtrace/tracer.go +++ b/api/trace/tracetest/tracer.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package testtrace +package tracetest import ( "context" diff --git a/api/trace/testtrace/tracer_test.go b/api/trace/tracetest/tracer_test.go similarity index 91% rename from api/trace/testtrace/tracer_test.go rename to api/trace/tracetest/tracer_test.go index f62a33755b5..4af442b3972 100644 --- a/api/trace/testtrace/tracer_test.go +++ b/api/trace/tracetest/tracer_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package testtrace_test +package tracetest_test import ( "context" @@ -22,18 +22,18 @@ import ( "testing" "time" + "go.opentelemetry.io/otel/api/apitest" "go.opentelemetry.io/otel/api/kv" - "go.opentelemetry.io/otel/api/testharness" "go.opentelemetry.io/otel/api/trace" - "go.opentelemetry.io/otel/api/trace/testtrace" + "go.opentelemetry.io/otel/api/trace/tracetest" "go.opentelemetry.io/otel/internal/matchers" ) func TestTracer(t *testing.T) { - tp := testtrace.NewProvider() + tp := tracetest.NewProvider() - testharness.NewHarness(t).TestTracer(func() func() trace.Tracer { - tp := testtrace.NewProvider() + apitest.NewHarness(t).TestTracer(func() func() trace.Tracer { + tp := tracetest.NewProvider() var i uint64 return func() trace.Tracer { return tp.Tracer(fmt.Sprintf("tracer %d", atomic.AddUint64(&i, 1))) @@ -57,7 +57,7 @@ func TestTracer(t *testing.T) { subject := tp.Tracer(t.Name()) _, span := subject.Start(context.Background(), "test", trace.WithStartTime(expectedStartTime)) - testSpan, ok := span.(*testtrace.Span) + testSpan, ok := span.(*tracetest.Span) e.Expect(ok).ToBeTrue() e.Expect(testSpan.StartTime()).ToEqual(expectedStartTime) @@ -74,7 +74,7 @@ func TestTracer(t *testing.T) { subject := tp.Tracer(t.Name()) _, span := subject.Start(context.Background(), "test", trace.WithAttributes(attr1, attr2)) - testSpan, ok := span.(*testtrace.Span) + testSpan, ok := span.(*tracetest.Span) e.Expect(ok).ToBeTrue() attributes := testSpan.Attributes() @@ -94,7 +94,7 @@ func TestTracer(t *testing.T) { _, span := subject.Start(parent, "child") - testSpan, ok := span.(*testtrace.Span) + testSpan, ok := span.(*tracetest.Span) e.Expect(ok).ToBeTrue() childSpanContext := testSpan.SpanContext() @@ -117,7 +117,7 @@ func TestTracer(t *testing.T) { _, span := subject.Start(parent, "child") - testSpan, ok := span.(*testtrace.Span) + testSpan, ok := span.(*tracetest.Span) e.Expect(ok).ToBeTrue() childSpanContext := testSpan.SpanContext() @@ -139,7 +139,7 @@ func TestTracer(t *testing.T) { _, span := subject.Start(parent, "child") - testSpan, ok := span.(*testtrace.Span) + testSpan, ok := span.(*tracetest.Span) e.Expect(ok).ToBeTrue() childSpanContext := testSpan.SpanContext() @@ -162,7 +162,7 @@ func TestTracer(t *testing.T) { _, span := subject.Start(context.Background(), "child") - testSpan, ok := span.(*testtrace.Span) + testSpan, ok := span.(*tracetest.Span) e.Expect(ok).ToBeTrue() childSpanContext := testSpan.SpanContext() @@ -188,7 +188,7 @@ func TestTracer(t *testing.T) { _, span := subject.Start(parentCtx, "child", trace.WithNewRoot()) - testSpan, ok := span.(*testtrace.Span) + testSpan, ok := span.(*tracetest.Span) e.Expect(ok).ToBeTrue() childSpanContext := testSpan.SpanContext() @@ -248,7 +248,7 @@ func TestTracer(t *testing.T) { _, span = subject.Start(context.Background(), "test", trace.LinkedTo(link1.SpanContext, link1.Attributes...), trace.LinkedTo(link2.SpanContext, link2.Attributes...)) - testSpan, ok := span.(*testtrace.Span) + testSpan, ok := span.(*tracetest.Span) e.Expect(ok).ToBeTrue() links := testSpan.Links() @@ -259,7 +259,7 @@ func TestTracer(t *testing.T) { } func testTracedSpan(t *testing.T, fn func(tracer trace.Tracer, name string) (trace.Span, error)) { - tp := testtrace.NewProvider() + tp := tracetest.NewProvider() t.Run("starts a span with the expected name", func(t *testing.T) { t.Parallel() @@ -272,7 +272,7 @@ func testTracedSpan(t *testing.T, fn func(tracer trace.Tracer, name string) (tra e.Expect(err).ToBeNil() - testSpan, ok := span.(*testtrace.Span) + testSpan, ok := span.(*tracetest.Span) e.Expect(ok).ToBeTrue() e.Expect(testSpan.Name()).ToEqual(expectedName) @@ -291,7 +291,7 @@ func testTracedSpan(t *testing.T, fn func(tracer trace.Tracer, name string) (tra e.Expect(err).ToBeNil() - testSpan, ok := span.(*testtrace.Span) + testSpan, ok := span.(*tracetest.Span) e.Expect(ok).ToBeTrue() e.Expect(testSpan.StartTime()).ToBeTemporally(matchers.AfterOrSameTime, start) @@ -303,8 +303,8 @@ func testTracedSpan(t *testing.T, fn func(tracer trace.Tracer, name string) (tra e := matchers.NewExpecter(t) - sr := new(testtrace.StandardSpanRecorder) - subject := testtrace.NewProvider(testtrace.WithSpanRecorder(sr)).Tracer(t.Name()) + sr := new(tracetest.StandardSpanRecorder) + subject := tracetest.NewProvider(tracetest.WithSpanRecorder(sr)).Tracer(t.Name()) subject.Start(context.Background(), "span1") e.Expect(len(sr.Started())).ToEqual(1) @@ -323,8 +323,8 @@ func testTracedSpan(t *testing.T, fn func(tracer trace.Tracer, name string) (tra e := matchers.NewExpecter(t) - sr := new(testtrace.StandardSpanRecorder) - subject := testtrace.NewProvider(testtrace.WithSpanRecorder(sr)).Tracer(t.Name()) + sr := new(tracetest.StandardSpanRecorder) + subject := tracetest.NewProvider(tracetest.WithSpanRecorder(sr)).Tracer(t.Name()) numSpans := 2 diff --git a/sdk/metric/benchmark_test.go b/sdk/metric/benchmark_test.go index 204dbdfbca9..6331084b4c0 100644 --- a/sdk/metric/benchmark_test.go +++ b/sdk/metric/benchmark_test.go @@ -26,7 +26,7 @@ import ( "go.opentelemetry.io/otel/api/metric" export "go.opentelemetry.io/otel/sdk/export/metric" sdk "go.opentelemetry.io/otel/sdk/metric" - "go.opentelemetry.io/otel/sdk/metric/processor/test" + "go.opentelemetry.io/otel/sdk/metric/processor/processortest" ) type benchFixture struct { @@ -40,7 +40,7 @@ func newFixture(b *testing.B) *benchFixture { b.ReportAllocs() bf := &benchFixture{ B: b, - AggregatorSelector: test.AggregatorSelector(), + AggregatorSelector: processortest.AggregatorSelector(), } bf.accumulator = sdk.NewAccumulator(bf) diff --git a/sdk/metric/controller/test/test.go b/sdk/metric/controller/controllertest/test.go similarity index 98% rename from sdk/metric/controller/test/test.go rename to sdk/metric/controller/controllertest/test.go index f2c2e744762..94f38fbe6bd 100644 --- a/sdk/metric/controller/test/test.go +++ b/sdk/metric/controller/controllertest/test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package test +package controllertest import ( "time" diff --git a/sdk/metric/controller/pull/pull_test.go b/sdk/metric/controller/pull/pull_test.go index c2dde5de438..8a129caf85e 100644 --- a/sdk/metric/controller/pull/pull_test.go +++ b/sdk/metric/controller/pull/pull_test.go @@ -26,9 +26,9 @@ import ( "go.opentelemetry.io/otel/api/label" "go.opentelemetry.io/otel/api/metric" export "go.opentelemetry.io/otel/sdk/export/metric" + "go.opentelemetry.io/otel/sdk/metric/controller/controllertest" "go.opentelemetry.io/otel/sdk/metric/controller/pull" - controllerTest "go.opentelemetry.io/otel/sdk/metric/controller/test" - "go.opentelemetry.io/otel/sdk/metric/processor/test" + "go.opentelemetry.io/otel/sdk/metric/processor/processortest" selector "go.opentelemetry.io/otel/sdk/metric/selector/simple" ) @@ -46,7 +46,7 @@ func TestPullNoCache(t *testing.T) { counter.Add(ctx, 10, kv.String("A", "B")) require.NoError(t, puller.Collect(ctx)) - records := test.NewOutput(label.DefaultEncoder()) + records := processortest.NewOutput(label.DefaultEncoder()) require.NoError(t, puller.ForEach(export.CumulativeExporter, records.AddRecord)) require.EqualValues(t, map[string]float64{ @@ -56,7 +56,7 @@ func TestPullNoCache(t *testing.T) { counter.Add(ctx, 10, kv.String("A", "B")) require.NoError(t, puller.Collect(ctx)) - records = test.NewOutput(label.DefaultEncoder()) + records = processortest.NewOutput(label.DefaultEncoder()) require.NoError(t, puller.ForEach(export.CumulativeExporter, records.AddRecord)) require.EqualValues(t, map[string]float64{ @@ -70,7 +70,7 @@ func TestPullWithCache(t *testing.T) { export.CumulativeExporter, pull.WithCachePeriod(time.Second), ) - mock := controllerTest.NewMockClock() + mock := controllertest.NewMockClock() puller.SetClock(mock) ctx := context.Background() @@ -80,7 +80,7 @@ func TestPullWithCache(t *testing.T) { counter.Add(ctx, 10, kv.String("A", "B")) require.NoError(t, puller.Collect(ctx)) - records := test.NewOutput(label.DefaultEncoder()) + records := processortest.NewOutput(label.DefaultEncoder()) require.NoError(t, puller.ForEach(export.CumulativeExporter, records.AddRecord)) require.EqualValues(t, map[string]float64{ @@ -91,7 +91,7 @@ func TestPullWithCache(t *testing.T) { // Cached value! require.NoError(t, puller.Collect(ctx)) - records = test.NewOutput(label.DefaultEncoder()) + records = processortest.NewOutput(label.DefaultEncoder()) require.NoError(t, puller.ForEach(export.CumulativeExporter, records.AddRecord)) require.EqualValues(t, map[string]float64{ @@ -103,7 +103,7 @@ func TestPullWithCache(t *testing.T) { // Re-computed value! require.NoError(t, puller.Collect(ctx)) - records = test.NewOutput(label.DefaultEncoder()) + records = processortest.NewOutput(label.DefaultEncoder()) require.NoError(t, puller.ForEach(export.CumulativeExporter, records.AddRecord)) require.EqualValues(t, map[string]float64{ diff --git a/sdk/metric/controller/push/push_test.go b/sdk/metric/controller/push/push_test.go index ab9f4f55cbf..46fc5116e62 100644 --- a/sdk/metric/controller/push/push_test.go +++ b/sdk/metric/controller/push/push_test.go @@ -31,10 +31,9 @@ import ( export "go.opentelemetry.io/otel/sdk/export/metric" "go.opentelemetry.io/otel/sdk/export/metric/aggregation" "go.opentelemetry.io/otel/sdk/export/metric/metrictest" + "go.opentelemetry.io/otel/sdk/metric/controller/controllertest" "go.opentelemetry.io/otel/sdk/metric/controller/push" - controllerTest "go.opentelemetry.io/otel/sdk/metric/controller/test" - "go.opentelemetry.io/otel/sdk/metric/processor/test" - processorTest "go.opentelemetry.io/otel/sdk/metric/processor/test" + "go.opentelemetry.io/otel/sdk/metric/processor/processortest" "go.opentelemetry.io/otel/sdk/resource" ) @@ -125,7 +124,7 @@ func (e *testExporter) resetRecords() ([]export.Record, int) { func TestPushDoubleStop(t *testing.T) { fix := newFixture(t) - p := push.New(processorTest.AggregatorSelector(), fix.exporter) + p := push.New(processortest.AggregatorSelector(), fix.exporter) p.Start() p.Stop() p.Stop() @@ -133,7 +132,7 @@ func TestPushDoubleStop(t *testing.T) { func TestPushDoubleStart(t *testing.T) { fix := newFixture(t) - p := push.New(test.AggregatorSelector(), fix.exporter) + p := push.New(processortest.AggregatorSelector(), fix.exporter) p.Start() p.Start() p.Stop() @@ -143,14 +142,14 @@ func TestPushTicker(t *testing.T) { fix := newFixture(t) p := push.New( - test.AggregatorSelector(), + processortest.AggregatorSelector(), fix.exporter, push.WithPeriod(time.Second), push.WithResource(testResource), ) meter := p.Provider().Meter("name") - mock := controllerTest.NewMockClock() + mock := controllertest.NewMockClock() p.SetClock(mock) ctx := context.Background() @@ -224,13 +223,13 @@ func TestPushExportError(t *testing.T) { fix.exporter.injectErr = injector("counter1.sum", tt.injectedError) p := push.New( - test.AggregatorSelector(), + processortest.AggregatorSelector(), fix.exporter, push.WithPeriod(time.Second), push.WithResource(testResource), ) - mock := controllerTest.NewMockClock() + mock := controllertest.NewMockClock() p.SetClock(mock) ctx := context.Background() diff --git a/sdk/metric/correct_test.go b/sdk/metric/correct_test.go index 4809ee5fa44..8f69a439a9a 100644 --- a/sdk/metric/correct_test.go +++ b/sdk/metric/correct_test.go @@ -30,8 +30,7 @@ import ( export "go.opentelemetry.io/otel/sdk/export/metric" "go.opentelemetry.io/otel/sdk/export/metric/aggregation" metricsdk "go.opentelemetry.io/otel/sdk/metric" - "go.opentelemetry.io/otel/sdk/metric/processor/test" - batchTest "go.opentelemetry.io/otel/sdk/metric/processor/test" + "go.opentelemetry.io/otel/sdk/metric/processor/processortest" "go.opentelemetry.io/otel/sdk/resource" ) @@ -84,14 +83,14 @@ type testSelector struct { func (ts *testSelector) AggregatorFor(desc *metric.Descriptor, aggPtrs ...*export.Aggregator) { ts.newAggCount += len(aggPtrs) - test.AggregatorSelector().AggregatorFor(desc, aggPtrs...) + processortest.AggregatorSelector().AggregatorFor(desc, aggPtrs...) } func newSDK(t *testing.T) (metric.Meter, *metricsdk.Accumulator, *correctnessProcessor) { testHandler.Reset() processor := &correctnessProcessor{ t: t, - testSelector: &testSelector{selector: test.AggregatorSelector()}, + testSelector: &testSelector{selector: processortest.AggregatorSelector()}, } accum := metricsdk.NewAccumulator( processor, @@ -346,7 +345,7 @@ func TestObserverCollection(t *testing.T) { require.Equal(t, collected, len(processor.accumulations)) - out := batchTest.NewOutput(label.DefaultEncoder()) + out := processortest.NewOutput(label.DefaultEncoder()) for _, rec := range processor.accumulations { require.NoError(t, out.AddAccumulation(rec)) } @@ -449,7 +448,7 @@ func TestObserverBatch(t *testing.T) { require.Equal(t, collected, len(processor.accumulations)) - out := batchTest.NewOutput(label.DefaultEncoder()) + out := processortest.NewOutput(label.DefaultEncoder()) for _, rec := range processor.accumulations { require.NoError(t, out.AddAccumulation(rec)) } @@ -494,7 +493,7 @@ func TestRecordBatch(t *testing.T) { sdk.Collect(ctx) - out := batchTest.NewOutput(label.DefaultEncoder()) + out := processortest.NewOutput(label.DefaultEncoder()) for _, rec := range processor.accumulations { require.NoError(t, out.AddAccumulation(rec)) } @@ -576,7 +575,7 @@ func TestSyncInAsync(t *testing.T) { sdk.Collect(ctx) - out := batchTest.NewOutput(label.DefaultEncoder()) + out := processortest.NewOutput(label.DefaultEncoder()) for _, rec := range processor.accumulations { require.NoError(t, out.AddAccumulation(rec)) } diff --git a/sdk/metric/processor/basic/basic_test.go b/sdk/metric/processor/basic/basic_test.go index 4d3f6392be1..1dcab1b7b16 100644 --- a/sdk/metric/processor/basic/basic_test.go +++ b/sdk/metric/processor/basic/basic_test.go @@ -36,7 +36,7 @@ import ( "go.opentelemetry.io/otel/sdk/metric/aggregator/minmaxsumcount" "go.opentelemetry.io/otel/sdk/metric/aggregator/sum" "go.opentelemetry.io/otel/sdk/metric/processor/basic" - "go.opentelemetry.io/otel/sdk/metric/processor/test" + "go.opentelemetry.io/otel/sdk/metric/processor/processortest" "go.opentelemetry.io/otel/sdk/resource" ) @@ -207,7 +207,7 @@ func testProcessor( } // Test the final checkpoint state. - records1 := test.NewOutput(label.DefaultEncoder()) + records1 := processortest.NewOutput(label.DefaultEncoder()) err = checkpointSet.ForEach(ekind, records1.AddRecord) // Test for an allowed error: @@ -287,19 +287,19 @@ func (bogusExporter) Export(context.Context, export.CheckpointSet) error { func TestBasicInconsistent(t *testing.T) { // Test double-start - b := basic.New(test.AggregatorSelector(), export.PassThroughExporter) + b := basic.New(processortest.AggregatorSelector(), export.PassThroughExporter) b.StartCollection() b.StartCollection() require.Equal(t, basic.ErrInconsistentState, b.FinishCollection()) // Test finish without start - b = basic.New(test.AggregatorSelector(), export.PassThroughExporter) + b = basic.New(processortest.AggregatorSelector(), export.PassThroughExporter) require.Equal(t, basic.ErrInconsistentState, b.FinishCollection()) // Test no finish - b = basic.New(test.AggregatorSelector(), export.PassThroughExporter) + b = basic.New(processortest.AggregatorSelector(), export.PassThroughExporter) b.StartCollection() require.Equal( @@ -312,14 +312,14 @@ func TestBasicInconsistent(t *testing.T) { ) // Test no start - b = basic.New(test.AggregatorSelector(), export.PassThroughExporter) + b = basic.New(processortest.AggregatorSelector(), export.PassThroughExporter) desc := metric.NewDescriptor("inst", metric.CounterKind, metric.Int64NumberKind) accum := export.NewAccumulation(&desc, label.EmptySet(), resource.Empty(), metrictest.NoopAggregator{}) require.Equal(t, basic.ErrInconsistentState, b.Process(accum)) // Test invalid kind: - b = basic.New(test.AggregatorSelector(), export.PassThroughExporter) + b = basic.New(processortest.AggregatorSelector(), export.PassThroughExporter) b.StartCollection() require.NoError(t, b.Process(accum)) require.NoError(t, b.FinishCollection()) @@ -334,7 +334,7 @@ func TestBasicInconsistent(t *testing.T) { func TestBasicTimestamps(t *testing.T) { beforeNew := time.Now() - b := basic.New(test.AggregatorSelector(), export.PassThroughExporter) + b := basic.New(processortest.AggregatorSelector(), export.PassThroughExporter) afterNew := time.Now() desc := metric.NewDescriptor("inst", metric.CounterKind, metric.Int64NumberKind) @@ -395,7 +395,7 @@ func TestStatefulNoMemoryCumulative(t *testing.T) { require.NoError(t, processor.FinishCollection()) // Verify zero elements - records := test.NewOutput(label.DefaultEncoder()) + records := processortest.NewOutput(label.DefaultEncoder()) require.NoError(t, checkpointSet.ForEach(ekind, records.AddRecord)) require.EqualValues(t, map[string]float64{}, records.Map) @@ -405,7 +405,7 @@ func TestStatefulNoMemoryCumulative(t *testing.T) { require.NoError(t, processor.FinishCollection()) // Verify one element - records = test.NewOutput(label.DefaultEncoder()) + records = processortest.NewOutput(label.DefaultEncoder()) require.NoError(t, checkpointSet.ForEach(ekind, records.AddRecord)) require.EqualValues(t, map[string]float64{ "inst/A=B/R=V": float64(i * 10), @@ -429,7 +429,7 @@ func TestStatefulNoMemoryDelta(t *testing.T) { require.NoError(t, processor.FinishCollection()) // Verify zero elements - records := test.NewOutput(label.DefaultEncoder()) + records := processortest.NewOutput(label.DefaultEncoder()) require.NoError(t, checkpointSet.ForEach(ekind, records.AddRecord)) require.EqualValues(t, map[string]float64{}, records.Map) @@ -439,7 +439,7 @@ func TestStatefulNoMemoryDelta(t *testing.T) { require.NoError(t, processor.FinishCollection()) // Verify one element - records = test.NewOutput(label.DefaultEncoder()) + records = processortest.NewOutput(label.DefaultEncoder()) require.NoError(t, checkpointSet.ForEach(ekind, records.AddRecord)) require.EqualValues(t, map[string]float64{ "inst/A=B/R=V": 10, diff --git a/sdk/metric/processor/test/test.go b/sdk/metric/processor/processortest/test.go similarity index 99% rename from sdk/metric/processor/test/test.go rename to sdk/metric/processor/processortest/test.go index fe2d4eec28e..422db8cbf27 100644 --- a/sdk/metric/processor/test/test.go +++ b/sdk/metric/processor/processortest/test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package test +package processortest import ( "fmt" diff --git a/sdk/metric/stress_test.go b/sdk/metric/stress_test.go index e0245ae9a6d..c1368869250 100644 --- a/sdk/metric/stress_test.go +++ b/sdk/metric/stress_test.go @@ -36,7 +36,7 @@ import ( api "go.opentelemetry.io/otel/api/metric" export "go.opentelemetry.io/otel/sdk/export/metric" "go.opentelemetry.io/otel/sdk/export/metric/aggregation" - "go.opentelemetry.io/otel/sdk/metric/processor/test" + "go.opentelemetry.io/otel/sdk/metric/processor/processortest" ) const ( @@ -290,7 +290,7 @@ func stressTest(t *testing.T, impl testImpl) { T: t, impl: impl, lused: map[string]bool{}, - AggregatorSelector: test.AggregatorSelector(), + AggregatorSelector: processortest.AggregatorSelector(), } cc := concurrency() sdk := NewAccumulator(fixture) diff --git a/sdk/trace/trace_test.go b/sdk/trace/trace_test.go index 69d27ac5182..3e8838b2664 100644 --- a/sdk/trace/trace_test.go +++ b/sdk/trace/trace_test.go @@ -31,8 +31,8 @@ import ( "github.com/stretchr/testify/require" grpccodes "google.golang.org/grpc/codes" + "go.opentelemetry.io/otel/api/apitest" "go.opentelemetry.io/otel/api/kv" - "go.opentelemetry.io/otel/api/testharness" "go.opentelemetry.io/otel/api/trace" apitrace "go.opentelemetry.io/otel/api/trace" otelcodes "go.opentelemetry.io/otel/codes" @@ -63,7 +63,7 @@ func TestTracerFollowsExpectedAPIBehaviour(t *testing.T) { if err != nil { t.Fatalf("failed to create provider, err: %v\n", err) } - harness := testharness.NewHarness(t) + harness := apitest.NewHarness(t) subjectFactory := func() trace.Tracer { return tp.Tracer("") }