- Notifications
You must be signed in to change notification settings - Fork1k
fix(agent/agentcontainers): fixTestDevcontainerDiscovery/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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
… flakeFixescoder/internal#864I've ripped out the mock infrastructure for this test, and have insteadreplaced 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 testTestDevcontainerDiscovery/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")
Uh oh!
There was an error while loading.Please reload this page.
📝 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 morehere, 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 withCodeRabbit:
SupportNeed help? Create a ticket on oursupport 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 👍🏻
760dc8b
intomainUh oh!
There was an error while loading.Please reload this page.
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.
Suggestassert
here instead.
// And: `up` was called on the correct containers | ||
forconfigPath,config:=rangett.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 callup
for something not inconfig.Configuration.Customizations.Coder.AutoStart
?
Fixescoder/internal#864