From 420bdba2c55e5cbddafcfc704172a171a2e1e1f4 Mon Sep 17 00:00:00 2001 From: Curtis Robert Date: Fri, 22 Mar 2024 14:47:57 -0700 Subject: [PATCH] [chore][receiver/k8sevent] Enable goleak check (#31917) **Description:** Enable goleak check to help ensure no goroutines are being leaked. This is a test only change, a test was missing a shutdown call. **Link to tracking Issue:** https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/30438 **Testing:** Existing tests are passing, as well as added goleak check. --- receiver/k8seventsreceiver/factory_test.go | 1 + receiver/k8seventsreceiver/go.mod | 1 + receiver/k8seventsreceiver/package_test.go | 14 ++++++++++++++ 3 files changed, 16 insertions(+) create mode 100644 receiver/k8seventsreceiver/package_test.go diff --git a/receiver/k8seventsreceiver/factory_test.go b/receiver/k8seventsreceiver/factory_test.go index 8cf5dca06623..bc347a606c28 100644 --- a/receiver/k8seventsreceiver/factory_test.go +++ b/receiver/k8seventsreceiver/factory_test.go @@ -59,4 +59,5 @@ func TestCreateReceiver(t *testing.T) { require.NoError(t, err) err = r.Start(context.Background(), componenttest.NewNopHost()) assert.NoError(t, err) + require.NoError(t, r.Shutdown(context.Background())) } diff --git a/receiver/k8seventsreceiver/go.mod b/receiver/k8seventsreceiver/go.mod index d7ffde84c79b..c34bef4995ce 100644 --- a/receiver/k8seventsreceiver/go.mod +++ b/receiver/k8seventsreceiver/go.mod @@ -13,6 +13,7 @@ require ( go.opentelemetry.io/collector/semconv v0.96.1-0.20240315172937-3b5aee0c7a16 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 k8s.io/api v0.29.3 k8s.io/apimachinery v0.29.3 diff --git a/receiver/k8seventsreceiver/package_test.go b/receiver/k8seventsreceiver/package_test.go new file mode 100644 index 000000000000..b772c9a283b7 --- /dev/null +++ b/receiver/k8seventsreceiver/package_test.go @@ -0,0 +1,14 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package k8seventsreceiver + +import ( + "testing" + + "go.uber.org/goleak" +) + +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +}