github.com/thanos-io/thanos@v0.32.5/pkg/testutil/custom/custom.go (about) 1 // Copyright (c) The Thanos Authors. 2 // Licensed under the Apache License 2.0. 3 4 package custom 5 6 import ( 7 "testing" 8 9 "go.uber.org/goleak" 10 ) 11 12 // TolerantVerifyLeakMain verifies go leaks but excludes the go routines that are 13 // launched as side effects of some of our dependencies. 14 func TolerantVerifyLeakMain(m *testing.M) { 15 goleak.VerifyTestMain(m, 16 // https://github.com/census-instrumentation/opencensus-go/blob/d7677d6af5953e0506ac4c08f349c62b917a443a/stats/view/worker.go#L34 17 goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"), 18 // https://github.com/kubernetes/klog/blob/c85d02d1c76a9ebafa81eb6d35c980734f2c4727/klog.go#L417 19 goleak.IgnoreTopFunction("k8s.io/klog/v2.(*loggingT).flushDaemon"), 20 goleak.IgnoreTopFunction("k8s.io/klog.(*loggingT).flushDaemon"), 21 // https://github.com/baidubce/bce-sdk-go/blob/9a8c1139e6a3ad23080b9b8c51dec88df8ce3cda/util/log/logger.go#L359 22 goleak.IgnoreTopFunction("github.com/baidubce/bce-sdk-go/util/log.NewLogger.func1"), 23 ) 24 } 25 26 // TolerantVerifyLeak verifies go leaks but excludes the go routines that are 27 // launched as side effects of some of our dependencies. 28 func TolerantVerifyLeak(t *testing.T) { 29 goleak.VerifyNone(t, 30 // https://github.com/census-instrumentation/opencensus-go/blob/d7677d6af5953e0506ac4c08f349c62b917a443a/stats/view/worker.go#L34 31 goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"), 32 // https://github.com/kubernetes/klog/blob/c85d02d1c76a9ebafa81eb6d35c980734f2c4727/klog.go#L417 33 goleak.IgnoreTopFunction("k8s.io/klog/v2.(*loggingT).flushDaemon"), 34 goleak.IgnoreTopFunction("k8s.io/klog.(*loggingT).flushDaemon"), 35 // https://github.com/baidubce/bce-sdk-go/blob/9a8c1139e6a3ad23080b9b8c51dec88df8ce3cda/util/log/logger.go#L359 36 goleak.IgnoreTopFunction("github.com/baidubce/bce-sdk-go/util/log.NewLogger.func1"), 37 ) 38 }