Skip to content

Commit

Permalink
Remove unnecessary and unused testdata (open-telemetry#5599)
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Drutu <[email protected]>
  • Loading branch information
bogdandrutu authored Jun 27, 2022
1 parent 259f711 commit 1a4361c
Show file tree
Hide file tree
Showing 32 changed files with 259 additions and 431 deletions.
2 changes: 1 addition & 1 deletion component/componenttest/shutdown_verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func verifyTracesProcessorDoesntProduceAfterShutdown(t *testing.T, factory compo
// Send some traces to the processor.
const generatedCount = 10
for i := 0; i < generatedCount; i++ {
require.NoError(t, processor.ConsumeTraces(context.Background(), testdata.GenerateTracesOneSpan()))
require.NoError(t, processor.ConsumeTraces(context.Background(), testdata.GenerateTraces(1)))
}

// Now shutdown the processor.
Expand Down
18 changes: 9 additions & 9 deletions config/configgrpc/configgrpc_benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,45 +137,45 @@ func setupTestPayloads() []testPayload {
logMarshaler := &logMarshaler{plog.NewProtoMarshaler()}
payloads = append(payloads, testPayload{
name: "sm_log_request",
message: testdata.GenerateLogsOneLogRecord(),
message: testdata.GenerateLogs(1),
marshaler: logMarshaler})
payloads = append(payloads, testPayload{
name: "md_log_request",
message: testdata.GenerateLogsTwoLogRecordsSameResourceOneDifferent(),
message: testdata.GenerateLogs(2),
marshaler: logMarshaler})
payloads = append(payloads, testPayload{
name: "lg_log_request",
message: testdata.GenerateLogsManyLogRecordsSameResource(50),
message: testdata.GenerateLogs(50),
marshaler: logMarshaler})

// trace payloads
tracesMarshaler := &traceMarshaler{ptrace.NewProtoMarshaler()}
payloads = append(payloads, testPayload{
name: "sm_trace_request",
message: testdata.GenerateTracesOneSpan(),
message: testdata.GenerateTraces(1),
marshaler: tracesMarshaler})
payloads = append(payloads, testPayload{
name: "md_trace_request",
message: testdata.GenerateTracesTwoSpansSameResourceOneDifferent(),
message: testdata.GenerateTraces(2),
marshaler: tracesMarshaler})
payloads = append(payloads, testPayload{
name: "lg_trace_request",
message: testdata.GenerateTracesManySpansSameResource(50),
message: testdata.GenerateTraces(50),
marshaler: tracesMarshaler})

// metric payloads
metricsMarshaler := &metricsMarshaler{pmetric.NewProtoMarshaler()}
payloads = append(payloads, testPayload{
name: "sm_metric_request",
message: testdata.GenerateMetricsOneMetric(),
message: testdata.GenerateMetrics(1),
marshaler: metricsMarshaler})
payloads = append(payloads, testPayload{
name: "md_metric_request",
message: testdata.GenerateMetricsTwoMetrics(),
message: testdata.GenerateMetrics(2),
marshaler: metricsMarshaler})
payloads = append(payloads, testPayload{
name: "lg_metric_request",
message: testdata.GenerateMetricsManyMetricsSameResource(50),
message: testdata.GenerateMetrics(50),
marshaler: metricsMarshaler})

return payloads
Expand Down
12 changes: 6 additions & 6 deletions consumer/consumererror/signalerrors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
)

func TestTraces(t *testing.T) {
td := testdata.GenerateTracesOneSpan()
td := testdata.GenerateTraces(1)
err := errors.New("some error")
traceErr := NewTraces(err, td)
assert.Equal(t, err.Error(), traceErr.Error())
Expand All @@ -37,7 +37,7 @@ func TestTraces(t *testing.T) {
}

func TestTraces_Unwrap(t *testing.T) {
td := testdata.GenerateTracesOneSpan()
td := testdata.GenerateTraces(1)
var err error = testErrorType{"some error"}
// Wrapping err with error Traces.
traceErr := NewTraces(err, td)
Expand All @@ -49,7 +49,7 @@ func TestTraces_Unwrap(t *testing.T) {
}

func TestLogs(t *testing.T) {
td := testdata.GenerateLogsOneLogRecord()
td := testdata.GenerateLogs(1)
err := errors.New("some error")
logsErr := NewLogs(err, td)
assert.Equal(t, err.Error(), logsErr.Error())
Expand All @@ -61,7 +61,7 @@ func TestLogs(t *testing.T) {
}

func TestLogs_Unwrap(t *testing.T) {
td := testdata.GenerateLogsOneLogRecord()
td := testdata.GenerateLogs(1)
var err error = testErrorType{"some error"}
// Wrapping err with error Logs.
logsErr := NewLogs(err, td)
Expand All @@ -73,7 +73,7 @@ func TestLogs_Unwrap(t *testing.T) {
}

func TestMetrics(t *testing.T) {
td := testdata.GenerateMetricsOneMetric()
td := testdata.GenerateMetrics(1)
err := errors.New("some error")
metricErr := NewMetrics(err, td)
assert.Equal(t, err.Error(), metricErr.Error())
Expand All @@ -85,7 +85,7 @@ func TestMetrics(t *testing.T) {
}

func TestMetrics_Unwrap(t *testing.T) {
td := testdata.GenerateMetricsOneMetric()
td := testdata.GenerateMetrics(1)
var err error = testErrorType{"some error"}
// Wrapping err with error Metrics.
metricErr := NewMetrics(err, td)
Expand Down
6 changes: 3 additions & 3 deletions consumer/consumertest/sink_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (

func TestTracesSink(t *testing.T) {
sink := new(TracesSink)
td := testdata.GenerateTracesOneSpan()
td := testdata.GenerateTraces(1)
want := make([]ptrace.Traces, 0, 7)
for i := 0; i < 7; i++ {
require.NoError(t, sink.ConsumeTraces(context.Background(), td))
Expand All @@ -44,7 +44,7 @@ func TestTracesSink(t *testing.T) {

func TestMetricsSink(t *testing.T) {
sink := new(MetricsSink)
md := testdata.GenerateMetricsOneMetric()
md := testdata.GenerateMetrics(1)
want := make([]pmetric.Metrics, 0, 7)
for i := 0; i < 7; i++ {
require.NoError(t, sink.ConsumeMetrics(context.Background(), md))
Expand All @@ -59,7 +59,7 @@ func TestMetricsSink(t *testing.T) {

func TestLogsSink(t *testing.T) {
sink := new(LogsSink)
md := testdata.GenerateLogsOneLogRecord()
md := testdata.GenerateLogs(1)
want := make([]plog.Logs, 0, 7)
for i := 0; i < 7; i++ {
require.NoError(t, sink.ConsumeLogs(context.Background(), md))
Expand Down
8 changes: 4 additions & 4 deletions exporter/exporterhelper/logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ var (
)

func TestLogsRequest(t *testing.T) {
lr := newLogsRequest(context.Background(), testdata.GenerateLogsOneLogRecord(), nil)
lr := newLogsRequest(context.Background(), testdata.GenerateLogs(1), nil)

logErr := consumererror.NewLogs(errors.New("some error"), plog.NewLogs())
assert.EqualValues(
Expand Down Expand Up @@ -137,7 +137,7 @@ func TestLogsExporter_WithRecordEnqueueFailedMetrics(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, te)

md := testdata.GenerateLogsTwoLogRecordsSameResourceOneDifferent()
md := testdata.GenerateLogs(3)
const numBatches = 7
for i := 0; i < numBatches; i++ {
// errors are checked in the checkExporterEnqueueFailedLogsStats function below.
Expand Down Expand Up @@ -209,7 +209,7 @@ func checkRecordedMetricsForLogsExporter(t *testing.T, le component.LogsExporter
require.NoError(t, err)
t.Cleanup(func() { require.NoError(t, tt.Shutdown(context.Background())) })

ld := testdata.GenerateLogsTwoLogRecordsSameResource()
ld := testdata.GenerateLogs(2)
const numBatches = 7
for i := 0; i < numBatches; i++ {
require.Equal(t, wantError, le.ConsumeLogs(context.Background(), ld))
Expand All @@ -224,7 +224,7 @@ func checkRecordedMetricsForLogsExporter(t *testing.T, le component.LogsExporter
}

func generateLogsTraffic(t *testing.T, tracer trace.Tracer, le component.LogsExporter, numRequests int, wantError error) {
ld := testdata.GenerateLogsOneLogRecord()
ld := testdata.GenerateLogs(1)
ctx, span := tracer.Start(context.Background(), fakeLogsParentSpanName)
defer span.End()
for i := 0; i < numRequests; i++ {
Expand Down
8 changes: 4 additions & 4 deletions exporter/exporterhelper/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ var (
)

func TestMetricsRequest(t *testing.T) {
mr := newMetricsRequest(context.Background(), testdata.GenerateMetricsOneMetric(), nil)
mr := newMetricsRequest(context.Background(), testdata.GenerateMetrics(1), nil)

metricsErr := consumererror.NewMetrics(errors.New("some error"), pmetric.NewMetrics())
assert.EqualValues(
Expand Down Expand Up @@ -136,7 +136,7 @@ func TestMetricsExporter_WithRecordEnqueueFailedMetrics(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, te)

md := testdata.GenerateMetricsOneMetric()
md := testdata.GenerateMetrics(1)
const numBatches = 7
for i := 0; i < numBatches; i++ {
// errors are checked in the checkExporterEnqueueFailedMetricsStats function below.
Expand Down Expand Up @@ -210,7 +210,7 @@ func checkRecordedMetricsForMetricsExporter(t *testing.T, me component.MetricsEx
require.NoError(t, err)
t.Cleanup(func() { require.NoError(t, tt.Shutdown(context.Background())) })

md := testdata.GenerateMetricsTwoMetrics()
md := testdata.GenerateMetrics(2)
const numBatches = 7
for i := 0; i < numBatches; i++ {
require.Equal(t, wantError, me.ConsumeMetrics(context.Background(), md))
Expand All @@ -226,7 +226,7 @@ func checkRecordedMetricsForMetricsExporter(t *testing.T, me component.MetricsEx
}

func generateMetricsTraffic(t *testing.T, tracer trace.Tracer, me component.MetricsExporter, numRequests int, wantError error) {
md := testdata.GenerateMetricsOneMetric()
md := testdata.GenerateMetrics(1)
ctx, span := tracer.Start(context.Background(), fakeMetricsParentSpanName)
defer span.End()
for i := 0; i < numRequests; i++ {
Expand Down
2 changes: 1 addition & 1 deletion exporter/exporterhelper/queued_retry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func TestQueuedRetry_OnError(t *testing.T) {
assert.NoError(t, be.Shutdown(context.Background()))
})

traceErr := consumererror.NewTraces(errors.New("some error"), testdata.GenerateTracesOneSpan())
traceErr := consumererror.NewTraces(errors.New("some error"), testdata.GenerateTraces(1))
mockR := newMockRequest(context.Background(), 2, traceErr)
ocs.run(func() {
// This is asynchronous so it should just enqueue, no errors expected.
Expand Down
6 changes: 3 additions & 3 deletions exporter/exporterhelper/traces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ var (
)

func TestTracesRequest(t *testing.T) {
mr := newTracesRequest(context.Background(), testdata.GenerateTracesOneSpan(), nil)
mr := newTracesRequest(context.Background(), testdata.GenerateTraces(1), nil)

traceErr := consumererror.NewTraces(errors.New("some error"), ptrace.NewTraces())
assert.EqualValues(t, newTracesRequest(context.Background(), ptrace.NewTraces(), nil), mr.onError(traceErr))
Expand Down Expand Up @@ -134,7 +134,7 @@ func TestTracesExporter_WithRecordEnqueueFailedMetrics(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, te)

td := testdata.GenerateTracesTwoSpansSameResource()
td := testdata.GenerateTraces(2)
const numBatches = 7
for i := 0; i < numBatches; i++ {
// errors are checked in the checkExporterEnqueueFailedTracesStats function below.
Expand Down Expand Up @@ -210,7 +210,7 @@ func checkRecordedMetricsForTracesExporter(t *testing.T, te component.TracesExpo
require.NoError(t, err)
t.Cleanup(func() { require.NoError(t, tt.Shutdown(context.Background())) })

td := testdata.GenerateTracesTwoSpansSameResource()
td := testdata.GenerateTraces(2)
const numBatches = 7
for i := 0; i < numBatches; i++ {
require.Equal(t, wantError, te.ConsumeTraces(context.Background(), td))
Expand Down
8 changes: 3 additions & 5 deletions exporter/loggingexporter/internal/otlptext/logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,9 @@ func TestLogsText(t *testing.T) {
args args
empty bool
}{
{"empty logs", args{plog.NewLogs()}, true},
{"logs data with empty resource log", args{testdata.GenerateLogsOneEmptyResourceLogs()}, false},
{"logs data with no log records", args{testdata.GenerateLogsNoLogRecords()}, false},
{"logs with one empty log", args{testdata.GenerateLogsOneEmptyLogRecord()}, false},
{"logs with one log", args{testdata.GenerateLogsOneLogRecord()}, false},
{"empty logs", args{ld: plog.NewLogs()}, true},
{"logs with one log", args{ld: testdata.GenerateLogs(1)}, false},
{"logs with lots of log records", args{ld: testdata.GenerateLogs(10)}, false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions exporter/loggingexporter/internal/otlptext/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ func TestMetricsText(t *testing.T) {
empty bool
}{
{"empty metrics", args{pmetric.NewMetrics()}, true},
{"metrics with all types and datapoints", args{testdata.GeneratMetricsAllTypesWithSampleDatapoints()}, false},
{"metrics with all types without datapoints", args{testdata.GenerateMetricsAllTypesEmptyDataPoint()}, false},
{"metrics with all types and datapoints", args{testdata.GenerateMetricsAllTypes()}, false},
{"metrics with all types without datapoints", args{testdata.GenerateMetricsAllTypesEmpty()}, false},
{"metrics with invalid metric types", args{testdata.GenerateMetricsMetricTypeInvalid()}, false},
{"metrics with lots of metrics", args{testdata.GenerateMetrics(10)}, false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion exporter/loggingexporter/internal/otlptext/traces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ func TestTracesText(t *testing.T) {
empty bool
}{
{"empty traces", args{ptrace.NewTraces()}, true},
{"traces with two spans", args{testdata.GenerateTracesTwoSpansSameResource()}, false},
{"traces with one span", args{testdata.GenerateTraces(1)}, false},
{"traces with lots of spans", args{testdata.GenerateTraces(10)}, false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
11 changes: 5 additions & 6 deletions exporter/loggingexporter/logging_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestLoggingTracesExporterNoErrors(t *testing.T) {
assert.NoError(t, err)

assert.NoError(t, lte.ConsumeTraces(context.Background(), ptrace.NewTraces()))
assert.NoError(t, lte.ConsumeTraces(context.Background(), testdata.GenerateTracesTwoSpansSameResourceOneDifferent()))
assert.NoError(t, lte.ConsumeTraces(context.Background(), testdata.GenerateTraces(10)))

assert.NoError(t, lte.Shutdown(context.Background()))
}
Expand All @@ -48,9 +48,10 @@ func TestLoggingMetricsExporterNoErrors(t *testing.T) {
assert.NoError(t, err)

assert.NoError(t, lme.ConsumeMetrics(context.Background(), pmetric.NewMetrics()))
assert.NoError(t, lme.ConsumeMetrics(context.Background(), testdata.GeneratMetricsAllTypesWithSampleDatapoints()))
assert.NoError(t, lme.ConsumeMetrics(context.Background(), testdata.GenerateMetricsAllTypesEmptyDataPoint()))
assert.NoError(t, lme.ConsumeMetrics(context.Background(), testdata.GenerateMetricsAllTypes()))
assert.NoError(t, lme.ConsumeMetrics(context.Background(), testdata.GenerateMetricsAllTypesEmpty()))
assert.NoError(t, lme.ConsumeMetrics(context.Background(), testdata.GenerateMetricsMetricTypeInvalid()))
assert.NoError(t, lme.ConsumeMetrics(context.Background(), testdata.GenerateMetrics(10)))

assert.NoError(t, lme.Shutdown(context.Background()))
}
Expand All @@ -61,9 +62,7 @@ func TestLoggingLogsExporterNoErrors(t *testing.T) {
assert.NoError(t, err)

assert.NoError(t, lle.ConsumeLogs(context.Background(), plog.NewLogs()))
assert.NoError(t, lle.ConsumeLogs(context.Background(), testdata.GenerateLogsOneEmptyResourceLogs()))
assert.NoError(t, lle.ConsumeLogs(context.Background(), testdata.GenerateLogsNoLogRecords()))
assert.NoError(t, lle.ConsumeLogs(context.Background(), testdata.GenerateLogsOneEmptyLogRecord()))
assert.NoError(t, lle.ConsumeLogs(context.Background(), testdata.GenerateLogs(10)))

assert.NoError(t, lle.Shutdown(context.Background()))
}
Expand Down
10 changes: 5 additions & 5 deletions exporter/otlpexporter/otlp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func TestSendTraces(t *testing.T) {
assert.EqualValues(t, 0, rcv.totalItems.Load())

// A trace with 2 spans.
td = testdata.GenerateTracesTwoSpansSameResource()
td = testdata.GenerateTraces(2)

err = exp.ConsumeTraces(context.Background(), td)
assert.NoError(t, err)
Expand Down Expand Up @@ -393,7 +393,7 @@ func TestSendMetrics(t *testing.T) {
assert.EqualValues(t, 0, rcv.totalItems.Load())

// Send two metrics.
md = testdata.GenerateMetricsTwoMetrics()
md = testdata.GenerateMetrics(2)

err = exp.ConsumeMetrics(context.Background(), md)
assert.NoError(t, err)
Expand Down Expand Up @@ -449,7 +449,7 @@ func TestSendTraceDataServerDownAndUp(t *testing.T) {
assert.NoError(t, exp.Start(context.Background(), host))

// A trace with 2 spans.
td := testdata.GenerateTracesTwoSpansSameResource()
td := testdata.GenerateTraces(2)
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
assert.Error(t, exp.ConsumeTraces(ctx, td))
assert.EqualValues(t, context.DeadlineExceeded, ctx.Err())
Expand Down Expand Up @@ -506,7 +506,7 @@ func TestSendTraceDataServerStartWhileRequest(t *testing.T) {
assert.NoError(t, exp.Start(context.Background(), host))

// A trace with 2 spans.
td := testdata.GenerateTracesTwoSpansSameResource()
td := testdata.GenerateTraces(2)
done := make(chan bool, 1)
defer close(done)
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
Expand Down Expand Up @@ -651,7 +651,7 @@ func TestSendLogData(t *testing.T) {
assert.EqualValues(t, 0, rcv.totalItems.Load())

// A request with 2 log entries.
ld = testdata.GenerateLogsTwoLogRecordsSameResource()
ld = testdata.GenerateLogs(2)

err = exp.ConsumeLogs(context.Background(), ld)
assert.NoError(t, err)
Expand Down
Loading

0 comments on commit 1a4361c

Please sign in to comment.