Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore] add goleak tests for splunkhecreceiver #31619

Merged
merged 1 commit into from Mar 6, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions receiver/splunkhecreceiver/go.mod
Expand Up @@ -22,6 +22,7 @@ require (
go.opentelemetry.io/collector/semconv v0.96.1-0.20240305232712-5a68058e0e3a
go.opentelemetry.io/otel/metric v1.24.0
go.opentelemetry.io/otel/trace v1.24.0
go.uber.org/goleak v1.3.0
go.uber.org/zap v1.27.0
)

Expand Down
14 changes: 14 additions & 0 deletions receiver/splunkhecreceiver/package_test.go
@@ -0,0 +1,14 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package splunkhecreceiver

import (
"testing"

"go.uber.org/goleak"
)

func TestMain(m *testing.M) {
goleak.VerifyTestMain(m, goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this still need the ignore for opencensus?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, as this receiver has some opencensus metrics related to heartbeat.

}
15 changes: 15 additions & 0 deletions receiver/splunkhecreceiver/receiver_test.go
Expand Up @@ -461,6 +461,9 @@ func Test_splunkhecReceiver_TLS(t *testing.T) {

require.NoError(t, r.Start(context.Background(), componenttest.NewNopHost()), "should not have failed to start log reception")
require.NoError(t, r.Start(context.Background(), componenttest.NewNopHost()), "should not fail to start log on second Start call")
defer func() {
require.NoError(t, r.Shutdown(context.Background()))
}()

// If there are errors reported through ReportStatus this will retrieve it.
<-time.After(500 * time.Millisecond)
Expand Down Expand Up @@ -627,6 +630,9 @@ func Test_splunkhecReceiver_AccessTokenPassthrough(t *testing.T) {
if tt.metric {
exporter, err := factory.CreateMetricsExporter(context.Background(), exportertest.NewNopCreateSettings(), exporterConfig)
assert.NoError(t, exporter.Start(context.Background(), nil))
defer func() {
require.NoError(t, exporter.Shutdown(context.Background()))
}()
assert.NoError(t, err)
rcv, err := newMetricsReceiver(receivertest.NewNopCreateSettings(), *config, exporter)
assert.NoError(t, err)
Expand All @@ -640,6 +646,9 @@ func Test_splunkhecReceiver_AccessTokenPassthrough(t *testing.T) {
} else {
exporter, err := factory.CreateLogsExporter(context.Background(), exportertest.NewNopCreateSettings(), exporterConfig)
assert.NoError(t, exporter.Start(context.Background(), nil))
defer func() {
require.NoError(t, exporter.Shutdown(context.Background()))
}()
assert.NoError(t, err)
rcv, err := newLogsReceiver(receivertest.NewNopCreateSettings(), *config, exporter)
assert.NoError(t, err)
Expand Down Expand Up @@ -707,6 +716,9 @@ func Test_Logs_splunkhecReceiver_IndexSourceTypePassthrough(t *testing.T) {
exporter, err := factory.CreateLogsExporter(context.Background(), exportertest.NewNopCreateSettings(), exporterConfig)
assert.NoError(t, exporter.Start(context.Background(), nil))
assert.NoError(t, err)
defer func() {
require.NoError(t, exporter.Shutdown(context.Background()))
}()
rcv, err := newLogsReceiver(receivertest.NewNopCreateSettings(), *cfg, exporter)
assert.NoError(t, err)

Expand Down Expand Up @@ -804,6 +816,9 @@ func Test_Metrics_splunkhecReceiver_IndexSourceTypePassthrough(t *testing.T) {

exporter, err := factory.CreateMetricsExporter(context.Background(), exportertest.NewNopCreateSettings(), exporterConfig)
assert.NoError(t, exporter.Start(context.Background(), nil))
defer func() {
require.NoError(t, exporter.Shutdown(context.Background()))
}()
assert.NoError(t, err)
rcv, err := newMetricsReceiver(receivertest.NewNopCreateSettings(), *cfg, exporter)
assert.NoError(t, err)
Expand Down