Skip to content

Commit 02d4073

Browse files
crobert-1XinRanZhAWS
authored andcommitted
[chore][extension/bearertokenauth] Enable goleak check (open-telemetry#31154)
**Description:** <Describe what has changed.> <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> This adds `goleak` checks on the `bearertokenauthextension` extension to help ensure no goroutines are being leaked. This is a test only change. **Link to tracking Issue:** <Issue number if applicable> open-telemetry#30438 **Testing:** <Describe what testing was performed and which tests were added.> All existing tests are passing as well as added `goleak` check.
1 parent 8f2beb7 commit 02d4073

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

extension/bearertokenauthextension/bearertokenauth_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ func TestBearerTokenFileContentUpdate(t *testing.T) {
160160

161161
assert.Nil(t, bauth.Start(context.Background(), componenttest.NewNopHost()))
162162
assert.Error(t, bauth.Start(context.Background(), componenttest.NewNopHost()))
163+
defer func() { assert.NoError(t, bauth.Shutdown(context.Background())) }()
163164

164165
token, err := os.ReadFile(bauth.filename)
165166
assert.NoError(t, err)

extension/bearertokenauthextension/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ require (
1212
go.opentelemetry.io/collector/extension/auth v0.94.1
1313
go.opentelemetry.io/otel/metric v1.23.0
1414
go.opentelemetry.io/otel/trace v1.23.0
15+
go.uber.org/goleak v1.3.0
1516
go.uber.org/zap v1.26.0
1617
google.golang.org/grpc v1.61.0
1718
)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright The OpenTelemetry Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package bearertokenauthextension
5+
6+
import (
7+
"testing"
8+
9+
"go.uber.org/goleak"
10+
)
11+
12+
func TestMain(m *testing.M) {
13+
goleak.VerifyTestMain(m)
14+
}

0 commit comments

Comments
 (0)