Skip to content

feat(embedded-mongodb): add support to launch mongo as a replicaset#2698

Merged
ijusti merged 5 commits intoPlaytikaOSS:developfrom
metron2:feat/embedded-mongodb-replicaset
Dec 11, 2025
Merged

feat(embedded-mongodb): add support to launch mongo as a replicaset#2698
ijusti merged 5 commits intoPlaytikaOSS:developfrom
metron2:feat/embedded-mongodb-replicaset

Conversation

@metron2
Copy link
Contributor

@metron2 metron2 commented Dec 6, 2025

My team is using mongo change streams for more and more things, but it's a little difficult to make test containers launch mongod as a replicaset. I saw there was an open issue for this #1182 so hopefully people are interested.

The documentation for the mongo container is really sparse on how to do this, so if nothing else this will help others. I included some test and cleaned-up the mongo stuff a little too.

Thanks for this fantastic project.

Copy link
Collaborator

@ijusti ijusti left a comment

Choose a reason for hiding this comment

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

Thanks for contribution, docs and tests

@codecov
Copy link

codecov bot commented Dec 8, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (074d7cd) to head (75b7640).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files
@@               Coverage Diff               @@
##             develop     #2698       +/-   ##
===============================================
+ Coverage      82.03%   100.00%   +17.96%     
+ Complexity       685        19      -666     
===============================================
  Files            205         5      -200     
  Lines           3111        70     -3041     
  Branches         144         2      -142     
===============================================
- Hits            2552        70     -2482     
+ Misses           489         0      -489     
+ Partials          70         0       -70     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

// renovate: datasource=docker
// https://hub.docker.com/_/mongo
return "mongodb/mongodb-community-server:8.0.10-ubuntu2204";
return "mongodb/mongodb-community-server:8.2.2-ubuntu2204";
Copy link
Collaborator

Choose a reason for hiding this comment

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

update also version in other places metron2@4d635ab

Copy link
Collaborator

Choose a reason for hiding this comment

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

do not forget add it to readme

@metron2 metron2 force-pushed the feat/embedded-mongodb-replicaset branch from 998adb3 to 8288d13 Compare December 8, 2025 18:37
@metron2 metron2 requested a review from ijusti December 10, 2025 05:03
// renovate: datasource=docker
// https://hub.docker.com/_/mongo
return "mongodb/mongodb-community-server:8.0.10-ubuntu2204";
return "mongodb/mongodb-community-server:8.2.2-ubuntu2204";
Copy link
Collaborator

Choose a reason for hiding this comment

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

do not forget add it to readme

Comment on lines +50 to +55
assertThat(environment.getProperty("embedded.mongodb.port")).isNotEmpty();
assertThat(environment.getProperty("embedded.mongodb.host")).isNotEmpty();
assertThat(environment.getProperty("embedded.mongodb.username")).isNotEmpty();
assertThat(environment.getProperty("embedded.mongodb.password")).isNotEmpty();
assertThat(environment.getProperty("embedded.mongodb.database")).isNotEmpty();
assertThat(environment.getProperty("embedded.mongodb.replica-set-name")).isNotEmpty();
Copy link
Collaborator

Choose a reason for hiding this comment

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

do not use environment. add fields with spring Value annotation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was following the convention of the other test, do you want me to change both of them? I pretty much copied that one and added this line for the replicaset mode.

metron2 and others added 2 commits December 10, 2025 11:34
Co-authored-by: Oleksandr <ijusti@users.noreply.github.com>
Unfortunately the order seems to matter and it doesn't work this way

This reverts commit cf07395.
@ijusti ijusti merged commit 46dd5ce into PlaytikaOSS:develop Dec 11, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants