-
-
Notifications
You must be signed in to change notification settings - Fork 503
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
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for testcontainers-go ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
f704010
to
d34f4f2
Compare
d34f4f2
to
8f29ffd
Compare
430200b
to
aaab322
Compare
…list of statements
Co-authored-by: Steven Hartland <stevenmhartland@gmail.com>
Co-authored-by: Steven Hartland <stevenmhartland@gmail.com>
… in defaultOptions
Co-authored-by: Manuel de la Peña <social.mdelapenya@gmail.com>
… to DefaultStatements
aaab322
to
c58631b
Compare
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.
@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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Looks good to me! 👍 |
There was a problem hiding this 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
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 |
The connection handling is not 100% backwards compatible as detailed in the PR message:
|
I think this is ready to be merge, but let's wait a bit until @eddumelendez 's question is addressed in the upstream project. That would be a good improvement if all the TC languages would benefit from this, instead of having each custom code. |
In order to follow the suggestion, the wait strategy should also check if a file was created. See testcontainers/testcontainers-java#9505. This approach is valid for CockroachDB >= 22.1.0 |
Thanks @eddumelendez I've incorporated that into refactored approach for the go CockroachDB module in #2883 This is still draft but I think the changes improve the flow, avoiding manually creating certs which prevents a bunch of the edge cases in the current version as well as streamlining to logic so users can use the functional options with less restrictions. Be interested in feedback. |
Converted this to draft while we discuss the different approaches |
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
, useConnectionConfig
for this use case instead.