Skip to content

Migrate MongoDB tests to Testcontainers #3839

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

Closed
artembilan opened this issue Jul 8, 2022 · 2 comments
Closed

Migrate MongoDB tests to Testcontainers #3839

artembilan opened this issue Jul 8, 2022 · 2 comments

Comments

@artembilan
Copy link
Member

Currently our integration tests rely on the MongoDB server provided by the host of the test execution and use JUnit 4 rule for condition evaluation.
We cannot have externally configured MongoDB server on CI environment anymore, so SonarQube reports pure coverage, since most of MongoDB tests are ignored.

Switch integration tests for MongoDB to Testcontainers since Docker is available in most modern environments.
This way we also will be able to migrate all those tests to JUnit 5.

See MosquittoContainerTest for example.

@artembilan
Copy link
Member Author

@oxcafedead,

I wonder if you can now look into this since you have a similar experience migration Redis tests.

Thank you!

@oxcafedead
Copy link
Contributor

@artembilan,
Sure, I will take a look at this one.

oxcafedead added a commit to oxcafedead/spring-integration that referenced this issue Jul 18, 2022
Closes spring-projects#3839

* Create a new base interface for Mongo container-based tests
* Migrate all tests to JUnit5
* Remove obsolete classes related to JUnit4 Mongo rule
* Fix code style & readability here and there, a few Sonar issues
* Fix failing test `validateWithConfiguredPollerFlow`
* * This test was failing with Mongo error
`$and/$or/$nor must be a nonempty array`. The cause was too small
polling ratio of the update query, the consecutive read queries
failed as no 'Oleg' document was in collection after ~100 ms.
@artembilan artembilan modified the milestones: Backlog, 6.0.0-M4 Jul 18, 2022
oxcafedead added a commit to oxcafedead/spring-integration that referenced this issue Jul 19, 2022
Closes spring-projects#3839

Couple of changes after the pull request review:
* Get back the blank lines in test classes
* Get back the blank lines for some inner classes
* Eliminate bad renaming consequences
* Remove a couple of garbage todos
* Couple of places with code cleanup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants