Skip to content

Commit

Permalink
Round 2: Adapt to randomly generated nop component names in unit tests (
Browse files Browse the repository at this point in the history
#31659)

Follow-up to
#31640

I didn't realize the contrib test stopped after the first failure, so
there were a few more failures for
open-telemetry/opentelemetry-collector#9637.

I verified that this passes the contrib-tests check for the core repo
locally, so this should be the rest of them.

For the splunkhec exporter, the exporter actually uses `ID.String()`:
https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/4c5b5e934484ae3084565abbd3746a98e7f27721/exporter/splunkhecexporter/client.go#L71

The filelog receiver was assuming that `NewNopCreateSettings` returned
the same ID, so I re-used the create settings in the test.

**Link to tracking Issue:**

Blocking
open-telemetry/opentelemetry-collector#9637

@dmitryax @Aneurysm9 @codeboten
  • Loading branch information
dashpole committed Mar 11, 2024
1 parent 451159e commit 9c44670
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion exporter/splunkhecexporter/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1397,7 +1397,7 @@ func TestHeartbeatStartupFailed(t *testing.T) {
assert.NoError(t, err)
assert.EqualError(t,
exporter.Start(context.Background(), componenttest.NewNopHost()),
fmt.Sprintf("%s: heartbeat on startup failed: HTTP 403 \"Forbidden\"", params.ID.Type()),
fmt.Sprintf("%s: heartbeat on startup failed: HTTP 403 \"Forbidden\"", params.ID.String()),
)
assert.NoError(t, exporter.Shutdown(context.Background()))
}
Expand Down
7 changes: 4 additions & 3 deletions receiver/filelogreceiver/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ func TestStorage(t *testing.T) {
ext := storagetest.NewFileBackedStorageExtension("test", storageDir)
host := storagetest.NewStorageHost().WithExtension(ext.ID, ext)
sink := new(consumertest.LogsSink)
rcvr, err := f.CreateLogsReceiver(ctx, receivertest.NewNopCreateSettings(), cfg, sink)
set := receivertest.NewNopCreateSettings()
rcvr, err := f.CreateLogsReceiver(ctx, set, cfg, sink)
require.NoError(t, err, "failed to create receiver")
require.NoError(t, rcvr.Start(ctx, host))

Expand Down Expand Up @@ -72,7 +73,7 @@ func TestStorage(t *testing.T) {
// Start the components again
ext = storagetest.NewFileBackedStorageExtension("test", storageDir)
host = storagetest.NewStorageHost().WithExtension(ext.ID, ext)
rcvr, err = f.CreateLogsReceiver(ctx, receivertest.NewNopCreateSettings(), cfg, sink)
rcvr, err = f.CreateLogsReceiver(ctx, set, cfg, sink)
require.NoError(t, err, "failed to create receiver")
require.NoError(t, rcvr.Start(ctx, host))
sink.Reset()
Expand Down Expand Up @@ -117,7 +118,7 @@ func TestStorage(t *testing.T) {
// Start the components again
ext = storagetest.NewFileBackedStorageExtension("test", storageDir)
host = storagetest.NewStorageHost().WithExtension(ext.ID, ext)
rcvr, err = f.CreateLogsReceiver(ctx, receivertest.NewNopCreateSettings(), cfg, sink)
rcvr, err = f.CreateLogsReceiver(ctx, set, cfg, sink)
require.NoError(t, err, "failed to create receiver")
require.NoError(t, rcvr.Start(ctx, host))
sink.Reset()
Expand Down

0 comments on commit 9c44670

Please sign in to comment.