-
Notifications
You must be signed in to change notification settings - Fork 956
fix(agent/agentcontainers): fix TestDevcontainerDiscovery/AutoStart
flake
#19179
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
Conversation
… flake Fixes coder/internal#864 I've ripped out the mock infrastructure for this test, and have instead replaced it with our `fakeContainerCLI` and `fakeDevcontainerCLI` utilities.
@coderabbitai review |
✅ Actions performedReview triggered.
|
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.
Pull Request Overview
This PR fixes a flaky test TestDevcontainerDiscovery/AutoStart
by replacing gomock-based mocking with a deterministic fake implementation. The test was likely flaking due to race conditions or timing issues with mock expectations.
Key changes:
- Replace gomock mocking with a deterministic fake devcontainer CLI implementation
- Add explicit tracking of
Up
method calls to verify expected behavior - Simplify test structure by using data-driven configuration maps instead of complex mock setups
Comments suppressed due to low confidence (1)
agent/agentcontainers/api_test.go:773
- The assertion should use assert.Equal instead of require.Equal since this is inside a loop and a failure here should not prevent checking other configurations. Using require.Equal will stop the test immediately on first failure.
require.ErrorContains(t, got, tc.expectedErr, "want error")
📝 WalkthroughWalkthroughThe Changes
Sequence Diagram(s)sequenceDiagram
participant Test
participant FakeDevcontainerCLI
participant API
Test->>FakeDevcontainerCLI: Set up configMap and up function
Test->>API: Start API with FakeDevcontainerCLI
API->>FakeDevcontainerCLI: ReadConfig(configPath)
FakeDevcontainerCLI-->>API: Return DevcontainerConfig (with AutoStart)
API->>FakeDevcontainerCLI: Up(workspaceFolder, configPath) [if AutoStart]
FakeDevcontainerCLI-->>API: Record Up call
Test->>API: Wait for discovery and Up calls
Test->>Test: Assert correct Up invocations and devcontainer count
Test->>API: Close API
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15 minutes Assessment against linked issues
Assessment against linked issues: Out-of-scope changesNo out-of-scope changes were found. Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
🔇 Additional comments (4)
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
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.
LGTM 👍🏻
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.
Some (belated) comments below, but nothing blocking.
autoStart := config.Configuration.Customizations.Coder.AutoStart | ||
wasUpCalled := upCalledFor[configPath] | ||
|
||
require.Equal(t, autoStart, wasUpCalled) |
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.
Suggest assert
here instead.
// And: `up` was called on the correct containers | ||
for configPath, config := range tt.configMap { | ||
autoStart := config.Configuration.Customizations.Coder.AutoStart | ||
wasUpCalled := upCalledFor[configPath] |
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.
Will this handle the case where we call up
for something not in config.Configuration.Customizations.Coder.AutoStart
?
Fixes coder/internal#864