From 5c09feb45b63791ca574fb09e976fbf99a6c5b88 Mon Sep 17 00:00:00 2001 From: Curtis Robert Date: Thu, 4 Apr 2024 16:06:38 -0700 Subject: [PATCH 1/2] [chore][receiver/snowflake] Enable goleak checks --- receiver/snowflakereceiver/client_test.go | 5 +++-- receiver/snowflakereceiver/package_test.go | 14 ++++++++++++++ receiver/snowflakereceiver/scraper_test.go | 1 + 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 receiver/snowflakereceiver/package_test.go diff --git a/receiver/snowflakereceiver/client_test.go b/receiver/snowflakereceiver/client_test.go index 743c9b817eee..30d43c724941 100644 --- a/receiver/snowflakereceiver/client_test.go +++ b/receiver/snowflakereceiver/client_test.go @@ -18,7 +18,7 @@ import ( ) func TestDefaultClientCreation(t *testing.T) { - _, err := newDefaultClient(componenttest.NewNopTelemetrySettings(), Config{ + c, err := newDefaultClient(componenttest.NewNopTelemetrySettings(), Config{ Username: "testuser", Password: "testPassword", Account: "testAccount", @@ -27,7 +27,8 @@ func TestDefaultClientCreation(t *testing.T) { Database: "testDatabase", Role: "testRole", }) - assert.Equal(t, nil, err) + assert.NoError(t, err) + assert.NoError(t, c.client.Close()) } // test query wrapper diff --git a/receiver/snowflakereceiver/package_test.go b/receiver/snowflakereceiver/package_test.go new file mode 100644 index 000000000000..d82966d01b74 --- /dev/null +++ b/receiver/snowflakereceiver/package_test.go @@ -0,0 +1,14 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package snowflakereceiver + +import ( + "testing" + + "go.uber.org/goleak" +) + +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} diff --git a/receiver/snowflakereceiver/scraper_test.go b/receiver/snowflakereceiver/scraper_test.go index f07ec6e36ed9..5d7f4b62c523 100644 --- a/receiver/snowflakereceiver/scraper_test.go +++ b/receiver/snowflakereceiver/scraper_test.go @@ -72,6 +72,7 @@ func TestStart(t *testing.T) { scraper := newSnowflakeMetricsScraper(receivertest.NewNopCreateSettings(), cfg) err := scraper.start(context.Background(), componenttest.NewNopHost()) require.NoError(t, err, "Problem starting scraper") + require.NoError(t, scraper.shutdown(context.Background())) } // wrapper type for convenience From de4fefc85ce027e60fbeb6b9b25d383b758b7b8b Mon Sep 17 00:00:00 2001 From: Curtis Robert Date: Thu, 4 Apr 2024 16:25:55 -0700 Subject: [PATCH 2/2] Add goleak ignore --- receiver/snowflakereceiver/package_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/receiver/snowflakereceiver/package_test.go b/receiver/snowflakereceiver/package_test.go index d82966d01b74..354238689a68 100644 --- a/receiver/snowflakereceiver/package_test.go +++ b/receiver/snowflakereceiver/package_test.go @@ -9,6 +9,7 @@ import ( "go.uber.org/goleak" ) +// Regarding the godbus/dbus ignore: see https://github.com/99designs/keyring/issues/103 func TestMain(m *testing.M) { - goleak.VerifyTestMain(m) + goleak.VerifyTestMain(m, goleak.IgnoreAnyFunction("github.com/godbus/dbus.(*Conn).inWorker")) }