Skip to content

Commit

Permalink
[chore] add goleak tests for splunkhecreceiver (open-telemetry#31619)
Browse files Browse the repository at this point in the history
  • Loading branch information
atoulme authored and XinRanZhAWS committed Mar 13, 2024
1 parent ff6ec10 commit 7fd540d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
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.20240306115632-b2693620eff6
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"))
}
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

0 comments on commit 7fd540d

Please sign in to comment.