Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!(cockroachdb): use recommended cluster settings #2869

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

stevenh
Copy link
Collaborator

@stevenh stevenh commented Nov 1, 2024

Configures the cockroachdb container with the settings recommended by Cockroach Labs for testing clusters.

Simplify the connection handling in cockroachdb so that ConnectionString can be used without the user doing extra work to handle TLS if enabled.

Deprecate TLSConfig which is no longer needed separately.

BREAKING_CHANGE: This now returns a registered connection string so is no longer compatible with pgx.ParseConfig, use ConnectionConfig for this use case instead.

Copy link

netlify bot commented Nov 1, 2024

Deploy Preview for testcontainers-go ready!

Name Link
🔨 Latest commit c58631b
🔍 Latest deploy log https://app.netlify.com/sites/testcontainers-go/deploys/672a0f870e39050008034429
😎 Deploy Preview https://deploy-preview-2869--testcontainers-go.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@stevenh stevenh force-pushed the recommended-cluster-settings branch 2 times, most recently from 430200b to aaab322 Compare November 5, 2024 10:59
@stevenh stevenh force-pushed the recommended-cluster-settings branch from aaab322 to c58631b Compare November 5, 2024 12:28
Simplify the connection handling in cockroachdb so that ConnectionString
can be used without the user doing extra work to handle TLS if enabled.

Deprecate TLSConfig which is no longer needed separately.

BREAKING_CHANGE: This now returns a registered connection string so is
no longer compatible with pgx.ParseConfig, use ConnectionConfig for this
use case instead.
@stevenh stevenh added the breaking change Causing compatibility issues. label Nov 6, 2024
@stevenh stevenh changed the title feat: use recommended cluster settings for cockroachdb feat!(cockroachdb): use recommended cluster settings Nov 6, 2024
@stevenh stevenh marked this pull request as ready for review November 6, 2024 10:32
@stevenh stevenh requested a review from a team as a code owner November 6, 2024 10:32
@stevenh
Copy link
Collaborator Author

stevenh commented Nov 6, 2024

@martskins could you review these changes based on top of your PR #2869 please.

opts: []testcontainers.ContainerCustomizer{
cockroachdb.WithUser("foo"),
cockroachdb.WithPassword("bar"),
// Do not run the default statements as the user used on this test is
Copy link
Member

Choose a reason for hiding this comment

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

question: after reading this comment, is it possible to have a test using WithUser and with the default statements?

Choose a reason for hiding this comment

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

question: after reading this comment, is it possible to have a test using WithUser and with the default statements?

as long as the user has MODIFYCLUSTERSETTING privilege, yes

Copy link
Member

Choose a reason for hiding this comment

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

So at that point, the user must provide statements to configure the MODIFYCLUSTERSETTING privilege for the user in order this to work, right? Should the library grant this privilege automatically in the case the WithUser option is passed?

Copy link

@martskins martskins Nov 6, 2024

Choose a reason for hiding this comment

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

I suppose that could an option, yes. Alternatively, it looks like we don't allow using the TLS option with a user other than the default one (root), should we maybe do the same here?

Copy link
Member

Choose a reason for hiding this comment

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

We can probably do it in a follow-up. Wdyt? Would you like to be involved in that?

Choose a reason for hiding this comment

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

I'm happy to be involved, but if the preferred path is to make this error if default statements are used with a non-root user then it might be better to do it in this PR so we don't ship this only to introduce a breaking change to it right after? Although I suppose the cluster would fail to start in that scenario anyways so maybe it's not that much of a breaking change.

@martskins
Copy link

@martskins could you review these changes based on top of your PR #2869 please.

Looks good to me! 👍

Copy link
Member

@mdelapenya mdelapenya left a comment

Choose a reason for hiding this comment

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

@stevenh is this a breaking change? I do not see any change in the signatures of the public API, just changes in how we build the examples on how to use it, but maybe I'm wrong.

Other than that LGTM

@eddumelendez
Copy link
Member

FYI, I have raised an issue in CockroachDb repo in order to consider having an env var to apply those settings automatically and take advantage of it in other Testcontainers implementation without changes. See cockroachdb/cockroach#134429

@stevenh
Copy link
Collaborator Author

stevenh commented Nov 6, 2024

@stevenh is this a breaking change? I do not see any change in the signatures of the public API, just changes in how we build the examples on how to use it, but maybe I'm wrong.

Other than that LGTM

The connection handling is not 100% backwards compatible as detailed in the PR message:

This now returns a registered connection string so is no longer compatible with pgx.ParseConfig, use ConnectionConfig for this use case instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change Causing compatibility issues. enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants