Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
DanielleMaywood merged 2 commits intomainfromdanielle/fix-devcontainer-flake
Aug 5, 2025

Conversation

DanielleMaywood
Copy link
Contributor

… flakeFixescoder/internal#864I've ripped out the mock infrastructure for this test, and have insteadreplaced it with our `fakeContainerCLI` and `fakeDevcontainerCLI`utilities.
@DanielleMaywoodDanielleMaywood marked this pull request as ready for reviewAugust 5, 2025 12:28
@DanielleMaywood
Copy link
ContributorAuthor

@coderabbitai review

coderabbitai[bot] reacted with eyes emoji

@coderabbitaicoderabbitai
Copy link

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

@CopilotCopilotAI left a 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 ofUp 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")

@coderabbitaicoderabbitai
Copy link

📝 Walkthrough

Walkthrough

TheTestDevcontainerDiscovery test inagent/agentcontainers/api_test.go was refactored and enhanced to robustly verify the auto-start behavior of devcontainers. The test infrastructure now uses a configurable fake CLI implementation, enabling dynamic configuration and tracking of which devcontainers are started based on theirAutoStart setting. The test covers multiple auto-start scenarios and asserts correct behavior.

Changes

Cohort / File(s)Change Summary
Devcontainer Discovery Test Refactor
agent/agentcontainers/api_test.go
RefactoredTestDevcontainerDiscovery to use a customfakeDevcontainerCLI with dynamic config andUp tracking. Added/updated subtests for various auto-start scenarios. Modified method signatures and struct fields to support new test logic. Removed gomock usage in favor of internal call tracking.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Assessment against linked issues

ObjectiveAddressedExplanation
EnsureTestDevcontainerDiscovery/AutoStart/MultipleEnabled reliably verifies multiple enabled devcontainers auto-start (#864)
Remove reliance on gomock for Up calls in devcontainer discovery tests (#864)
Track and assert correct Up invocations for devcontainers with AutoStart enabled (#864)

Assessment against linked issues: Out-of-scope changes

No 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 details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between8b66a5a and72514f8.

📒 Files selected for processing (1)
  • agent/agentcontainers/api_test.go (5 hunks)
🔇 Additional comments (4)
agent/agentcontainers/api_test.go (4)

74-85:Good refactoring to improve test flexibility.

The addition of theup function field andconfigMap enables dynamic behavior in tests, making it easier to verify which devcontainers are started based on their configuration. This is a cleaner approach than using mocks for this use case.


87-102:Proper implementation of configurable Up behavior.

The method correctly delegates to the customup function when provided, while maintaining backward compatibility with the channel-based approach for existing tests.


118-135:Excellent implementation of path-specific configuration.

TheReadConfig method now properly supports returning different configurations based on the config path, which is crucial for testing multiple devcontainers with varyingAutoStart settings.


3583-3846:Excellent refactoring of the AutoStart test to address flakiness.

The test has been significantly improved:

  1. Replaced gomock expectations with a deterministic fake implementation that tracksUp calls
  2. Added comprehensive test scenarios covering different AutoStart configurations
  3. Uses proper synchronization with mutex to track concurrent operations
  4. Verifies both the discovery of devcontainers and thatUp is called only for those withAutoStart: true

This approach should resolve the flaky test issue by providing better control over the test execution flow and eliminating timing dependencies.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branchdanielle/fix-devcontainer-flake

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat withCodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag@coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag@coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on oursupport page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings togenerate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add@coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add@coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add@coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit ourDocumentation for detailed information on how to use CodeRabbit.
  • Join ourDiscord Community to get help, request features, and share feedback.
  • Follow us onX/Twitter for updates and announcements.

Copy link
Member

@mafredrimafredri left a comment

Choose a reason for hiding this comment

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

LGTM 👍🏻

@DanielleMaywoodDanielleMaywood merged commit760dc8b intomainAug 5, 2025
28 checks passed
@DanielleMaywoodDanielleMaywood deleted the danielle/fix-devcontainer-flake branchAugust 5, 2025 12:58
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsAug 5, 2025
Copy link
Member

@johnstcnjohnstcn left a 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)
Copy link
Member

@johnstcnjohnstcnAug 5, 2025
edited
Loading

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]
Copy link
Member

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?

Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@johnstcnjohnstcnjohnstcn left review comments

Copilot code reviewCopilotCopilot left review comments

@mafredrimafredrimafredri approved these changes

Assignees

@DanielleMaywoodDanielleMaywood

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

[flake] TestDevcontainerDiscovery/AutoStart/MultipleEnabled
3 participants
@DanielleMaywood@mafredri@johnstcn

[8]ページ先頭

©2009-2025 Movatter.jp