Skip to content

Commit

Permalink
Replace goleak.VerifyTestMain with testutils.VerifyGoLeaks (#5108)
Browse files Browse the repository at this point in the history
## Which problem is this PR solving?
- Part of #5006 

## Description of the changes
- Fixed Script to count `testutils.VerifyGoLeaks` as satisfactory.
- Replaced `goleak.VerifyTestMain` with `testutils.VerifyGoLeaks`.

## How was this change tested?
- `make test`

## Checklist
- [x] I have read
https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md
- [x] I have signed all commits
- [ ] I have added unit tests for the new functionality
- [x] I have run lint and test steps successfully
  - for `jaeger`: `make lint test`
  - for `jaeger-ui`: `yarn lint` and `yarn test`

---------

Signed-off-by: Pushkar Mishra <pushkarmishra029@gmail.com>
Co-authored-by: Yuri Shkuro <yurishkuro@users.noreply.github.com>
  • Loading branch information
Pushkarm029 and yurishkuro committed Jan 16, 2024
1 parent 3c9da0d commit 663a04e
Show file tree
Hide file tree
Showing 153 changed files with 334 additions and 312 deletions.
7 changes: 7 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@ linters-settings:
desc: "Do not refer to crossdock from other packages"
files:
- "!**/crossdock/**"

disallow-uber/goleak:
deny:
- pkg: go.uber.org/goleak
desc: "Use github.com/jaegertracing/jaeger/pkg/testutils"
files:
- "**_test.go"

goimports:
local-prefixes: github.com/jaegertracing/jaeger
Expand Down
4 changes: 2 additions & 2 deletions cmd/agent/app/configmanager/grpc/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/goleak"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"

"github.com/jaegertracing/jaeger/pkg/testutils"
"github.com/jaegertracing/jaeger/proto-gen/api_v2"
)

Expand Down Expand Up @@ -84,5 +84,5 @@ func initializeGRPCTestServer(t *testing.T, beforeServe func(server *grpc.Server
}

func TestMain(m *testing.M) {
goleak.VerifyTestMain(m)
testutils.VerifyGoLeaks(m)
}
4 changes: 2 additions & 2 deletions cmd/agent/app/configmanager/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import (
"time"

"github.com/stretchr/testify/require"
"go.uber.org/goleak"

"github.com/jaegertracing/jaeger/internal/metricstest"
"github.com/jaegertracing/jaeger/pkg/testutils"
"github.com/jaegertracing/jaeger/proto-gen/api_v2"
"github.com/jaegertracing/jaeger/thrift-gen/baggage"
)
Expand Down Expand Up @@ -90,5 +90,5 @@ func TestMetrics(t *testing.T) {
}

func TestMain(m *testing.M) {
goleak.VerifyTestMain(m)
testutils.VerifyGoLeaks(m)
}
5 changes: 3 additions & 2 deletions cmd/agent/app/customtransport/buffered_read_transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import (
"testing"

"github.com/stretchr/testify/require"
"go.uber.org/goleak"

"github.com/jaegertracing/jaeger/pkg/testutils"
)

// TestTBufferedReadTransport tests the TBufferedReadTransport
Expand Down Expand Up @@ -72,5 +73,5 @@ func TestTBufferedReadTransportEmptyFunctions(t *testing.T) {
}

func TestMain(m *testing.M) {
goleak.VerifyTestMain(m)
testutils.VerifyGoLeaks(m)
}
5 changes: 3 additions & 2 deletions cmd/agent/app/httpserver/srv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ import (
"testing"

"github.com/stretchr/testify/assert"
"go.uber.org/goleak"
"go.uber.org/zap"

"github.com/jaegertracing/jaeger/pkg/testutils"
)

func TestHTTPServer(t *testing.T) {
Expand All @@ -29,5 +30,5 @@ func TestHTTPServer(t *testing.T) {
}

func TestMain(m *testing.M) {
goleak.VerifyTestMain(m)
testutils.VerifyGoLeaks(m)
}
25 changes: 25 additions & 0 deletions cmd/agent/app/processors/package_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright (c) 2024 The Jaeger Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package processors

import (
"testing"

"github.com/jaegertracing/jaeger/pkg/testutils"
)

func TestMain(m *testing.M) {
testutils.VerifyGoLeaks(m)
}
5 changes: 0 additions & 5 deletions cmd/agent/app/processors/thrift_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"github.com/apache/thrift/lib/go/thrift"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/goleak"
"go.uber.org/zap/zaptest"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
Expand Down Expand Up @@ -244,7 +243,3 @@ func assertCollectorReceivedData(
{Name: "thrift.udp.server.packets.processed", Value: 1},
}...)
}

func TestMain(m *testing.M) {
goleak.VerifyTestMain(m)
}
4 changes: 2 additions & 2 deletions cmd/agent/app/reporter/grpc/package_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ package grpc
import (
"testing"

"go.uber.org/goleak"
"github.com/jaegertracing/jaeger/pkg/testutils"
)

func TestMain(m *testing.M) {
goleak.VerifyTestMain(m)
testutils.VerifyGoLeaks(m)
}
4 changes: 2 additions & 2 deletions cmd/agent/app/reporter/package_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ package reporter
import (
"testing"

"go.uber.org/goleak"
"github.com/jaegertracing/jaeger/pkg/testutils"
)

func TestMain(m *testing.M) {
goleak.VerifyTestMain(m)
testutils.VerifyGoLeaks(m)
}
5 changes: 3 additions & 2 deletions cmd/agent/app/servers/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/goleak"

"github.com/jaegertracing/jaeger/pkg/testutils"
)

func TestReadBuf_EOF(t *testing.T) {
Expand All @@ -41,5 +42,5 @@ func TestReadBuf_Read(t *testing.T) {
}

func TestMain(m *testing.M) {
goleak.VerifyTestMain(m)
testutils.VerifyGoLeaks(m)
}
5 changes: 3 additions & 2 deletions cmd/agent/app/servers/thriftudp/transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/goleak"

"github.com/jaegertracing/jaeger/pkg/testutils"
)

var localListenAddr = &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1)}
Expand Down Expand Up @@ -242,5 +243,5 @@ func TestCreateClient(t *testing.T) {
}

func TestMain(m *testing.M) {
goleak.VerifyTestMain(m)
testutils.VerifyGoLeaks(m)
}
4 changes: 2 additions & 2 deletions cmd/agent/app/testutils/package_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ package testutils
import (
"testing"

"go.uber.org/goleak"
"github.com/jaegertracing/jaeger/pkg/testutils"
)

func TestMain(m *testing.M) {
goleak.VerifyTestMain(m)
testutils.VerifyGoLeaks(m)
}
5 changes: 3 additions & 2 deletions cmd/all-in-one/setupcontext/setupcontext_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import (
"testing"

"github.com/stretchr/testify/assert"
"go.uber.org/goleak"

"github.com/jaegertracing/jaeger/pkg/testutils"
)

func TestSetupContext(t *testing.T) {
Expand All @@ -29,5 +30,5 @@ func TestSetupContext(t *testing.T) {
}

func TestMain(m *testing.M) {
goleak.VerifyTestMain(m)
testutils.VerifyGoLeaks(m)
}
5 changes: 3 additions & 2 deletions cmd/anonymizer/app/flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import (

"github.com/spf13/cobra"
"github.com/stretchr/testify/assert"
"go.uber.org/goleak"

"github.com/jaegertracing/jaeger/pkg/testutils"
)

func TestOptionsWithDefaultFlags(t *testing.T) {
Expand Down Expand Up @@ -63,5 +64,5 @@ func TestOptionsWithFlags(t *testing.T) {
}

func TestMain(m *testing.M) {
goleak.VerifyTestMain(m)
testutils.VerifyGoLeaks(m)
}
4 changes: 2 additions & 2 deletions cmd/anonymizer/app/uiconv/package_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ package uiconv
import (
"testing"

"go.uber.org/goleak"
"github.com/jaegertracing/jaeger/pkg/testutils"
)

func TestMain(m *testing.M) {
goleak.VerifyTestMain(m)
testutils.VerifyGoLeaks(m)
}
4 changes: 2 additions & 2 deletions cmd/collector/app/flags/flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/goleak"
"go.uber.org/zap"

"github.com/jaegertracing/jaeger/pkg/config"
"github.com/jaegertracing/jaeger/pkg/testutils"
)

func TestCollectorOptionsWithFlags_CheckHostPort(t *testing.T) {
Expand Down Expand Up @@ -191,5 +191,5 @@ func TestCollectorOptionsWithFlags_CheckZipkinKeepAlive(t *testing.T) {
}

func TestMain(m *testing.M) {
goleak.VerifyTestMain(m)
testutils.VerifyGoLeaks(m)
}
4 changes: 1 addition & 3 deletions cmd/collector/app/handler/package_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ package handler
import (
"testing"

"go.uber.org/goleak"

"github.com/jaegertracing/jaeger/pkg/testutils"
)

func TestMain(m *testing.M) {
goleak.VerifyTestMain(m, testutils.IgnoreOpenCensusWorkerLeak())
testutils.VerifyGoLeaks(m)
}
4 changes: 2 additions & 2 deletions cmd/collector/app/processor/empty_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ package processor
import (
"testing"

"go.uber.org/goleak"
"github.com/jaegertracing/jaeger/pkg/testutils"
)

func TestMain(m *testing.M) {
goleak.VerifyTestMain(m)
testutils.VerifyGoLeaks(m)
}
4 changes: 2 additions & 2 deletions cmd/collector/app/sampling/grpc_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/goleak"
"golang.org/x/net/context"

"github.com/jaegertracing/jaeger/pkg/testutils"
"github.com/jaegertracing/jaeger/proto-gen/api_v2"
)

Expand Down Expand Up @@ -61,5 +61,5 @@ func TestNewGRPCHandler(t *testing.T) {
}

func TestMain(m *testing.M) {
goleak.VerifyTestMain(m)
testutils.VerifyGoLeaks(m)
}
4 changes: 2 additions & 2 deletions cmd/collector/app/sampling/model/empty_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ package model
import (
"testing"

"go.uber.org/goleak"
"github.com/jaegertracing/jaeger/pkg/testutils"
)

func TestMain(m *testing.M) {
goleak.VerifyTestMain(m)
testutils.VerifyGoLeaks(m)
}
4 changes: 2 additions & 2 deletions cmd/collector/app/sampling/strategystore/empty_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ package strategystore
import (
"testing"

"go.uber.org/goleak"
"github.com/jaegertracing/jaeger/pkg/testutils"
)

func TestMain(m *testing.M) {
goleak.VerifyTestMain(m)
testutils.VerifyGoLeaks(m)
}
4 changes: 2 additions & 2 deletions cmd/collector/app/sanitizer/cache/auto_refresh_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/goleak"
"go.uber.org/zap"

"github.com/jaegertracing/jaeger/cmd/collector/app/sanitizer/cache/mocks"
"github.com/jaegertracing/jaeger/pkg/testutils"
)

var (
Expand Down Expand Up @@ -231,5 +231,5 @@ func TestIsEmpty(t *testing.T) {
}

func TestMain(m *testing.M) {
goleak.VerifyTestMain(m)
testutils.VerifyGoLeaks(m)
}
4 changes: 2 additions & 2 deletions cmd/collector/app/sanitizer/package_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ package sanitizer
import (
"testing"

"go.uber.org/goleak"
"github.com/jaegertracing/jaeger/pkg/testutils"
)

func TestMain(m *testing.M) {
goleak.VerifyTestMain(m)
testutils.VerifyGoLeaks(m)
}
4 changes: 2 additions & 2 deletions cmd/collector/app/sanitizer/zipkin/span_sanitizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import (
"testing"

"github.com/stretchr/testify/assert"
"go.uber.org/goleak"

"github.com/jaegertracing/jaeger/pkg/testutils"
"github.com/jaegertracing/jaeger/thrift-gen/zipkincore"
)

Expand Down Expand Up @@ -203,5 +203,5 @@ func TestSpanStartTimeSanitizer(t *testing.T) {
}

func TestMain(m *testing.M) {
goleak.VerifyTestMain(m)
testutils.VerifyGoLeaks(m)
}
4 changes: 1 addition & 3 deletions cmd/collector/app/server/package_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@ package server
import (
"testing"

"go.uber.org/goleak"

"github.com/jaegertracing/jaeger/pkg/testutils"
)

func TestMain(m *testing.M) {
goleak.VerifyTestMain(m, testutils.IgnoreOpenCensusWorkerLeak())
testutils.VerifyGoLeaks(m)
}
Loading

0 comments on commit 663a04e

Please sign in to comment.