diff --git a/discovery/azure/azure_test.go b/discovery/azure/azure_test.go index 3e7f218ca..e5e6f4201 100644 --- a/discovery/azure/azure_test.go +++ b/discovery/azure/azure_test.go @@ -18,8 +18,13 @@ import ( "testing" "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute" + "go.uber.org/goleak" ) +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} + func TestMapFromVMWithEmptyTags(t *testing.T) { id := "test" name := "name" diff --git a/discovery/dns/dns_test.go b/discovery/dns/dns_test.go index ddcb2d163..be0ad8cf8 100644 --- a/discovery/dns/dns_test.go +++ b/discovery/dns/dns_test.go @@ -22,6 +22,7 @@ import ( "github.com/go-kit/kit/log" "github.com/miekg/dns" + "go.uber.org/goleak" "gopkg.in/yaml.v2" "github.com/prometheus/common/model" @@ -29,6 +30,10 @@ import ( "github.com/prometheus/prometheus/util/testutil" ) +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} + func TestDNS(t *testing.T) { testCases := []struct { name string diff --git a/discovery/file/file_test.go b/discovery/file/file_test.go index a1880220c..b8fead21b 100644 --- a/discovery/file/file_test.go +++ b/discovery/file/file_test.go @@ -26,11 +26,16 @@ import ( "time" "github.com/prometheus/common/model" + "go.uber.org/goleak" "github.com/prometheus/prometheus/discovery/targetgroup" "github.com/prometheus/prometheus/util/testutil" ) +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} + const defaultWait = time.Second type testRunner struct { diff --git a/discovery/kubernetes/kubernetes_test.go b/discovery/kubernetes/kubernetes_test.go index eb1f97fa2..6d7e76272 100644 --- a/discovery/kubernetes/kubernetes_test.go +++ b/discovery/kubernetes/kubernetes_test.go @@ -29,6 +29,10 @@ import ( "github.com/prometheus/prometheus/util/testutil" ) +func TestMain(m *testing.M) { + testutil.TolerantVerifyLeak(m) +} + // makeDiscovery creates a kubernetes.Discovery instance for testing. func makeDiscovery(role Role, nsDiscovery NamespaceDiscovery, objects ...runtime.Object) (*Discovery, kubernetes.Interface) { clientset := fake.NewSimpleClientset(objects...) diff --git a/discovery/refresh/refresh_test.go b/discovery/refresh/refresh_test.go index 066f901ce..6463164ae 100644 --- a/discovery/refresh/refresh_test.go +++ b/discovery/refresh/refresh_test.go @@ -20,11 +20,16 @@ import ( "time" "github.com/prometheus/common/model" + "go.uber.org/goleak" "github.com/prometheus/prometheus/discovery/targetgroup" "github.com/prometheus/prometheus/util/testutil" ) +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} + func TestRefresh(t *testing.T) { tg1 := []*targetgroup.Group{ { diff --git a/discovery/zookeeper/zookeeper_test.go b/discovery/zookeeper/zookeeper_test.go index 8900b2ab6..d0e67b50a 100644 --- a/discovery/zookeeper/zookeeper_test.go +++ b/discovery/zookeeper/zookeeper_test.go @@ -18,8 +18,13 @@ import ( "time" "github.com/prometheus/common/model" + "go.uber.org/goleak" ) +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} + func TestNewDiscoveryError(t *testing.T) { _, err := NewDiscovery( []string{"unreachable.test"}, diff --git a/rules/manager_test.go b/rules/manager_test.go index a865097d4..10e16e6cc 100644 --- a/rules/manager_test.go +++ b/rules/manager_test.go @@ -26,6 +26,7 @@ import ( "github.com/go-kit/kit/log" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/common/model" + "go.uber.org/goleak" yaml "gopkg.in/yaml.v2" "github.com/prometheus/prometheus/pkg/labels" @@ -39,6 +40,10 @@ import ( "github.com/prometheus/prometheus/util/testutil" ) +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} + func TestAlertingRule(t *testing.T) { suite, err := promql.NewTest(t, ` load 5m diff --git a/scrape/scrape_test.go b/scrape/scrape_test.go index 5240f78ca..e9e1cfe36 100644 --- a/scrape/scrape_test.go +++ b/scrape/scrape_test.go @@ -46,6 +46,10 @@ import ( "github.com/prometheus/prometheus/util/testutil" ) +func TestMain(m *testing.M) { + testutil.TolerantVerifyLeak(m) +} + func TestNewScrapePool(t *testing.T) { var ( app = &nopAppendable{} @@ -1785,6 +1789,7 @@ func TestReuseScrapeCache(t *testing.T) { } proxyURL, _ = url.Parse("http://localhost:2128") ) + defer sp.stop() sp.sync([]*Target{t1}) steps := []struct { @@ -1937,6 +1942,7 @@ func TestReuseCacheRace(t *testing.T) { }, } ) + defer sp.stop() sp.sync([]*Target{t1}) start := time.Now()