Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CI #1

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions cmd/cluster/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package main

import (
"context"
"go.uber.org/goleak"
"net"
"os"
"sync"
"testing"
"time"

"go.uber.org/goleak"
)

func TestMain(m *testing.M) {
Expand Down Expand Up @@ -48,8 +49,10 @@ func TestLeaks(t *testing.T) {
goleak.IgnoreTopFunction("github.com/panjf2000/ants/v2.(*Pool).purgeStaleWorkers"),
goleak.IgnoreTopFunction("github.com/panjf2000/ants/v2.(*Pool).ticktock"),
// ignore the pprof http server goroutine
goleak.IgnoreTopFunction("internal/poll.runtime_pollWait"))

goleak.IgnoreTopFunction("internal/poll.runtime_pollWait"),
// ignore the glog flush daemon goroutine
goleak.IgnoreTopFunction("github.com/golang/glog.(*fileSink).flushDaemon"),
)
}

// hasRedis does a TCP connect to port 6379 to see if there is a redis server running on localhost.
Expand Down
9 changes: 7 additions & 2 deletions cmd/single/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package main

import (
"context"
"go.uber.org/goleak"
"sync"
"testing"
"time"

"go.uber.org/goleak"
)

func TestMain(m *testing.M) {
Expand All @@ -15,7 +16,6 @@ func TestMain(m *testing.M) {
// TestLeaks tests that there are no goroutine leaks after starting and stopping the server.
// We should likely do some more operations here, but this is a start.
func TestLeaks(t *testing.T) {
defer goleak.VerifyNone(t)
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
defer cancel()
wg := sync.WaitGroup{}
Expand All @@ -31,4 +31,9 @@ func TestLeaks(t *testing.T) {
time.Sleep(time.Millisecond * 100)
cancel()
wg.Wait()

goleak.VerifyNone(t,
// ignore the glog flush daemon goroutine
goleak.IgnoreTopFunction("github.com/golang/glog.(*fileSink).flushDaemon"),
)
}
Loading