From 1bb79238bb495395ca77a3675280766fc5122894 Mon Sep 17 00:00:00 2001 From: Curtis Robert Date: Wed, 7 Feb 2024 07:51:31 -0800 Subject: [PATCH] [chore][pkg/stanza/operator/helper] Enable goleak check (#31092) This enables `goleak` in the `pkg/stanza/operator/helper` package to help ensure no goroutines are leaking. This is a test only change, some tests were simply missing `Stop` calls. **Link to tracking Issue:** #30438 --- pkg/stanza/operator/helper/ip_resolver_test.go | 2 ++ pkg/stanza/operator/helper/package_test.go | 14 ++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 pkg/stanza/operator/helper/package_test.go diff --git a/pkg/stanza/operator/helper/ip_resolver_test.go b/pkg/stanza/operator/helper/ip_resolver_test.go index d660810817bb..7f4c82eec3d0 100644 --- a/pkg/stanza/operator/helper/ip_resolver_test.go +++ b/pkg/stanza/operator/helper/ip_resolver_test.go @@ -18,6 +18,7 @@ func TestIPResolverCacheLookup(t *testing.T) { } require.Equal(t, "definitely invalid hostname", resolver.GetHostFromIP("127.0.0.1")) + resolver.Stop() } func TestIPResolverCacheInvalidation(t *testing.T) { @@ -45,6 +46,7 @@ func TestIPResolver100Hits(t *testing.T) { for i := 0; i < 100; i++ { require.Equal(t, "definitely invalid hostname", resolver.GetHostFromIP("127.0.0.1")) } + resolver.Stop() } func TestIPResolverWithMultipleStops(_ *testing.T) { diff --git a/pkg/stanza/operator/helper/package_test.go b/pkg/stanza/operator/helper/package_test.go new file mode 100644 index 000000000000..c41dd2a22337 --- /dev/null +++ b/pkg/stanza/operator/helper/package_test.go @@ -0,0 +1,14 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package helper + +import ( + "testing" + + "go.uber.org/goleak" +) + +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +}