fix: service monitor recovery detection#318
Conversation
📝 WalkthroughWalkthroughThis PR adds explicit handling for the Changes
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
server/internal/monitor/service_instance_monitor.go (1)
209-220: Add targeted monitor tests for the newFailed-state branches.Please add/extend tests for: (1)
Failed+ healthy status ⇒ transition toRunningwith cleared error, (2)Failed+ nil status ⇒ no-op, (3)Failed+ status error ⇒ no state mutation.Based on learnings: “Ensure nil status is handled separately by handleNilStatus, and add tests to cover both nil and non-nil status scenarios to verify the default behavior and the explicit nil-status handling.”
Also applies to: 271-277
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@server/internal/monitor/service_instance_monitor.go` around lines 209 - 220, Add unit tests for the ServiceInstanceMonitor logic when a service instance is in database.ServiceInstanceStateFailed: (1) simulate a non-nil healthy status and assert that m.updateState is called with database.ServiceInstanceStateRunning and the error/message cleared, (2) simulate a nil status and assert the monitor routes to handleNilStatus and performs no state mutation, and (3) simulate a non-nil unhealthy status/error and assert m.updateStatus is called but no state transition occurs. Target the switch branch that invokes m.updateState and m.updateStatus (the Failed case) and the handleNilStatus path, using mocks/spies for updateState/updateStatus to verify calls and arguments for each scenario.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@server/internal/monitor/service_instance_monitor.go`:
- Around line 209-220: Add unit tests for the ServiceInstanceMonitor logic when
a service instance is in database.ServiceInstanceStateFailed: (1) simulate a
non-nil healthy status and assert that m.updateState is called with
database.ServiceInstanceStateRunning and the error/message cleared, (2) simulate
a nil status and assert the monitor routes to handleNilStatus and performs no
state mutation, and (3) simulate a non-nil unhealthy status/error and assert
m.updateStatus is called but no state transition occurs. Target the switch
branch that invokes m.updateState and m.updateStatus (the Failed case) and the
handleNilStatus path, using mocks/spies for updateState/updateStatus to verify
calls and arguments for each scenario.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 88a6213e-7df9-475e-a46d-1511d5856443
📒 Files selected for processing (1)
server/internal/monitor/service_instance_monitor.go
Summary
Test plan
PLAT-525