Skip to content

Commit

Permalink
[chore][receiver/purefb] Enable goleak check (#32184)
Browse files Browse the repository at this point in the history
This change enables `goleak` checks on the Pure Storage FlashBlade
receiver to help ensure no goroutines are being leaked. This is a test
only change as a test was missing a shutdown call.

This looks like I deleted a test, but the two tests were identical,
other than a missing shutdown call. Once the missing call was added they
were identical, so I decided to delete one. I also consolidated err
checking to remove the `err` variable and directly check the result of
the `Start` and `Shutdown` methods.

**Link to tracking Issue:** #30438
  • Loading branch information
crobert-1 authored Apr 5, 2024
1 parent 70dada2 commit 9f3db69
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 23 deletions.
26 changes: 3 additions & 23 deletions receiver/purefbreceiver/metrics_receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,15 @@ import (
"go.opentelemetry.io/collector/receiver/receivertest"
)

func TestStart(t *testing.T) {
func TestStartAndShutdown(t *testing.T) {
// prepare
cfg, ok := createDefaultConfig().(*Config)
require.True(t, ok)

sink := &consumertest.MetricsSink{}
recv := newReceiver(cfg, receivertest.NewNopCreateSettings(), sink)

// test
err := recv.Start(context.Background(), componenttest.NewNopHost())

// verify
assert.NoError(t, err)
}

func TestShutdown(t *testing.T) {
// prepare
cfg, ok := createDefaultConfig().(*Config)
require.True(t, ok)

sink := &consumertest.MetricsSink{}
recv := newReceiver(cfg, receivertest.NewNopCreateSettings(), sink)

err := recv.Start(context.Background(), componenttest.NewNopHost())
require.NoError(t, err)

// test
err = recv.Shutdown(context.Background())

// verify
assert.NoError(t, err)
assert.NoError(t, recv.Start(context.Background(), componenttest.NewNopHost()))
assert.NoError(t, recv.Shutdown(context.Background()))
}
15 changes: 15 additions & 0 deletions receiver/purefbreceiver/package_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package purefbreceiver

import (
"testing"

"go.uber.org/goleak"
)

// See https://github.com/census-instrumentation/opencensus-go/issues/1191 for more information on opencensus ignore.
func TestMain(m *testing.M) {
goleak.VerifyTestMain(m, goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"))
}

0 comments on commit 9f3db69

Please sign in to comment.