Skip to content

test(source/cockroachdb): migrate integration tests to testcontainers#2672

Merged
duwenxin99 merged 6 commits intomainfrom
cockroach-fix
Mar 9, 2026
Merged

test(source/cockroachdb): migrate integration tests to testcontainers#2672
duwenxin99 merged 6 commits intomainfrom
cockroach-fix

Conversation

@duwenxin99
Copy link
Copy Markdown
Contributor

@duwenxin99 duwenxin99 commented Mar 9, 2026

This PR migrates the CockroachDB integration tests from relying on an external persistent database instance to using local, ephemeral Docker containers via testcontainers-go/modules/cockroachdb.
It will spin up an isolated cockroachdb/cockroach:latest-v23.1 container for each test run.

@duwenxin99 duwenxin99 requested a review from a team as a code owner March 9, 2026 03:43
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the CockroachDB integration tests to utilize testcontainers-go. This change enhances test reliability and isolation by dynamically provisioning a CockroachDB instance for each test run, eliminating external dependencies and simplifying the test setup process.

Highlights

  • Test Infrastructure Update: The CockroachDB integration tests were updated to use testcontainers-go for managing the CockroachDB instance.
  • Environment Variable Removal: The reliance on environment variables (COCKROACHDB_HOST, COCKROACHDB_PORT, etc.) for configuring CockroachDB connection details was removed.
  • Connection Logic Simplification: The initCockroachDBConnectionPool function was refactored to accept a direct connection string, simplifying its usage.
Changelog
  • go.mod
    • Added github.com/testcontainers/testcontainers-go/modules/cockroachdb as a new dependency.
  • tests/cockroachdb/cockroachdb_integration_test.go
    • Removed net/url and os imports.
    • Updated getCockroachDBVars to accept host and port parameters instead of relying on global environment variables.
    • Removed the getEnvOrDefault helper function.
    • Modified initCockroachDBConnectionPool to accept a connection string directly.
    • Integrated testcontainers-go to spin up a CockroachDB container for TestCockroachDB, dynamically retrieving connection details.
Ignored Files
  • Ignored by pattern: go.sum (1)
    • go.sum
Activity
  • No human activity has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the CockroachDB integration test to use testcontainers-go. This is an excellent improvement that makes the test self-contained and more reliable for CI and local development by removing the dependency on an externally configured database. The implementation is clean and correct. The only feedback is a minor suggestion regarding code formatting to adhere to standard Go style, specifically removing an unnecessary blank line.

Comment thread tests/cockroachdb/cockroachdb_integration_test.go Outdated
@duwenxin99 duwenxin99 changed the title ci: Change CockroachDB test source test(source/cockroachdb): migrate integration tests to testcontainers Mar 9, 2026
@duwenxin99 duwenxin99 merged commit f29f719 into main Mar 9, 2026
19 checks passed
@duwenxin99 duwenxin99 deleted the cockroach-fix branch March 9, 2026 14:41
dumians pushed a commit to dumians/genai-toolbox that referenced this pull request Mar 12, 2026
…googleapis#2672)

This PR migrates the CockroachDB integration tests from relying on an
external persistent database instance to using local, ephemeral Docker
containers via `testcontainers-go/modules/cockroachdb`.
It will spin up an isolated `cockroachdb/cockroach:latest-v23.1`
container for each test run.
NirajNandre pushed a commit to NirajNandre/genai-toolbox-fork that referenced this pull request Mar 24, 2026
…googleapis#2672)

This PR migrates the CockroachDB integration tests from relying on an
external persistent database instance to using local, ephemeral Docker
containers via `testcontainers-go/modules/cockroachdb`.
It will spin up an isolated `cockroachdb/cockroach:latest-v23.1`
container for each test run.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants