Skip to content

Commit

Permalink
pillar/devicenetwork: goroutine leak test
Browse files Browse the repository at this point in the history
use fancy uber leak checker to check for leaks
which have been fixed in the commit before

Signed-off-by: Christoph Ostarek <christoph@zededa.com>
(cherry picked from commit 145e98e)
  • Loading branch information
christoph-zededa authored and OhmSpectator committed Nov 6, 2024
1 parent d5d9f92 commit 7c8ec71
Show file tree
Hide file tree
Showing 19 changed files with 1,063 additions and 2 deletions.
5 changes: 4 additions & 1 deletion pkg/pillar/devicenetwork/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,10 @@ func ResolveWithPortsLambda(domain string,
close(wgChan)
}()

defer close(quit)
defer func() {
close(quit)
<-wgChan
}()
select {
case <-wgChan:
var responses []DNSResponse
Expand Down
3 changes: 2 additions & 1 deletion pkg/pillar/devicenetwork/dns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/lf-edge/eve/pkg/pillar/devicenetwork"
"github.com/lf-edge/eve/pkg/pillar/netmonitor"
"github.com/lf-edge/eve/pkg/pillar/types"
"go.uber.org/goleak"
)

func createNetmonitorMockInterface() []netmonitor.MockInterface {
Expand Down Expand Up @@ -160,7 +161,7 @@ func TestDnsResolveTimeout(t *testing.T) {
}

func TestResolveWithPortsLambda(t *testing.T) {
t.Parallel()
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("go.opencensus.io/stats/view.(*worker).start"), goleak.IgnoreCurrent())

expectedIP := net.IP{1, 2, 3, 4}

Expand Down
1 change: 1 addition & 0 deletions pkg/pillar/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ require (
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
go.opencensus.io v0.24.0 // indirect
go.uber.org/goleak v1.3.0 // indirect
golang.org/x/oauth2 v0.7.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/text v0.13.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions pkg/pillar/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1743,6 +1743,8 @@ go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A=
go.uber.org/goleak v1.1.12/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
Expand Down
5 changes: 5 additions & 0 deletions pkg/pillar/vendor/go.uber.org/goleak/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions pkg/pillar/vendor/go.uber.org/goleak/.golangci.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

74 changes: 74 additions & 0 deletions pkg/pillar/vendor/go.uber.org/goleak/CHANGELOG.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions pkg/pillar/vendor/go.uber.org/goleak/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions pkg/pillar/vendor/go.uber.org/goleak/Makefile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

74 changes: 74 additions & 0 deletions pkg/pillar/vendor/go.uber.org/goleak/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions pkg/pillar/vendor/go.uber.org/goleak/doc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions pkg/pillar/vendor/go.uber.org/goleak/internal/stack/doc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7c8ec71

Please sign in to comment.