-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Enable and enforce goroutine leak checks in tests #5006
Comments
@yurishkuro, I will look into this |
@yurishkuro, i would also like to work on this, if @Freedisch dosen't mind |
## Which problem is this PR solving? - Partially Fixes #5006 ## Description of the changes - added a linter to check implementation of goleak in tests - added go leak in some tests ## How was this change tested? - ## Checklist - [x] I have read https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md - [x] I have signed all commits - [ ] I have added unit tests for the new functionality - [ ] I have run lint and test steps successfully - for `jaeger`: `make lint test` - for `jaeger-ui`: `yarn lint` and `yarn test` --------- Signed-off-by: Harshvir Potpose <[email protected]> Signed-off-by: Yuri Shkuro <[email protected]> Co-authored-by: Yuri Shkuro <[email protected]> Co-authored-by: Yuri Shkuro <[email protected]>
## Which problem is this PR solving? - Part of #5006 ## Description of the changes - Add goleak checks to all packages with empty_test.go as well as ./storage/... (which mostly contains APIs) ## How was this change tested? - CI Signed-off-by: Yuri Shkuro <[email protected]>
## Which problem is this PR solving? - part of #5006 ## Description of the changes - added goleak checks to all tests that do not fail - minor bug fix in `check-goleak-file.sh` - `make goleak` was listing directories that do not contain any test, added a `if` condition to prevent that ## How was this change tested? - `make test` --------- Signed-off-by: Harshvir Potpose <[email protected]> Signed-off-by: Yuri Shkuro <[email protected]> Co-authored-by: Yuri Shkuro <[email protected]> Co-authored-by: Yuri Shkuro <[email protected]>
Latest: 33 packages remaining
|
## Which problem is this PR solving? - Part of #5006 ## Description of the changes - Fix goroutine leaks in several packages ## How was this change tested? - go test --------- Signed-off-by: Yuri Shkuro <[email protected]>
## Which problem is this PR solving? - part of #5006 ## Description of the changes - fix goroutine leaks in some package and add goleak check ## How was this change tested? - go test --------- Signed-off-by: Harshvir Potpose <[email protected]>
working on /cmd/collector/app/zipkin/ |
I have implemented this into the package folders in this PR |
## Which problem is this PR solving? - fix gorourine leak in some packages ## Description of the changes - part of #5006 ## How was this change tested? - go test ## Checklist - [x] I have read https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md - [x] I have signed all commits - [x] I have run lint and test steps successfully - for `jaeger`: `make lint test` --------- Signed-off-by: Harshvir Potpose <[email protected]>
…lder (#5055) ## Which problem is this PR solving? - Part of #5006 ## Description of the changes - Added TestMain to package folders - Added make goleak into unit test ci ## How was this change tested? - please run make goleak ## Checklist - [x] I have read https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md - [x] I have signed all commits - [x] I have added unit tests for the new functionality - [x] I have run lint and test steps successfully - for `jaeger`: `make lint test` - for `jaeger-ui`: `yarn lint` and `yarn test` --------- Signed-off-by: Aleem Isiaka <[email protected]> Signed-off-by: Aleem Isiaka <[email protected]> Co-authored-by: Yuri Shkuro <[email protected]>
## Which problem is this PR solving? - part of #5006 ## Description of the changes - fixed goroutine leaks in `cmd/agent/app/reporter/grpc` and also added a goleak check ## How was this change tested? - go test ## Checklist - [x] I have read https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md - [x] I have signed all commits - [x] I have added unit tests for the new functionality - [x] I have run lint and test steps successfully - for `jaeger`: `make lint test` --------- Signed-off-by: Harshvir Potpose <[email protected]>
I had a look into I think there's a couple of options:
For now I'll go for 1. but I thought I'd see whether there is any appetite for 2. because it would have the side benefit of making the test code a bit cleaner. |
Solved in a different way: dfe7adc |
## Which problem is this PR solving? - Solves part of #5006 ## Description of the changes - This mainly involved ensuring that all goroutines started by the Processor are shut down in a Close method (which also blocks on them returning via a WaitGroup). - Adding this flagged an issue where the `runUpdateProbabilitiesLoop` had a long delay, so tests need to be able to override the default Processor.followerRefreshInterval, or `Close` would take up to ~20s to return. More context on this here #5006 (comment) - specifically regarding how to override this in the `Factory`. - I also needed to fix a deadlock where a test was not unlocking a lock which would allow the Close method to return: https://github.com/jaegertracing/jaeger/pull/5310/files#diff-c9d6c33e36122502911585c65618d1af863079a70a68543adcc0ae2798faa348R468 ## How was this change tested? - `make test lint` ## Checklist - [x] I have read https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md - [x] I have signed all commits - [ ] I have added unit tests for the new functionality - [x] I have run lint and test steps successfully - for `jaeger`: `make lint test` - for `jaeger-ui`: `yarn lint` and `yarn test` --------- Signed-off-by: Will Sewell <[email protected]>
## Which problem is this PR solving? - The testutils package itself was being flagged as missing goleak check. The check was there, but without the package name, and the lint script was flagging it as false positive. - Similar issue in `pkg/cassandra/gocql/testutils` - Part of #5006 ## Description of the changes 1. Change package name of the test file so that the functions can be called with the usual package package name `testutils`. 2. change competing `testutils` import labels to satisfy the linter ## How was this change tested? - `make goleak` no longer shows this package --------- Signed-off-by: Yuri Shkuro <[email protected]>
## Which problem is this PR solving? - Part of #5006 - We have only two packages remaining without goroutine leak checks, both integration tests, which are being worked on - Meanwhile new code / packages do not benefit from enforcement of goleak checks because the linter does not fail CI ## Description of the changes - Add the two remaining packages into exclusion list and force a failure of the CI if anything else is missing goleak checks ## How was this change tested? Successful exit: ```shell $ make goleak Verifying that all packages with tests have goleak in their TestMain 🔴 Error(check-goleak): no goleak check in package ./cmd/jaeger/internal/integration/ this package is temporarily allowed and will not cause linter failure 🔴 Error(check-goleak): no goleak check in package ./plugin/storage/integration/ this package is temporarily allowed and will not cause linter failure 🐞 Warning(check-goleak): no goleak check in 2 package(s). See https://github.com/jaegertracing/jaeger/pull/5010/files for examples of adding the checks. ``` Unsuccessful exit (forced by removing one of the existing checks): ```shell $ make goleak Verifying that all packages with tests have goleak in their TestMain 🔴 Error(check-goleak): no goleak check in package ./cmd/jaeger/internal/integration/ this package is temporarily allowed and will not cause linter failure 🔴 Error(check-goleak): no goleak check in package ./internal/tracegen/ 🔴 Error(check-goleak): no goleak check in package ./plugin/storage/integration/ this package is temporarily allowed and will not cause linter failure ⛔ Fatal(check-goleak): no goleak check in 3 package(s), 1 of which not allowed. See https://github.com/jaegertracing/jaeger/pull/5010/files for examples of adding the checks. make: *** [goleak] Error 1 ``` Signed-off-by: Yuri Shkuro <[email protected]>
…st.go (#5311) ## Which problem is this PR solving? - Solves part of #5006 ## Description of the changes - Fixes goroutine leaks in the shutdown of cassandra Factory - It does not add the goleak detection because there are still failures in this package related to other components (e.g. grpc, elasticsearch) ## How was this change tested? - Add a goleak detection (i.e. this file 105a4d7) - `STORAGE=cassandra go test -v ./plugin/storage/integration` ## Checklist - [x] I have read https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md - [x] I have signed all commits - [ ] I have added unit tests for the new functionality - [x] I have run lint and test steps successfully - for `jaeger`: `make lint test` - for `jaeger-ui`: `yarn lint` and `yarn test` --------- Signed-off-by: Will Sewell <[email protected]>
## Which problem is this PR solving? - Solves part of #5006 ## Description of the changes - The key issue was that the grpc client was only being killed in a `runtime.SetFinalizer` - i.e. when it is GCed. I think in the tests this was not shutting down before goleak had decided that the goroutine had leaked. - This change switches to a more conventional approach of killing the client as part of the Close method and then ensuring this is called in each of the tests. ## How was this change tested? - While this change does not include a call to activate goleak, it _was_ tested with this. The PR does not include goleak detection because there are still other violations related to elasticsearch in this package. ## Checklist - [x] I have read https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md - [x] I have signed all commits - [ ] I have added unit tests for the new functionality - [ ] I have run lint and test steps successfully - for `jaeger`: `make lint test` - for `jaeger-ui`: `yarn lint` and `yarn test` --------- Signed-off-by: Will Sewell <[email protected]> Signed-off-by: Yuri Shkuro <[email protected]> Co-authored-by: Yuri Shkuro <[email protected]>
## Which problem is this PR solving? - Solves part of jaegertracing#5006 ## Description of the changes - The key issue was that the grpc client was only being killed in a `runtime.SetFinalizer` - i.e. when it is GCed. I think in the tests this was not shutting down before goleak had decided that the goroutine had leaked. - This change switches to a more conventional approach of killing the client as part of the Close method and then ensuring this is called in each of the tests. ## How was this change tested? - While this change does not include a call to activate goleak, it _was_ tested with this. The PR does not include goleak detection because there are still other violations related to elasticsearch in this package. ## Checklist - [x] I have read https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md - [x] I have signed all commits - [ ] I have added unit tests for the new functionality - [ ] I have run lint and test steps successfully - for `jaeger`: `make lint test` - for `jaeger-ui`: `yarn lint` and `yarn test` --------- Signed-off-by: Will Sewell <[email protected]> Signed-off-by: Yuri Shkuro <[email protected]> Co-authored-by: Yuri Shkuro <[email protected]> Signed-off-by: Vamshi Maskuri <[email protected]>
#5468 (comment) I started with this like by adding adding goleak in a single test. From there I got errors and by reffering to this I got to know that we have to use a seperate grpc clients for each test instead of using as a single (initialized in the |
@Manik2708 if you are able to get clean run by adding goleak check into individual tests, feel free to create PRs for those - it will narrow down the scope of remaining work (once the whole package is clean it's easy to remove those in favor of a package-level check, although we may just want to keep them per-test too, as a debugging tool). I will need more information about what specific problem you found. I don't believe it should matter if some gRPC clients are alive for the duration of the overall test vs. individual tests as long as they are closed at the end of the parent test. |
This was the error which I got when I used
|
@Manik2708 first, you mentioned that adding second, are you talking about v1 or v2 integration tests? For v1 there should be no gRPC in the picture. If you are talking about v2, then again gRPC there is not specific to Cassandra, but to the overall test setup, so I would expect the same issue to occur for another storage backend that might be easier to run locally than the one with Cassandra. Lastly, I think I would be only putting |
looking at the dump output, it mentions |
I think there is some mis-understanding! I said that tests are not passing for individual tests but they are passing for package. Yes, this output is for v2. But thanks for the clarification as I was putting the goleak test in individual test not in top level test. I think now these errors are justified. |
I don't think we need anything extra for v2 tests since we already have package-level check. The last package missing checks is plugin/storage/integration (which is also used by v2 e2e tests, so a bit puzzling why it fails) |
## Which problem is this PR solving? Fixes a part of #5006 ## Description of the changes 1) Cassandra factory is closed in the test manually after the test, not doing so will fail the leak test probably due to CleanUp function is not closing factory properly and returning in the test leading to end it that further fails the leak test. 2) Kafka Producer and Consumer was not closed before leading to failure of leak test which is fixed in this PR. ## How was this change tested? - By running integartion tests manually ## Checklist - [x] I have read https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md - [x] I have signed all commits - [x] I have added unit tests for the new functionality - [x] I have run lint and test steps successfully - for `jaeger`: `make lint test` - for `jaeger-ui`: `yarn lint` and `yarn test` --------- Signed-off-by: Manik2708 <[email protected]> Signed-off-by: Manik Mehta <[email protected]> Co-authored-by: Yuri Shkuro <[email protected]>
## Which problem is this PR solving? Fixes a part of #5006 ## Description of the changes - Added go leak check for badgerstore, grpc and Memstore ## How was this change tested? - Integration Tests ## Checklist - [x] I have read https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md - [x] I have signed all commits - [x] I have added unit tests for the new functionality - [x] I have run lint and test steps successfully - for `jaeger`: `make lint test` - for `jaeger-ui`: `yarn lint` and `yarn test` Signed-off-by: Manik2708 <[email protected]>
## Which problem is this PR solving? - Fixes a part of #5006 ## Description of the changes - This is a better version of `elasticsearch_test` reducing the number of leaks from 50 to less than 10. Unfortunately we can't fix all the leakages because there is no way to close the v8 client of ES leading to some unclosed http transports. If the changes looks good then we can merge without embedding `goleak` (as it will lead to failure of test) ## How was this change tested? - By running the integration tests ## Checklist - [x] I have read https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md - [x] I have signed all commits - [x] I have added unit tests for the new functionality - [ ] I have run lint and test steps successfully - for `jaeger`: `make lint test` - for `jaeger-ui`: `yarn lint` and `yarn test` --------- Signed-off-by: Manik2708 <[email protected]>
Enforce the use of https://github.com/uber-go/goleak across the repo:
make goleak
to see the list of packages missing the linter*_test.go
files add the check to a new filepackage_test.go
make fmt
after committing the new filesState on March 8 2024:
The text was updated successfully, but these errors were encountered: