Skip to content
This repository was archived by the owner on May 30, 2025. It is now read-only.

test: migrate to testcontainers#22

Merged
tzdybal merged 1 commit intomainfrom
tzdybal/testcontainers
Feb 10, 2025
Merged

test: migrate to testcontainers#22
tzdybal merged 1 commit intomainfrom
tzdybal/testcontainers

Conversation

@tzdybal
Copy link
Contributor

@tzdybal tzdybal commented Feb 10, 2025

Overview

Migrate existing, raw-docker handling of containers in test to testcontainers.

Resolves #18

Summary by CodeRabbit

Summary by CodeRabbit

  • Chores

    • Refined project dependency management with several updates, additions, and removals to improve overall stability.
  • Tests

    • Enhanced integration testing by streamlining container orchestration and cleanup—simplifying the test setup for better reliability.

@coderabbitai
Copy link

coderabbitai bot commented Feb 10, 2025

Walkthrough

This pull request updates the dependency management and test setup of the project. The go.mod file now includes several new indirect dependencies, updates version numbers for existing ones, and removes an unused dependency. In addition, the integration test setup in integration_test.go replaces direct Docker client interactions with the Testcontainers library for more streamlined container lifecycle management.

Changes

File(s) Change Summary
go.mod - Added new indirect dependencies (e.g., dario.cat/mergo, github.com/AdaLogics/go-fuzz-headers, testcontainers-go, etc.)
- Updated versions for golang.org/x/crypto and golang.org/x/sys
- Removed gotest.tools/v3 dependency
integration_test.go - Replaced Docker client usage with the Testcontainers library
- Updated container configuration using testcontainers.ContainerRequest
- Simplified container startup and cleanup processes

Sequence Diagram(s)

sequenceDiagram
    participant IT as Integration Test
    participant TC as Testcontainers Library
    participant CR as Container Runtime
    
    IT->>TC: Define ContainerRequest (image, entrypoint, ports, etc.)
    TC->>CR: Create and start container
    CR-->>TC: Container instance and status
    TC-->>IT: Return container instance for testing
    IT->>TC: On completion, initiate cleanup
    TC->>CR: Cleanup container resources
Loading

Assessment against linked issues

Objective Addressed Explanation
Resolve Docker client/server compatibility issue (#18)

Suggested reviewers

  • gupadhyaya
  • MSevey

Poem

I’m a rabbit, hopping with glee,
Updates and tests as smooth as can be.
Dependencies leap into place,
Containers dance with refined grace.
Cheers to changes bright and bold—
A joyful tale, digitally told!
🐇🌟

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 to generate docstrings for this PR. (Beta)
  • @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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@RollkitBot RollkitBot requested review from a team, MSevey, gupadhyaya and yarikbratashchuk and removed request for a team February 10, 2025 18:18
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🔭 Outside diff range comments (1)
go.mod (1)

117-123:

Details

🧩 Analysis chain

Verify testcontainers version compatibility.

The testcontainers version v0.35.0 is being used. Let's verify if this is the latest stable version.


🌐 Web query:

What is the latest stable version of testcontainers-go?

💡 Result:

The latest stable version of Testcontainers for Go as of February 2025 appears to be v0.34+, based on documentation showing functional additions like RequireContainerExec introduced in v0.34**.1**[9]. While specific minor versions aren't explicitly stated across all sources:

  • Recent updates include breaking changes for custom modules requiring error handling adjustments[4]
  • Dependency bumps align with Go 1.21+ compatibility[6][8]
  • Active development focuses on features like SSH port forwarding[4][7]

For installation:

go get github.com/testcontainers/testcontainers-go@latest

Always verify compatibility with your project’s Go runtime (supported versions include Go 1.21**+**)[1][6].

Citations:


Testcontainers-go version mismatch detected.
The web query indicates that the latest stable version is around v0.34+ (with evidence suggesting v0.34.1 as a reference), yet the repository’s go.mod specifies v0.35.0. Please verify whether using v0.35.0 is intentional (perhaps leveraging new or experimental features) or if a downgrade to the stable version is warranted.

  • Location: go.mod (line with github.com/testcontainers/testcontainers-go v0.35.0)
  • Action: Confirm that v0.35.0 has been fully validated in your project's context or consider reverting to v0.34.x for stability.
🧹 Nitpick comments (1)
integration_test.go (1)

122-126: Consider adding container startup timeout.

While the container setup looks good, it's recommended to add a timeout for container startup to prevent indefinite waits in case of issues.

 	rethContainer, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
 		ContainerRequest: rethReq,
 		Started:          true,
+		Started: testcontainers.WithStartupTimeout(time.Minute),
 	})
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8016a54 and 1fc913f.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (2)
  • go.mod (5 hunks)
  • integration_test.go (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: test / Run Unit Tests
  • GitHub Check: test / Run Integration Tests
  • GitHub Check: lint / golangci-lint
🔇 Additional comments (3)
integration_test.go (2)

79-121: LGTM! Container configuration is now more declarative and maintainable.

The migration to Testcontainers has improved the code by:

  • Making container configuration more declarative and readable
  • Simplifying container lifecycle management
  • Using a standardized approach for container setup

129-131: LGTM! Proper cleanup using testcontainers helper.

The cleanup is now handled properly using the testcontainers helper function.

go.mod (1)

13-95: LGTM! Dependencies are properly updated for testcontainers.

The new indirect dependencies are all related to testcontainers and its requirements. Version updates appear to be compatible.

@tzdybal tzdybal added the enhancement New feature or request label Feb 10, 2025
Migrate existing, raw-docker handling of containers in test to testcontainers.
@tzdybal tzdybal force-pushed the tzdybal/testcontainers branch from 1fc913f to ea47ae9 Compare February 10, 2025 18:29
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
integration_test.go (1)

79-126: Consider adding container startup timeout and health check.

While the container setup looks good, it's recommended to add explicit timeout and health check configurations to handle potential startup issues gracefully.

Add timeout and health check configurations:

 rethReq := testcontainers.ContainerRequest{
     Name:       "reth",
     Image:      "ghcr.io/paradigmxyz/reth:v1.1.1",
     Entrypoint: []string{"/bin/sh", "-c"},
+    WaitingFor: wait.ForHTTP("/").WithPort("8545/tcp").WithStartupTimeout(30 * time.Second),
     Cmd: []string{
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1fc913f and ea47ae9.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (2)
  • go.mod (5 hunks)
  • integration_test.go (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test / Run Unit Tests
🔇 Additional comments (3)
integration_test.go (2)

16-20: LGTM! Import changes look good.

The imports have been updated to support testcontainers while maintaining the necessary Docker types for container configuration.


129-131: LGTM! Container cleanup looks good.

The cleanup is properly handled using testcontainers.CleanupContainer.

go.mod (1)

117-123: LGTM! Direct dependencies look good.

The direct dependencies, including testcontainers-go, are properly specified with appropriate versions.

@tzdybal tzdybal added this pull request to the merge queue Feb 10, 2025
Merged via the queue into main with commit 1da1d26 Feb 10, 2025
10 checks passed
@tac0turtle tac0turtle removed this from Evolve Apr 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ci: resolve docker client/server compatibility issue

2 participants