-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Migrate Redis integration tests to Testcontainers #3840
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
Comments
I will take a look if no objections, there is one more interesting "bug" to deal with. |
Thank you, @oxcafedead ! Would you mind sharing what is that bug? Maybe it worth to raise a GH issue on the matter? |
@artembilan it should go away after the migration. It fails after my migration, so I disabled it. Probably the original author should take a look at it eventually because I don't understand how this test is intended to work (besides the typo in the test name and assertions, it operates with non-used mocks in the 'given' stage). In main branch, this test is marked as 'passed' with almost immediate timing. This is because inside |
Thank you! |
The logic of the test does not reflect the state of the `RedisLockRegistry` around `ulinkAvailable` property: we don't check the Redis version anymore, but try to call `UNLINK` command. Then we reset `ulinkAvailable` to `false` to call regular `DEL` for the rest of `RedisLockRegistry` life The `RedisAvailableRule` marks `testUlink()` as passed even without calling it. We are not going to look into fixing the rule since we are migrating to Testcontainers: #3840
Here it is: 79d31b2 |
Ok, I will rebase then, I hope there will be not too many conflicts :) |
Fixes spring-projects#3840 * Create a new abstraction `RedisTest` for Testcontainers-based tests * Move existing common utility methods to the new interface * Migrate all existing Redis tests to use this new `RedisTest` interface * Migrate all existing Redis tests to JUnit5 * Make all existing Redis tests confirming to JUnit5 standards, such as default methods and classes visibility instead of public * Add a dependency for parametrized tests in JUnit5 * Improve assertions readability across tests, for instance: assertThat(thing.size()).isEqualTo(2) -> assertThat(thing).hasSize(2) * Add real assertions to `RedisLockRegistryTests.twoRedisLockRegistryTest` (earlier it did not have assertions at all) * Reformat, rearrange and cleanup the code
Fix a couple of small changes after the code review: * Change base interface name to be consistent with other similar places * Typo in javadocs
Small tests readability improvement regarding assertions
Currently our integration tests rely on the Redis server provided by the host of the test execution and use JUnit 4 rule for condition evaluation.
We cannot have externally configured Redis server on CI environment anymore, so SonarQube reports pure coverage, since most of Redis tests are ignored.
Switch integration tests for Redis 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.The text was updated successfully, but these errors were encountered: