Skip to content

Commit

Permalink
Rename [Trace|Log]Data to Traces|Logs in internal package testdata (#…
Browse files Browse the repository at this point in the history
…3205)

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
  • Loading branch information
bogdandrutu authored May 17, 2021
1 parent 4f9e3c0 commit 2d48457
Show file tree
Hide file tree
Showing 42 changed files with 203 additions and 214 deletions.
2 changes: 1 addition & 1 deletion component/componenttest/shutdown_verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,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.GenerateTraceDataOneSpan()))
require.NoError(t, processor.ConsumeTraces(context.Background(), testdata.GenerateTracesOneSpan()))
}

// Now shutdown the processor.
Expand Down
8 changes: 4 additions & 4 deletions consumer/consumererror/signalerrors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
)

func TestTraces(t *testing.T) {
td := testdata.GenerateTraceDataOneSpan()
td := testdata.GenerateTracesOneSpan()
err := fmt.Errorf("some error")
traceErr := NewTraces(err, td)
assert.Equal(t, err.Error(), traceErr.Error())
Expand All @@ -38,7 +38,7 @@ func TestTraces(t *testing.T) {
}

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

func TestLogs(t *testing.T) {
td := testdata.GenerateLogDataOneLog()
td := testdata.GenerateLogsOneLogRecord()
err := fmt.Errorf("some error")
logsErr := NewLogs(err, td)
assert.Equal(t, err.Error(), logsErr.Error())
Expand All @@ -62,7 +62,7 @@ func TestLogs(t *testing.T) {
}

func TestLogs_Unwrap(t *testing.T) {
td := testdata.GenerateLogDataOneLog()
td := testdata.GenerateLogsOneLogRecord()
var err error = testErrorType{"some error"}
// Wrapping err with error Logs.
logsErr := NewLogs(err, td)
Expand Down
4 changes: 2 additions & 2 deletions consumer/consumertest/sink_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (

func TestTracesSink(t *testing.T) {
sink := new(TracesSink)
td := testdata.GenerateTraceDataOneSpan()
td := testdata.GenerateTracesOneSpan()
want := make([]pdata.Traces, 0, 7)
for i := 0; i < 7; i++ {
require.NoError(t, sink.ConsumeTraces(context.Background(), td))
Expand Down Expand Up @@ -57,7 +57,7 @@ func TestMetricsSink(t *testing.T) {

func TestLogsSink(t *testing.T) {
sink := new(LogsSink)
md := testdata.GenerateLogDataOneLogNoResource()
md := testdata.GenerateLogsOneLogRecord()
want := make([]pdata.Logs, 0, 7)
for i := 0; i < 7; i++ {
require.NoError(t, sink.ConsumeLogs(context.Background(), md))
Expand Down
4 changes: 2 additions & 2 deletions consumer/fanoutconsumer/cloningconsumer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestTracesProcessorCloningMultiplexing(t *testing.T) {
}

tfc := NewTracesCloning(processors)
td := testdata.GenerateTraceDataTwoSpansSameResource()
td := testdata.GenerateTracesTwoSpansSameResource()

var wantSpansCount = 0
for i := 0; i < 2; i++ {
Expand Down Expand Up @@ -124,7 +124,7 @@ func TestLogsProcessorCloningMultiplexing(t *testing.T) {
}

mfc := NewLogsCloning(processors)
ld := testdata.GenerateLogDataOneLog()
ld := testdata.GenerateLogsOneLogRecord()

var wantMetricsCount = 0
for i := 0; i < 2; i++ {
Expand Down
8 changes: 4 additions & 4 deletions consumer/fanoutconsumer/consumer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestTracesProcessorMultiplexing(t *testing.T) {
}

tfc := NewTraces(processors)
td := testdata.GenerateTraceDataOneSpan()
td := testdata.GenerateTracesOneSpan()

var wantSpansCount = 0
for i := 0; i < 2; i++ {
Expand Down Expand Up @@ -68,7 +68,7 @@ func TestTracesProcessorWhenOneErrors(t *testing.T) {
processors[1] = consumertest.NewErr(errors.New("my error"))

tfc := NewTraces(processors)
td := testdata.GenerateTraceDataOneSpan()
td := testdata.GenerateTracesOneSpan()

var wantSpansCount = 0
for i := 0; i < 2; i++ {
Expand Down Expand Up @@ -147,7 +147,7 @@ func TestLogsProcessorMultiplexing(t *testing.T) {
}

lfc := NewLogs(processors)
ld := testdata.GenerateLogDataOneLog()
ld := testdata.GenerateLogsOneLogRecord()

var wantMetricsCount = 0
for i := 0; i < 2; i++ {
Expand Down Expand Up @@ -176,7 +176,7 @@ func TestLogsProcessorWhenOneErrors(t *testing.T) {
processors[1] = consumertest.NewErr(errors.New("my error"))

lfc := NewLogs(processors)
ld := testdata.GenerateLogDataOneLog()
ld := testdata.GenerateLogsOneLogRecord()

var wantMetricsCount = 0
for i := 0; i < 2; i++ {
Expand Down
6 changes: 3 additions & 3 deletions exporter/exporterhelper/logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var (
)

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

logErr := consumererror.NewLogs(errors.New("some error"), pdata.NewLogs())
assert.EqualValues(
Expand Down Expand Up @@ -170,7 +170,7 @@ func checkRecordedMetricsForLogsExporter(t *testing.T, le component.LogsExporter
require.NoError(t, err)
defer doneFn()

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

func generateLogsTraffic(t *testing.T, le component.LogsExporter, numRequests int, wantError error) {
ld := testdata.GenerateLogDataOneLog()
ld := testdata.GenerateLogsOneLogRecord()
ctx, span := trace.StartSpan(context.Background(), fakeLogsParentSpanName, trace.WithSampler(trace.AlwaysSample()))
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 @@ -96,7 +96,7 @@ func TestQueuedRetry_OnError(t *testing.T) {
assert.NoError(t, be.Shutdown(context.Background()))
})

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

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

traceErr := consumererror.NewTraces(errors.New("some error"), pdata.NewTraces())
assert.EqualValues(t, newTracesRequest(context.Background(), pdata.NewTraces(), nil), mr.onError(traceErr))
Expand Down Expand Up @@ -184,7 +184,7 @@ func checkRecordedMetricsForTracesExporter(t *testing.T, te component.TracesExpo
require.NoError(t, err)
defer doneFn()

td := testdata.GenerateTraceDataTwoSpansSameResource()
td := testdata.GenerateTracesTwoSpansSameResource()
const numBatches = 7
for i := 0; i < numBatches; i++ {
require.Equal(t, wantError, te.ConsumeTraces(context.Background(), td))
Expand Down
8 changes: 4 additions & 4 deletions exporter/fileexporter/file_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func TestFileTracesExporter(t *testing.T) {
fe := &fileExporter{file: mf}
require.NotNil(t, fe)

td := testdata.GenerateTraceDataTwoSpansSameResource()
td := testdata.GenerateTracesTwoSpansSameResource()
assert.NoError(t, fe.Start(context.Background(), componenttest.NewNopHost()))
assert.NoError(t, fe.ConsumeTraces(context.Background(), td))
assert.NoError(t, fe.Shutdown(context.Background()))
Expand All @@ -53,7 +53,7 @@ func TestFileTracesExporterError(t *testing.T) {
fe := &fileExporter{file: mf}
require.NotNil(t, fe)

td := testdata.GenerateTraceDataTwoSpansSameResource()
td := testdata.GenerateTracesTwoSpansSameResource()
assert.NoError(t, fe.Start(context.Background(), componenttest.NewNopHost()))
assert.Error(t, fe.ConsumeTraces(context.Background(), td))
assert.NoError(t, fe.Shutdown(context.Background()))
Expand Down Expand Up @@ -93,7 +93,7 @@ func TestFileLogsExporter(t *testing.T) {
fe := &fileExporter{file: mf}
require.NotNil(t, fe)

otlp := testdata.GenerateLogDataTwoLogsSameResource()
otlp := testdata.GenerateLogsTwoLogRecordsSameResource()
assert.NoError(t, fe.Start(context.Background(), componenttest.NewNopHost()))
assert.NoError(t, fe.ConsumeLogs(context.Background(), otlp))
assert.NoError(t, fe.Shutdown(context.Background()))
Expand All @@ -111,7 +111,7 @@ func TestFileLogsExporterErrors(t *testing.T) {
fe := &fileExporter{file: mf}
require.NotNil(t, fe)

otlp := testdata.GenerateLogDataTwoLogsSameResource()
otlp := testdata.GenerateLogsTwoLogRecordsSameResource()
assert.NoError(t, fe.Start(context.Background(), componenttest.NewNopHost()))
assert.Error(t, fe.ConsumeLogs(context.Background(), otlp))
assert.NoError(t, fe.Shutdown(context.Background()))
Expand Down
2 changes: 1 addition & 1 deletion exporter/jaegerexporter/exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func TestNew(t *testing.T) {
}

// This is expected to fail.
err = got.ConsumeTraces(context.Background(), testdata.GenerateTraceDataNoLibraries())
err = got.ConsumeTraces(context.Background(), testdata.GenerateTracesNoLibraries())
assert.Error(t, err)
})
}
Expand Down
12 changes: 6 additions & 6 deletions exporter/kafkaexporter/kafka_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func TestTraceDataPusher(t *testing.T) {
t.Cleanup(func() {
require.NoError(t, p.Close(context.Background()))
})
err := p.traceDataPusher(context.Background(), testdata.GenerateTraceDataTwoSpansSameResource())
err := p.traceDataPusher(context.Background(), testdata.GenerateTracesTwoSpansSameResource())
require.NoError(t, err)
}

Expand All @@ -147,7 +147,7 @@ func TestTraceDataPusher_err(t *testing.T) {
t.Cleanup(func() {
require.NoError(t, p.Close(context.Background()))
})
td := testdata.GenerateTraceDataTwoSpansSameResource()
td := testdata.GenerateTracesTwoSpansSameResource()
err := p.traceDataPusher(context.Background(), td)
assert.EqualError(t, err, expErr.Error())
}
Expand All @@ -158,7 +158,7 @@ func TestTraceDataPusher_marshal_error(t *testing.T) {
marshaler: &tracesErrorMarshaler{err: expErr},
logger: zap.NewNop(),
}
td := testdata.GenerateTraceDataTwoSpansSameResource()
td := testdata.GenerateTracesTwoSpansSameResource()
err := p.traceDataPusher(context.Background(), td)
require.Error(t, err)
assert.Contains(t, err.Error(), expErr.Error())
Expand Down Expand Up @@ -223,7 +223,7 @@ func TestLogsDataPusher(t *testing.T) {
t.Cleanup(func() {
require.NoError(t, p.Close(context.Background()))
})
err := p.logsDataPusher(context.Background(), testdata.GenerateLogDataOneLog())
err := p.logsDataPusher(context.Background(), testdata.GenerateLogsOneLogRecord())
require.NoError(t, err)
}

Expand All @@ -241,7 +241,7 @@ func TestLogsDataPusher_err(t *testing.T) {
t.Cleanup(func() {
require.NoError(t, p.Close(context.Background()))
})
ld := testdata.GenerateLogDataOneLog()
ld := testdata.GenerateLogsOneLogRecord()
err := p.logsDataPusher(context.Background(), ld)
assert.EqualError(t, err, expErr.Error())
}
Expand All @@ -252,7 +252,7 @@ func TestLogsDataPusher_marshal_error(t *testing.T) {
marshaler: &logsErrorMarshaler{err: expErr},
logger: zap.NewNop(),
}
ld := testdata.GenerateLogDataOneLog()
ld := testdata.GenerateLogsOneLogRecord()
err := p.logsDataPusher(context.Background(), ld)
require.Error(t, err)
assert.Contains(t, err.Error(), expErr.Error())
Expand Down
4 changes: 2 additions & 2 deletions exporter/kafkaexporter/otlp_marshaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
)

func TestOTLPTracesPbMarshaler(t *testing.T) {
td := testdata.GenerateTraceDataTwoSpansSameResource()
td := testdata.GenerateTracesTwoSpansSameResource()
m := otlpTracesPbMarshaler{}
assert.Equal(t, "otlp_proto", m.Encoding())
messages, err := m.Marshal(td)
Expand All @@ -49,7 +49,7 @@ func TestOTLPMetricsPbMarshaler(t *testing.T) {
}

func TestOTLPLogsPbMarshaler(t *testing.T) {
ld := testdata.GenerateLogDataOneLog()
ld := testdata.GenerateLogsOneLogRecord()
m := otlpLogsPbMarshaler{}
assert.Equal(t, "otlp_proto", m.Encoding())
messages, err := m.Marshal(ld)
Expand Down
8 changes: 4 additions & 4 deletions exporter/loggingexporter/logging_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestLoggingTracesExporterNoErrors(t *testing.T) {
assert.NoError(t, err)

assert.NoError(t, lte.ConsumeTraces(context.Background(), pdata.NewTraces()))
assert.NoError(t, lte.ConsumeTraces(context.Background(), testdata.GenerateTraceDataTwoSpansSameResourceOneDifferent()))
assert.NoError(t, lte.ConsumeTraces(context.Background(), testdata.GenerateTracesTwoSpansSameResourceOneDifferent()))

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

assert.NoError(t, lle.ConsumeLogs(context.Background(), pdata.NewLogs()))
assert.NoError(t, lle.ConsumeLogs(context.Background(), testdata.GenerateLogDataOneEmptyResourceLogs()))
assert.NoError(t, lle.ConsumeLogs(context.Background(), testdata.GenerateLogDataNoLogRecords()))
assert.NoError(t, lle.ConsumeLogs(context.Background(), testdata.GenerateLogDataOneEmptyLogs()))
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.Shutdown(context.Background()))
}
6 changes: 3 additions & 3 deletions exporter/opencensusexporter/opencensus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func TestSendTraces(t *testing.T) {
assert.NoError(t, exp.Shutdown(context.Background()))
})

td := testdata.GenerateTraceDataOneSpan()
td := testdata.GenerateTracesOneSpan()
assert.NoError(t, exp.ConsumeTraces(context.Background(), td))
assert.Eventually(t, func() bool {
return len(sink.AllTraces()) == 1
Expand Down Expand Up @@ -105,7 +105,7 @@ func TestSendTraces_NoBackend(t *testing.T) {
assert.NoError(t, exp.Shutdown(context.Background()))
})

td := testdata.GenerateTraceDataOneSpan()
td := testdata.GenerateTracesOneSpan()
for i := 0; i < 10000; i++ {
assert.Error(t, exp.ConsumeTraces(context.Background(), td))
}
Expand All @@ -127,7 +127,7 @@ func TestSendTraces_AfterStop(t *testing.T) {
require.NoError(t, exp.Start(context.Background(), host))
assert.NoError(t, exp.Shutdown(context.Background()))

td := testdata.GenerateTraceDataOneSpan()
td := testdata.GenerateTracesOneSpan()
assert.Error(t, exp.ConsumeTraces(context.Background(), td))
}

Expand Down
8 changes: 4 additions & 4 deletions exporter/otlpexporter/otlp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func TestSendTraces(t *testing.T) {
assert.EqualValues(t, 0, atomic.LoadInt32(&rcv.totalItems))

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

expectedOTLPReq := internal.TracesToOtlp(td.Clone().InternalRep())

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

// A trace with 2 spans.
td := testdata.GenerateTraceDataTwoSpansSameResource()
td := testdata.GenerateTracesTwoSpansSameResource()
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 @@ -418,7 +418,7 @@ func TestSendTraceDataServerStartWhileRequest(t *testing.T) {
assert.NoError(t, exp.Start(context.Background(), host))

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

// A request with 2 log entries.
td = testdata.GenerateLogDataTwoLogsSameResource()
td = testdata.GenerateLogsTwoLogRecordsSameResource()
expectedOTLPReq := internal.LogsToOtlp(td.Clone().InternalRep())

err = exp.ConsumeLogs(context.Background(), td)
Expand Down
Loading

0 comments on commit 2d48457

Please sign in to comment.