Skip to content

test(controller): add goleak test cases to detect goroutine leaks #1810

Merged
EItanya merged 2 commits into
kagent-dev:mainfrom
dongjiang1989:fix/memory-leaks
May 11, 2026
Merged

test(controller): add goleak test cases to detect goroutine leaks #1810
EItanya merged 2 commits into
kagent-dev:mainfrom
dongjiang1989:fix/memory-leaks

Conversation

@dongjiang1989

Copy link
Copy Markdown
Contributor

Summary

  • Add goleak verification to the controller package test suite via TestMain, ensuring goroutine leaks are detected across all controller tests
  • Add goleak coverage to the MCP server reconciler tests
  • Prevent silent goroutine leaks from accumulating in the reconciliation loop

Test plan

  • go test ./go/core/internal/controller/... — goleak runs automatically on every test
  • go test ./go/core/internal/controller/reconciler/... — reconciler goleak tests pass

Copilot AI review requested due to automatic review settings May 7, 2026 09:47
@github-actions github-actions Bot added the testing Additional testing required label May 7, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds go.uber.org/goleak to the Go module and wires it into controller-related test suites via TestMain, aiming to detect goroutine leaks during tests (notably around reconciler behavior).

Changes:

  • Add go.uber.org/goleak dependency.
  • Enable goleak verification for controller package tests via a new TestMain.
  • Enable goleak verification for reconciler package tests via TestMain in the MCP server reconciler test file.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
go/go.mod Adds the go.uber.org/goleak dependency.
go/core/internal/controller/goleak_test.go Adds package-level TestMain to run goleak verification for controller tests.
go/core/internal/controller/reconciler/mcp_server_reconciler_test.go Adds goleak TestMain for reconciler package tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread go/core/internal/controller/goleak_test.go
@dongjiang1989

Copy link
Copy Markdown
Contributor Author

cc @EItanya PTAL

@EItanya EItanya left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a leak checker makes sense, but I'm not quite sure why you decided to put it in the spots you did.

Signed-off-by: dongjiang <dongjiang1989@126.com>
@dongjiang1989

Copy link
Copy Markdown
Contributor Author

Adding a leak checker makes sense, but I'm not quite sure why you decided to put it in the spots you did.

Thanks @EItanya

The goleak mainly checks for goroutine leaks, and configuring it in the controller is the most effective way to detect such problems

@EItanya

EItanya commented May 11, 2026

Copy link
Copy Markdown
Contributor

Adding a leak checker makes sense, but I'm not quite sure why you decided to put it in the spots you did.

Thanks @EItanya

The goleak mainly checks for goroutine leaks, and configuring it in the controller is the most effective way to detect such problems

Makes sense, need to resolve merge conflicts

Signed-off-by: dongjiang <dongjiang1989@126.com>
@dongjiang1989

Copy link
Copy Markdown
Contributor Author

Makes sense, need to resolve merge conflicts

Rebase done. thanks @EItanya

@EItanya EItanya merged commit 8e74316 into kagent-dev:main May 11, 2026
23 checks passed
@dongjiang1989 dongjiang1989 deleted the fix/memory-leaks branch May 11, 2026 16:49
0xLeo258 pushed a commit to 0xLeo258/kagent that referenced this pull request May 12, 2026
…gent-dev#1810)

## Summary
- Add `goleak` verification to the controller package test suite via
`TestMain`, ensuring goroutine leaks are detected across all controller
tests
- Add goleak coverage to the MCP server reconciler tests
- Prevent silent goroutine leaks from accumulating in the reconciliation
loop
## Test plan
- [x] `go test ./go/core/internal/controller/...` — goleak runs
automatically on every test
- [x] `go test ./go/core/internal/controller/reconciler/...` —
reconciler goleak tests pass

Signed-off-by: dongjiang <dongjiang1989@126.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testing Additional testing required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants