From 8600733be5dfbb5b1dcbac67cd00590f8a7d182b Mon Sep 17 00:00:00 2001 From: ohkinozomu Date: Fri, 26 Jul 2024 07:58:05 +0900 Subject: [PATCH] Fix CI --- cmd/cluster/main_test.go | 9 ++++++--- cmd/single/main_test.go | 8 ++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/cmd/cluster/main_test.go b/cmd/cluster/main_test.go index cbed48d..a800b37 100644 --- a/cmd/cluster/main_test.go +++ b/cmd/cluster/main_test.go @@ -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) { @@ -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. diff --git a/cmd/single/main_test.go b/cmd/single/main_test.go index 3638e7c..e5af5b4 100644 --- a/cmd/single/main_test.go +++ b/cmd/single/main_test.go @@ -2,10 +2,11 @@ package main import ( "context" - "go.uber.org/goleak" "sync" "testing" "time" + + "go.uber.org/goleak" ) func TestMain(m *testing.M) { @@ -15,7 +16,10 @@ 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) + defer goleak.VerifyNone(t, + // ignore the glog flush daemon goroutine + goleak.IgnoreTopFunction("github.com/golang/glog.(*fileSink).flushDaemon"), + ) ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) defer cancel() wg := sync.WaitGroup{}