Skip to content

Enable and enforce goroutine leak checks in tests #5006

@yurishkuro

Description

@yurishkuro

Enforce the use of https://github.com/uber-go/goleak across the repo:

  • a linter similar to scripts/check-test-files.sh that verifies that all packages with tests have goleak in TestMain
  • add goleak to all packages via TestMain. Some packages may pass the validation, some may fail and would need to be fixed. It's best to break this into several PRs, first to add goleak to packages that do not fail, and then potentially separate PRs for each package where goleak does fail with the corresponding fixes to the tests.
  • Fix leaks in the integration tests (see Add go leak checks to ES/OS tests #6339)
  • Change linter script to fail CI on errors going forward

State on March 8 2024:

$ make goleak
Verifying that all packages with tests have goleak in their TestMain
🔴 Error(check-goleak): no goleak check in package ./cmd/collector/app/
🔴 Error(check-goleak): no goleak check in package ./cmd/internal/printconfig/
🔴 Error(check-goleak): no goleak check in package ./cmd/query/app/
🔴 Error(check-goleak): no goleak check in package ./pkg/cassandra/gocql/testutils/
🔴 Error(check-goleak): no goleak check in package ./pkg/testutils/
🔴 Error(check-goleak): no goleak check in package ./plugin/metrics/prometheus/metricsstore/
🔴 Error(check-goleak): no goleak check in package ./plugin/sampling/strategystore/adaptive/
🔴 Error(check-goleak): no goleak check in package ./plugin/storage/integration/
Error(check-goleak): no goleak check in 8 package(s).

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueGood for beginnershelp wantedFeatures that maintainers are willing to accept but do not have cycles to implement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions