Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore][receiver/nsxt] Enable goleak check #32197

Merged
merged 1 commit into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions receiver/nsxtreceiver/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ func TestNewClientFailureToParse(t *testing.T) {

func TestTransportNodes(t *testing.T) {
nsxMock := mockServer(t)
defer nsxMock.Close()

client, err := newClient(&Config{
ClientConfig: confighttp.ClientConfig{
Endpoint: nsxMock.URL,
Expand All @@ -49,6 +51,8 @@ func TestTransportNodes(t *testing.T) {

func TestClusterNodes(t *testing.T) {
nsxMock := mockServer(t)
defer nsxMock.Close()

client, err := newClient(&Config{
ClientConfig: confighttp.ClientConfig{
Endpoint: nsxMock.URL,
Expand All @@ -62,6 +66,8 @@ func TestClusterNodes(t *testing.T) {

func TestClusterNodeInterface(t *testing.T) {
nsxMock := mockServer(t)
defer nsxMock.Close()

client, err := newClient(&Config{
ClientConfig: confighttp.ClientConfig{
Endpoint: nsxMock.URL,
Expand All @@ -75,6 +81,8 @@ func TestClusterNodeInterface(t *testing.T) {

func TestTransportNodeInterface(t *testing.T) {
nsxMock := mockServer(t)
defer nsxMock.Close()

client, err := newClient(&Config{
ClientConfig: confighttp.ClientConfig{
Endpoint: nsxMock.URL,
Expand All @@ -88,6 +96,8 @@ func TestTransportNodeInterface(t *testing.T) {

func TestTransportNodeStatus(t *testing.T) {
nsxMock := mockServer(t)
defer nsxMock.Close()

client, err := newClient(&Config{
ClientConfig: confighttp.ClientConfig{
Endpoint: nsxMock.URL,
Expand All @@ -101,6 +111,8 @@ func TestTransportNodeStatus(t *testing.T) {

func TestClusterNodeStatus(t *testing.T) {
nsxMock := mockServer(t)
defer nsxMock.Close()

client, err := newClient(&Config{
ClientConfig: confighttp.ClientConfig{
Endpoint: nsxMock.URL,
Expand All @@ -114,6 +126,8 @@ func TestClusterNodeStatus(t *testing.T) {

func TestTransportNodeInterfaceStatus(t *testing.T) {
nsxMock := mockServer(t)
defer nsxMock.Close()

client, err := newClient(&Config{
ClientConfig: confighttp.ClientConfig{
Endpoint: nsxMock.URL,
Expand All @@ -127,6 +141,8 @@ func TestTransportNodeInterfaceStatus(t *testing.T) {

func TestManagerNodeInterfaceStatus(t *testing.T) {
nsxMock := mockServer(t)
defer nsxMock.Close()

client, err := newClient(&Config{
ClientConfig: confighttp.ClientConfig{
Endpoint: nsxMock.URL,
Expand All @@ -140,6 +156,8 @@ func TestManagerNodeInterfaceStatus(t *testing.T) {

func TestDoRequestBadUrl(t *testing.T) {
nsxMock := mockServer(t)
defer nsxMock.Close()

client, err := newClient(&Config{
ClientConfig: confighttp.ClientConfig{
Endpoint: nsxMock.URL,
Expand All @@ -153,6 +171,8 @@ func TestDoRequestBadUrl(t *testing.T) {

func TestPermissionDenied_ClusterNodes(t *testing.T) {
nsxMock := mockServer(t)
defer nsxMock.Close()

client, err := newClient(&Config{
Password: badPassword,
ClientConfig: confighttp.ClientConfig{
Expand All @@ -167,6 +187,8 @@ func TestPermissionDenied_ClusterNodes(t *testing.T) {

func TestPermissionDenied_Interfaces(t *testing.T) {
nsxMock := mockServer(t)
defer nsxMock.Close()

client, err := newClient(&Config{
Password: badPassword,
ClientConfig: confighttp.ClientConfig{
Expand All @@ -181,6 +203,8 @@ func TestPermissionDenied_Interfaces(t *testing.T) {

func TestPermissionDenied_InterfaceStatus(t *testing.T) {
nsxMock := mockServer(t)
defer nsxMock.Close()

client, err := newClient(&Config{
Password: badPassword,
ClientConfig: confighttp.ClientConfig{
Expand All @@ -195,6 +219,8 @@ func TestPermissionDenied_InterfaceStatus(t *testing.T) {

func TestPermissionDenied_NodeStatus(t *testing.T) {
nsxMock := mockServer(t)
defer nsxMock.Close()

client, err := newClient(&Config{
Password: badPassword,
ClientConfig: confighttp.ClientConfig{
Expand All @@ -209,6 +235,8 @@ func TestPermissionDenied_NodeStatus(t *testing.T) {

func TestPermissionDenied_TransportNodes(t *testing.T) {
nsxMock := mockServer(t)
defer nsxMock.Close()

client, err := newClient(&Config{
Password: badPassword,
ClientConfig: confighttp.ClientConfig{
Expand All @@ -223,6 +251,8 @@ func TestPermissionDenied_TransportNodes(t *testing.T) {

func TestInternalServerError(t *testing.T) {
nsxMock := mockServer(t)
defer nsxMock.Close()

client, err := newClient(&Config{
Username: user500,
ClientConfig: confighttp.ClientConfig{
Expand Down
14 changes: 14 additions & 0 deletions receiver/nsxtreceiver/package_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package nsxtreceiver

import (
"testing"

"go.uber.org/goleak"
)

func TestMain(m *testing.M) {
goleak.VerifyTestMain(m)
}
2 changes: 2 additions & 0 deletions receiver/nsxtreceiver/scraper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ func TestScrapeClusterNodeErrors(t *testing.T) {

func TestStartClientAlreadySet(t *testing.T) {
mockClient := mockServer(t)
defer mockClient.Close()

scraper := newScraper(
&Config{
MetricsBuilderConfig: metadata.DefaultMetricsBuilderConfig(),
Expand Down