-
Notifications
You must be signed in to change notification settings - Fork 9.8k
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
tests: update + enable check for leaked goroutines #4026
Conversation
Works fine locally, let's see what semaphore has to say.. |
@jonboulle I think go 14 might still fail? The leaky issue is fixed in go 15 if I remember correctly. I will double check. |
Semaphore is fine and I'm using 1.4. What's the leak you have in mind? readloop? |
@jonboulle This golang/go#10457 is fixed in 15. |
@xiang90 how about this? |
Go 1.4 landed a new testing.M type [1][1] which allows for start-up and shutdown hooks when running tests. The standard library now uses this for checking for leaked goroutines in net/http [2][2]. This patch essentially re-ports the updated code from the net/http test (we were using an older version of it) - in detail: - updates the test to use `TestMain` instead of relying on `TestGoroutinesRunning` to be implicitly run after all other tests - adds a few new goroutines to the list of exceptions (the test itself, as well as the golang/glog package and pkg/log.MergeLogger, both of which spin off goroutines to handle log flushing/merging respectively) - removes a couple of TODOs in the test for extra goroutines that's run after individual tests (one of these re-enables the http package's `.readLoop` and the other was an out-of-date TODO) - re-enables the test [1]: https://golang.org/pkg/testing/#M [2]: https://github.com/golang/go/blob/release-branch.go1.4/src/net/http/main_test.go#L18
func init() { | ||
var major, minor int | ||
var discard string | ||
i, err := fmt.Sscanf(runtime.Version(), "go%d.%d%s", &major, &minor, &discard) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
go tip version does not follow this and it is greater than 1.5. but i am fine with not testing go tip.
LGTM! Thanks for fixing this! |
tests: update + enable check for leaked goroutines
Go 1.4 landed a new testing.M type [1][1] which allows for start-up and shutdown hooks when running tests. The standard library now uses this for checking for leaked goroutines in net/http [2][2]. This patch re-ports the updated code from the net/http test. For a previous example, see etcd-io/etcd#4026 [1]: https://golang.org/pkg/testing/#M [2]: https://github.com/golang/go/blob/release-branch.go1.4/src/net/http/main_test.go#L18
Go 1.4 landed a new testing.M type [1][1] which allows for start-up and shutdown hooks when running tests. The standard library now uses this for checking for leaked goroutines in net/http [2][2]. This patch re-ports the updated code from the net/http test. For a previous example, see etcd-io/etcd#4026 [1]: https://golang.org/pkg/testing/#M [2]: https://github.com/golang/go/blob/release-branch.go1.4/src/net/http/main_test.go#L18
Go 1.4 landed a new testing.M type [1][1] which allows for start-up and shutdown hooks when running tests. The standard library now uses this for checking for leaked goroutines in net/http [2][2]. This patch re-ports the updated code from the net/http test. For a previous example, see etcd-io/etcd#4026 [1]: https://golang.org/pkg/testing/#M [2]: https://github.com/golang/go/blob/release-branch.go1.4/src/net/http/main_test.go#L18
Go 1.4 landed a new testing.M type 1 which allows for start-up and
shutdown hooks when running tests. The standard library now uses this
for checking for leaked goroutines in net/http 2.
This patch essentially re-ports the updated code from the net/http test
(we were using an older version of it) - in detail:
TestMain
instead of relying onTestGoroutinesRunning
to be implicitly run after all other testsas well as the golang/glog package and pkg/log.MergeLogger, both of
which spin off goroutines to handle log flushing/merging respectively)
after individual tests (one of these re-enables the http package's
.readLoop
and the other was an out-of-date TODO)