Skip to content

Commit

Permalink
[chore][receiver/googlecloudspannerreceiver] Enable goleak checks (op…
Browse files Browse the repository at this point in the history
…en-telemetry#32307)

This is a test only change that enables `goleak` checks on some of the
internal packages of the Google Cloud Spanner receiver to help ensure no
goroutines are leaking. Some tests were missing shutdown calls so those
have been added.

**Link to tracking Issue:** open-telemetry#30438

All existing tests are passing, as well as added `goleak` checks.
  • Loading branch information
crobert-1 authored Apr 12, 2024
1 parent 34a3842 commit 4c30822
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 0 deletions.
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 filter

import (
"testing"

"go.uber.org/goleak"
)

func TestMain(m *testing.M) {
goleak.VerifyTestMain(m)
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ func TestFilterBuilder_BuildFilterByMetricPositiveTotalLimit(t *testing.T) {
assert.Equal(t, expectedLimit, f.TotalLimit())
assert.Equal(t, expectedLimit, f.LimitByTimestamp())
}
assert.NoError(t, f.Shutdown())
}
}
})
Expand Down Expand Up @@ -147,6 +148,7 @@ func TestFilterBuilder_HandleLowCardinalityGroups(t *testing.T) {
assert.Equal(t, expectedLimit, f.TotalLimit())
assert.Equal(t, expectedLimit, f.LimitByTimestamp())
assert.Equal(t, testCase.expectedRemainingTotalLimit, remainingTotalLimit)
assert.NoError(t, f.Shutdown())
}
}
})
Expand Down Expand Up @@ -200,6 +202,7 @@ func TestFilterBuilder_HandleHighCardinalityGroups(t *testing.T) {
assert.Equal(t, testCase.expectedHighCardinalityTotalLimit, f.TotalLimit())
assert.Equal(t, testCase.expectedHighCardinalityLimitByTimestamp, f.LimitByTimestamp())
assert.Equal(t, testCase.expectedRemainingTotalLimit, remainingTotalLimit)
assert.NoError(t, f.Shutdown())
}
}
})
Expand Down Expand Up @@ -234,6 +237,7 @@ func TestFilterBuilder_TestConstructFiltersForGroups(t *testing.T) {
assert.Equal(t, totalLimitPerMetric, f.TotalLimit())
assert.Equal(t, limitPerMetricByTimestamp, f.LimitByTimestamp())
assert.Equal(t, expectedRemainingTotalLimit, result)
assert.NoError(t, f.Shutdown())
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func TestNewItemFilterResolver(t *testing.T) {
require.Nil(t, factory)
} else {
require.NoError(t, err)
require.NoError(t, factory.Shutdown())
}
})
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package filterfactory

import (
"testing"

"go.uber.org/goleak"
)

// See https://github.com/census-instrumentation/opencensus-go/issues/1191 for more information on ignore.
func TestMain(m *testing.M) {
goleak.VerifyTestMain(m, goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package statsreader

import (
"testing"

"go.uber.org/goleak"
)

// See https://github.com/census-instrumentation/opencensus-go/issues/1191 for more information on ignore.
func TestMain(m *testing.M) {
goleak.VerifyTestMain(m, goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"))
}

0 comments on commit 4c30822

Please sign in to comment.