Skip to content

Commit

Permalink
Fix goleak error in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
leszko committed Oct 2, 2024
1 parent d7cc59c commit c3721dd
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion common/testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func IgnoreRoutines() []goleak.Option {
"github.com/livepeer/go-livepeer/server.(*LivepeerServer).StartMediaServer", "github.com/livepeer/go-livepeer/core.(*RemoteTranscoderManager).Manage.func1",
"github.com/livepeer/go-livepeer/server.(*LivepeerServer).HandlePush.func1", "github.com/rjeczalik/notify.(*nonrecursiveTree).dispatch",
"github.com/rjeczalik/notify.(*nonrecursiveTree).internal", "github.com/livepeer/lpms/stream.NewBasicRTMPVideoStream.func1", "github.com/patrickmn/go-cache.(*janitor).Run",
"github.com/golang/glog.(*fileSink).flushDaemon",
"github.com/golang/glog.(*fileSink).flushDaemon", "github.com/ipfs/go-log/writer.(*MirrorWriter).logRoutine",
}

res := make([]goleak.Option, 0, len(funcs2ignore))
Expand Down
5 changes: 3 additions & 2 deletions discovery/discovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
"go.uber.org/goleak"
)

func TestNewDBOrchestratorPoolCache_NilEthClient_ReturnsError(t *testing.T) {
Expand Down Expand Up @@ -159,7 +160,7 @@ func TestDBOrchestratorPoolCacheSize(t *testing.T) {
cancel()
dbh.Close()
dbraw.Close()
//goleak.VerifyNone(t, common.IgnoreRoutines()...)
goleak.VerifyNone(t, common.IgnoreRoutines()...)
}()

emptyPool, err := NewDBOrchestratorPoolCache(ctx, node, &stubRoundsManager{}, []string{}, 500*time.Millisecond)
Expand Down Expand Up @@ -1467,7 +1468,7 @@ func TestOrchestratorPool_ShuffleGetOrchestrators(t *testing.T) {
}

func TestOrchestratorPool_GetOrchestratorTimeout(t *testing.T) {
//defer goleak.VerifyNone(t, common.IgnoreRoutines()...)
defer goleak.VerifyNone(t, common.IgnoreRoutines()...)
assert := assert.New(t)

addresses := stringsToURIs([]string{"https://127.0.0.1:8936", "https://127.0.0.1:8937", "https://127.0.0.1:8938"})
Expand Down
2 changes: 0 additions & 2 deletions server/mediaserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1230,8 +1230,6 @@ func TestRegisterConnection(t *testing.T) {
}

func TestBroadcastSessionManagerWithStreamStartStop(t *testing.T) {
// TODO: Fix
t.SkipNow()
goleakOptions := common.IgnoreRoutines()
defer goleak.VerifyNone(t, goleakOptions...)
assert := require.New(t)
Expand Down
10 changes: 4 additions & 6 deletions server/push_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
"go.uber.org/goleak"
)

func requestSetup(s *LivepeerServer) (http.Handler, *strings.Reader, *httptest.ResponseRecorder) {
Expand Down Expand Up @@ -723,8 +724,7 @@ func TestPush_SetVideoProfileFormats(t *testing.T) {
}

func TestPush_ShouldRemoveSessionAfterTimeoutIfInternalMIDIsUsed(t *testing.T) {
// TODO: Fix leaked goroutine
//defer goleak.VerifyNone(t, common.IgnoreRoutines()...)
defer goleak.VerifyNone(t, common.IgnoreRoutines()...)

oldRI := httpPushTimeout
httpPushTimeout = 100 * time.Millisecond
Expand Down Expand Up @@ -774,8 +774,7 @@ func TestPush_ShouldRemoveSessionAfterTimeoutIfInternalMIDIsUsed(t *testing.T) {
}

func TestPush_ShouldRemoveSessionAfterTimeout(t *testing.T) {
// TODO: Fix leaked goroutine
//defer goleak.VerifyNone(t, common.IgnoreRoutines()...)
defer goleak.VerifyNone(t, common.IgnoreRoutines()...)

oldRI := httpPushTimeout
httpPushTimeout = 100 * time.Millisecond
Expand Down Expand Up @@ -1315,8 +1314,7 @@ func TestPush_ReuseIntmidWithDiffExtmid(t *testing.T) {
defer func() {
core.JsonPlaylistQuitTimeout = oldjpqt
}()
// TODO: Fix leaked goroutine
//defer goleak.VerifyNone(t, common.IgnoreRoutines()...)
defer goleak.VerifyNone(t, common.IgnoreRoutines()...)
core.JsonPlaylistQuitTimeout = 0 * time.Second

reader := strings.NewReader("InsteadOf.TS")
Expand Down

0 comments on commit c3721dd

Please sign in to comment.