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

chore(agent/agentcontainers): test current prebuilds integration#19074

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

Conversation

DanielleMaywood
Copy link
Contributor

As it turns out, prebuilds + devcontainers appear to already work together. This PR has created a test that simulates a prebuild claim happening toagentcontainers.API, to see how we handle it.

@DanielleMaywoodDanielleMaywood marked this pull request as ready for reviewJuly 30, 2025 11:15
@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.

@coderabbitaicoderabbitai
Copy link

📝 Walkthrough

Walkthrough

A new integration-style test,TestDevcontainerPrebuildSupport, was added to validate the behavior of devcontainers during the transition from a prebuild workspace to a claimed workspace. The test checks environment variable correctness, container reuse, and agent creation across both phases using mocks for dependencies.

Changes

Cohort / File(s)Change Summary
Devcontainer Prebuild Support Test
agent/agentcontainers/api_test.go
Added a new test functionTestDevcontainerPrebuildSupport to verify devcontainer behavior during prebuild-to-claimed workspace transitions, including environment variable propagation, container reuse, and agent lifecycle checks.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Suggested reviewers

  • mafredri
  • johnstcn

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 betweenbf78966 and2b97f35.

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

3819-4074:Well-structured integration test for prebuild support!

The test effectively validates the devcontainer lifecycle during workspace claim transitions. The two-phase approach with distinct manifest information and environment variable verification is appropriate.

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

🪧 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.
    • @coderabbitai modularize this function.
  • 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.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

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.

@DanielleMaywood
Copy link
ContributorAuthor

@coderabbitai generate sequence diagram

coderabbitai[bot] reacted with eyes emoji

@coderabbitaicoderabbitai
Copy link

Sequence Diagram for PR

sequenceDiagram    participant Test as TestDevcontainerPrebuildSupport    participant API as agentcontainers.API    participant MockContainer as Mock Container    participant MockAgent as Mock Agent    participant MockEnv as Mock Environment    Note over Test: Setup Phase    Test->>API: Initialize API with mocks    Test->>MockContainer: Setup container mock expectations    Test->>MockAgent: Setup agent mock expectations    Note over Test: Prebuild Phase Testing    Test->>API: Create prebuild workspace    API->>MockContainer: Create devcontainer for prebuild    MockContainer-->>API: Return container instance    API->>MockEnv: Set prebuild environment variables    MockEnv-->>API: Environment configured    API-->>Test: Prebuild workspace created    Note over Test: Validation Phase 1    Test->>API: Verify prebuild environment variables    API-->>Test: Environment variables correct    Test->>MockContainer: Verify container creation    MockContainer-->>Test: Container created as expected    Note over Test: Transition Phase Testing    Test->>API: Claim prebuild workspace    API->>MockContainer: Reuse existing container    MockContainer-->>API: Container reused successfully    API->>MockAgent: Create agent for claimed workspace    MockAgent-->>API: Agent created    API->>MockEnv: Update environment for claimed state    MockEnv-->>API: Environment updated    API-->>Test: Workspace claimed successfully    Note over Test: Validation Phase 2    Test->>API: Verify container reuse    API-->>Test: Same container instance used    Test->>MockAgent: Verify agent creation    MockAgent-->>Test: Agent created correctly    Test->>API: Verify environment transition    API-->>Test: Environment properly transitioned    Note over Test: Test Complete    Test->>Test: Assert all expectations met
Loading

@coderabbitaicoderabbitai
Copy link

✅ Actions performed

Sequence diagram generated.

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.

I like the principle and see definite value in this test, but worry that the amount of mocking being done here decreases the overall assurances we get.

I don't want to block this PR, but I would suggest adding another test with more of an integration-style approach that uses a well-known devcontainer repo and the 'real' Devcontainer CLI. We couldn't run this by default in CI though, which is the huge value of your current approach.

Comment on lines 3891 to 3896
mDCCLI.EXPECT().Up(gomock.Any(),testDC.WorkspaceFolder,testDC.ConfigPath,gomock.Any()).
Return("test-container-id",nil)

mCCLI.EXPECT().List(gomock.Any()).Return(codersdk.WorkspaceAgentListContainersResponse{
Containers: []codersdk.WorkspaceAgentContainer{testContainer},
},nil)
Copy link
Member

Choose a reason for hiding this comment

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

Should these also beInOrder?

@DanielleMaywood
Copy link
ContributorAuthor

@johnstcn Yeah I can do that. I've refactored the existing test to use thefake* utilities instead of mocking.

I'll make another integration style test (in line with our other docker only tests) as a more thorough test 👍

@DanielleMaywoodDanielleMaywoodforce-pushed thedanielle/test-devcontainer-prebuild-support branch from2db96b0 to9381e28CompareJuly 31, 2025 14:00
@DanielleMaywood
Copy link
ContributorAuthor

@johnstcn I have added an integration-style test now.

You can run it with

CODER_TEST_USE_DOCKER=1 go test ./agent -test.count 1 -test.run TestAgent_DevcontainerPrebuildClaim
johnstcn reacted with hooray emoji

@DanielleMaywoodDanielleMaywood merged commitddb5b87 intomainJul 31, 2025
26 checks passed
@DanielleMaywoodDanielleMaywood deleted the danielle/test-devcontainer-prebuild-support branchJuly 31, 2025 14:31
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsJul 31, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

@johnstcnjohnstcnjohnstcn approved these changes

@mafredrimafredriAwaiting requested review from mafredri

@SasSwartSasSwartAwaiting requested review from SasSwart

Assignees

@DanielleMaywoodDanielleMaywood

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@DanielleMaywood@johnstcn

[8]ページ先頭

©2009-2025 Movatter.jp