Skip to content

Commit

Permalink
Update leakcheck.go
Browse files Browse the repository at this point in the history
Signed-off-by: Vamshi Maskuri <117595548+varshith257@users.noreply.github.com>
  • Loading branch information
varshith257 committed May 21, 2024
1 parent ef66bb6 commit 489d417
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions pkg/testutils/leakcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,6 @@ func IgnoreGlogFlushDaemonLeak() goleak.Option {
return goleak.IgnoreTopFunction("github.com/golang/glog.(*fileSink).flushDaemon")
}

// IgnoreElasticHealthCheckerLeak returns a goleak.Option that ignores the healthchecker function
// from the olivere/elastic package that can cause false positives in leak detection.
// This is necessary because elastic starts a goroutine in the background that may not
// be stopped when the test finishes, leading to a detected but expected leak.
func IgnoreElasticHealthCheckerLeak() goleak.Option {
return goleak.IgnoreTopFunction("github.com/olivere/elastic.(*Client).healthchecker")
}

// IgnoreOpenCensusWorkerLeak This prevent catching the leak generated by opencensus defaultWorker.Start which at the time is part of the package's init call.
// See https://github.com/jaegertracing/jaeger/pull/5055#discussion_r1438702168 for more context.
func IgnoreOpenCensusWorkerLeak() goleak.Option {
Expand All @@ -45,7 +37,7 @@ func IgnoreOpenCensusWorkerLeak() goleak.Option {
// VerifyGoLeaks verifies that unit tests do not leak any goroutines.
// It should be called in TestMain.
func VerifyGoLeaks(m *testing.M) {
goleak.VerifyTestMain(m, IgnoreGlogFlushDaemonLeak(), IgnoreOpenCensusWorkerLeak(), IgnoreElasticHealthCheckerLeak())
goleak.VerifyTestMain(m, IgnoreGlogFlushDaemonLeak(), IgnoreOpenCensusWorkerLeak())
}

// VerifyGoLeaksOnce verifies that a given unit test does not leak any goroutines.
Expand Down

0 comments on commit 489d417

Please sign in to comment.