Skip to content

fix: mongodb replicaset should work with auth#2847

Merged
mdelapenya merged 13 commits intotestcontainers:mainfrom
abhipranay:fix/issue-2755-idea
Oct 28, 2024
Merged

fix: mongodb replicaset should work with auth#2847
mdelapenya merged 13 commits intotestcontainers:mainfrom
abhipranay:fix/issue-2755-idea

Conversation

@abhipranay
Copy link
Copy Markdown
Contributor

What does this PR do?

This PR fixes the bug for mongodb module where container doesn't start when WithReplicaSet option is used in combination with WithUsername and WithPassword.

Why is it important?

Fixes the issue mentioned in #2755.
Idea here is to use wrapping entrypoint so that security keyfile can be created with proper permissions and under correct ownership.
Wrapper entrypoint is used only when necessary and not always.

The functional option pattern make it difficult to figure out what were all the configured options so we are using req.Env to share data across funtions.

Related issues

@netlify
Copy link
Copy Markdown

netlify bot commented Oct 22, 2024

Deploy Preview for testcontainers-go ready!

Name Link
🔨 Latest commit e5f0a9b
🔍 Latest deploy log https://app.netlify.com/sites/testcontainers-go/deploys/671907fd986ac90008f20f45
😎 Deploy Preview https://deploy-preview-2847--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.

@abhipranay abhipranay changed the title Fix/issue 2755 fix: mongodb replicaset should work with auth Oct 22, 2024
@abhipranay abhipranay marked this pull request as ready for review October 22, 2024 22:56
@abhipranay abhipranay requested a review from a team as a code owner October 22, 2024 22:56
@abhipranay abhipranay marked this pull request as draft October 22, 2024 23:06
@abhipranay abhipranay marked this pull request as ready for review October 22, 2024 23:12
Copy link
Copy Markdown
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.

It LGTM, although I left a few comments. I tested it locally and it indeed resolves the issues described in the original ticket, so thank you for working on this

@abhipranay abhipranay requested a review from mdelapenya October 23, 2024 11:33
@mdelapenya mdelapenya self-assigned this Oct 23, 2024
@mdelapenya mdelapenya added the bug An issue with the library label Oct 23, 2024
mdelapenya
mdelapenya previously approved these changes Oct 23, 2024
Copy link
Copy Markdown
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.

LGTM, thanks for contributing the fix! Also for creating such a great commit history that allowed me to loop through it with ease.

@stevenh do you want to take a final look on it?

@mdelapenya
Copy link
Copy Markdown
Member

@abhipranay I added a commit on top with the fix for the lint: running make lint from the mongodb dir did the trick.

@abhipranay abhipranay requested a review from mdelapenya October 25, 2024 18:16
Copy link
Copy Markdown
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.

LGTM, thanks!

@mdelapenya mdelapenya merged commit 11eb809 into testcontainers:main Oct 28, 2024
mdelapenya added a commit that referenced this pull request Oct 28, 2024
* main:
  fix!: data races (#2843)
  fix: mongodb replicaset should work with auth (#2847)
  chore: use require.(No)Error(t,err) instead of t.Fatal(err) (#2851)
  fix: simplify fully-qualified image names (#2846)
mdelapenya added a commit to mdelapenya/testcontainers-go that referenced this pull request Oct 29, 2024
* main:
  chore: use require.Len instead of assert.Len (testcontainers#2854)
  chore: bump ryuk to 0.11.0 (testcontainers#2853)
  chore: enable usestdlibvars linter (testcontainers#2850)
  fix(compose): container initialisation (testcontainers#2844)
  fix!: data races (testcontainers#2843)
  fix: mongodb replicaset should work with auth (testcontainers#2847)
ttruongatl pushed a commit to ttruongatl/testcontainers-go that referenced this pull request Feb 15, 2025
* added custom entrypoint to setup keyfile with proper user permissions

* added testcases for replicaset with auth

* implementation to support replicaset with auth

* removed unnecessary files

* cleanup

* added autodetection for user:group and entrypoint

* added tests for replica set and auth for different images

* renamed entrypoint to differentiate between custom entrypoint of testcontainers

* code cleanup

* renamed newly added tests

* fixed names of tests to use slash separated options

* fix: lint

---------

Co-authored-by: Manuel de la Peña <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug An issue with the library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Error when using WithUsername and WithPassword with the WithReplicaSet option

2 participants