Skip to content

Commit

Permalink
Merge pull request #17676 from callthingsoff/refactor_testutil_intere…
Browse files Browse the repository at this point in the history
…stingGoroutines

client/pkg/testutil: add shouldSkip func for interestingGoroutines
  • Loading branch information
ahrtr authored Apr 1, 2024
2 parents cc32fa8 + 06b5037 commit 5c8a078
Showing 1 changed file with 36 additions and 20 deletions.
56 changes: 36 additions & 20 deletions client/pkg/testutil/leak.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,28 +130,44 @@ func interestingGoroutines() (gs []string) {
continue
}
stack := strings.TrimSpace(sl[1])
if stack == "" ||
strings.Contains(stack, "sync.(*WaitGroup).Done") ||
strings.Contains(stack, "os.(*file).close") ||
strings.Contains(stack, "os.(*Process).Release") ||
strings.Contains(stack, "created by os/signal.init") ||
strings.Contains(stack, "runtime/panic.go") ||
strings.Contains(stack, "created by testing.RunTests") ||
strings.Contains(stack, "created by testing.runTests") ||
strings.Contains(stack, "created by testing.(*T).Run") ||
strings.Contains(stack, "testing.Main(") ||
strings.Contains(stack, "runtime.goexit") ||
strings.Contains(stack, "go.etcd.io/etcd/client/pkg/v3/testutil.interestingGoroutines") ||
strings.Contains(stack, "go.etcd.io/etcd/client/pkg/v3/logutil.(*MergeLogger).outputLoop") ||
strings.Contains(stack, "github.com/golang/glog.(*loggingT).flushDaemon") ||
strings.Contains(stack, "created by runtime.gc") ||
strings.Contains(stack, "created by text/template/parse.lex") ||
strings.Contains(stack, "runtime.MHeap_Scavenger") ||
strings.Contains(stack, "rcrypto/internal/boring.(*PublicKeyRSA).finalize") ||
strings.Contains(stack, "net.(*netFD).Close(") ||
strings.Contains(stack, "testing.(*T).Run") {
if stack == "" {
continue
}

shouldSkip := func() bool {
var uninterestingMsgs = [...]string{
"sync.(*WaitGroup).Done",
"os.(*file).close",
"os.(*Process).Release",
"created by os/signal.init",
"runtime/panic.go",
"created by testing.RunTests",
"created by testing.runTests",
"created by testing.(*T).Run",
"testing.Main(",
"runtime.goexit",
"go.etcd.io/etcd/client/pkg/v3/testutil.interestingGoroutines",
"go.etcd.io/etcd/client/pkg/v3/logutil.(*MergeLogger).outputLoop",
"github.com/golang/glog.(*loggingT).flushDaemon",
"created by runtime.gc",
"created by text/template/parse.lex",
"runtime.MHeap_Scavenger",
"rcrypto/internal/boring.(*PublicKeyRSA).finalize",
"net.(*netFD).Close(",
"testing.(*T).Run",
}
for _, msg := range uninterestingMsgs {
if strings.Contains(stack, msg) {
return true
}
}
return false
}()

if shouldSkip {
continue
}

gs = append(gs, stack)
}
sort.Strings(gs)
Expand Down

0 comments on commit 5c8a078

Please sign in to comment.