diff --git a/internal/component/database_observability/mysql/collector/connection_info_test.go b/internal/component/database_observability/mysql/collector/connection_info_test.go index 173938b016..7f5ed4148d 100644 --- a/internal/component/database_observability/mysql/collector/connection_info_test.go +++ b/internal/component/database_observability/mysql/collector/connection_info_test.go @@ -9,9 +9,12 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/testutil" "github.com/stretchr/testify/require" + "go.uber.org/goleak" ) func TestConnectionInfoRun(t *testing.T) { + defer goleak.VerifyNone(t) + const baseExpectedMetrics = ` # HELP connection_info Information about the connection # TYPE connection_info gauge diff --git a/internal/component/database_observability/mysql/collector/query_sample_test.go b/internal/component/database_observability/mysql/collector/query_sample_test.go index b616ad0edf..4682707458 100644 --- a/internal/component/database_observability/mysql/collector/query_sample_test.go +++ b/internal/component/database_observability/mysql/collector/query_sample_test.go @@ -8,6 +8,7 @@ import ( loki_fake "github.com/grafana/alloy/internal/component/common/loki/client/fake" "github.com/prometheus/common/model" + "go.uber.org/goleak" "github.com/DATA-DOG/go-sqlmock" "github.com/go-kit/log" @@ -15,6 +16,8 @@ import ( ) func TestQuerySampleRun(t *testing.T) { + defer goleak.VerifyNone(t) + db, mock, err := sqlmock.New(sqlmock.QueryMatcherOption(sqlmock.QueryMatcherEqual)) require.NoError(t, err) defer db.Close() diff --git a/internal/component/database_observability/mysql/collector/schema_table_test.go b/internal/component/database_observability/mysql/collector/schema_table_test.go index c6fe296074..d8c17a9bf4 100644 --- a/internal/component/database_observability/mysql/collector/schema_table_test.go +++ b/internal/component/database_observability/mysql/collector/schema_table_test.go @@ -11,9 +11,14 @@ import ( loki_fake "github.com/grafana/alloy/internal/component/common/loki/client/fake" "github.com/prometheus/common/model" "github.com/stretchr/testify/require" + "go.uber.org/goleak" ) func TestSchemaTableRun(t *testing.T) { + // The goroutine which deletes expired entries runs indefinitely, + // see https://github.com/hashicorp/golang-lru/blob/v2.0.7/expirable/expirable_lru.go#L79-L80 + defer goleak.VerifyNone(t, goleak.IgnoreTopFunction("github.com/hashicorp/golang-lru/v2/expirable.NewLRU[...].func1")) + db, mock, err := sqlmock.New(sqlmock.QueryMatcherOption(sqlmock.QueryMatcherEqual)) require.NoError(t, err) defer db.Close()