Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Move the `go.opentelemetry.io/otel/api/trace/tracetest` package into `go.opentelemetry.io/otel/oteltest`. (#1229)
- OTLP Exporter supports OTLP v0.5.0. (#1230)
- The Sampler is now called on local child spans. (#1233)
- Move test harness from the `go.opentelemetry.io/otel/api/apitest` package into `go.opentelemetry.io/otel/oteltest`. (#1241)
- Rename `MergeItererator` to `MergeIterator` in the `go.opentelemetry.io/otel/label` package. (#1244)

### Removed
Expand Down
16 changes: 0 additions & 16 deletions api/apitest/doc.go

This file was deleted.

7 changes: 6 additions & 1 deletion api/apitest/harness.go → oteltest/harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package apitest
package oteltest

import (
"context"
Expand All @@ -26,16 +26,21 @@ import (
"go.opentelemetry.io/otel/label"
)

// Harness is a testing harness used to test implementations of the
// OpenTelemetry API.
type Harness struct {
t *testing.T
}

// NewHarness returns an instantiated *Harness using t.
func NewHarness(t *testing.T) *Harness {
return &Harness{
t: t,
}
}

// TestTracer runs validation tests for an implementation of the OpenTelemetry
// Tracer API.
func (h *Harness) TestTracer(subjectFactory func() otel.Tracer) {
h.t.Run("#Start", func(t *testing.T) {
t.Run("propagates the original context", func(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions oteltest/tracer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"time"

"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/api/apitest"
"go.opentelemetry.io/otel/internal/matchers"
"go.opentelemetry.io/otel/label"
"go.opentelemetry.io/otel/oteltest"
Expand All @@ -32,7 +31,7 @@ import (
func TestTracer(t *testing.T) {
tp := oteltest.NewTracerProvider()

apitest.NewHarness(t).TestTracer(func() func() otel.Tracer {
oteltest.NewHarness(t).TestTracer(func() func() otel.Tracer {
tp := oteltest.NewTracerProvider()
var i uint64
return func() otel.Tracer {
Expand Down
4 changes: 2 additions & 2 deletions sdk/trace/trace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ import (
"go.opentelemetry.io/otel/api/global"
"go.opentelemetry.io/otel/codes"
"go.opentelemetry.io/otel/label"
"go.opentelemetry.io/otel/oteltest"

"github.com/google/go-cmp/cmp"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"go.opentelemetry.io/otel/api/apitest"
ottest "go.opentelemetry.io/otel/internal/testing"
export "go.opentelemetry.io/otel/sdk/export/trace"
"go.opentelemetry.io/otel/sdk/instrumentation"
Expand All @@ -59,7 +59,7 @@ func init() {

func TestTracerFollowsExpectedAPIBehaviour(t *testing.T) {
tp := NewTracerProvider(WithConfig(Config{DefaultSampler: TraceIDRatioBased(0)}))
harness := apitest.NewHarness(t)
harness := oteltest.NewHarness(t)
subjectFactory := func() otel.Tracer {
return tp.Tracer("")
}
Expand Down