KAFKA-14001: Migrate streams module to JUnit 5 - Part 1#12285
KAFKA-14001: Migrate streams module to JUnit 5 - Part 1#12285cadonna merged 3 commits intoapache:trunkfrom
Conversation
|
Polite ask for a review from @divijvaidya @dengziming @Kvicii @mimaison. The decisions I have outlined in the description are reversible should there be objections to them :) |
|
@clolov thanks your PR, I think we should multiple modify. |
|
Thanks you submitting this change @clolov. This would greatly help us in moving towards getting rid of JUnit4 completely. 1\ To make the code review easier, could we please tackle the 2\ I agree with (and appreciate) your incremental approach towards this migration. We can handle the tests using parameterised separately. 3\ It would be helpful if you can document the high level changes required for the migration from Junit4 to Junit5 in the description of this PR. |
|
Okay, I will work on 1 and 3, thank you for the review. |
|
Thanks for the PR! |
|
Worth putting in a separate PR, but have you tried enabling the Jupiter parallel test runner? When I ran it on a work project, it improved build times by an order of magnitude |
|
@clolov Thank you for the PR! |
We use multiple forks at the gradle level, so we should not enable this. A couple more comments:
|
|
Hello! Thank you to everyone who has left a comment and suggestions for improvement. In the next few days I will aim to rework this pull request. In summary:
|
|
@cadonna @ijuma @divijvaidya @Kvicii I hope the latest commits address all of the suggestions above :) |
streams/src/test/java/org/apache/kafka/streams/integration/utils/IntegrationTestUtils.java
Outdated
Show resolved
Hide resolved
streams/src/test/java/org/apache/kafka/streams/integration/RestoreIntegrationTest.java
Outdated
Show resolved
Hide resolved
divijvaidya
left a comment
There was a problem hiding this comment.
LGTM! @cadonna this is ready for your review now.
|
Politely bumping the review @cadonna |
There was a problem hiding this comment.
Why did you not put this code into the setup() method?
There was a problem hiding this comment.
I cannot remember, so maybe there was no reason. When I was rebasing I noticed that this test has since been deleted (or moved to org.apache.kafka.connect.integration) so I believe it is safe to say I do not need to address this?
|
@clolov could you please rebase your PR since there are conflicts? |
|
Hey @cadonna, I rebased on top of trunk. Do let me know if there is something else you would like me to address :) |
|
Once I get acceptable builds, I am going to merge this PR! |
|
Failures are not related |
|
@clolov @divijvaidya I just checked and these tests are not run in the builds. I have also another PR in streams with tests that use junit5 and they are also not run in the builds. Does anybody of you know what is going on here? Here the tests that are run: https://ci-builds.apache.org/job/Kafka/job/kafka-pr/job/PR-12285/5/testReport/org.apache.kafka.streams.integration/ |
|
I don't know, but I can have a look in the upcoming days. |
|
Hey @clolov @cadonna
I made the above two changes and ensured that the modified test is run using With the above changes, we will still have tests which won't execute during build because at https://github.com/apache/kafka/blob/trunk/build.gradle#L466, we will only run tests with "integration" tag. A simple way to fix it is to run all Junit4 and Junit5 tests using the Jupiter platform. It is allowed if we use the JUnitVintageEngine. I will file a pull request soon to fix what I mentioned above. |
|
For other modules, we did the JUnit 5 migration in one PR to avoid this problem. As @divijvaidya mentioned, the build expects each module to be JUnit 4 or JUnit 5. |
|
@clolov we don't have to do it in one go. We can create a new project/task in |
|
@clolov Let's first try to make it work with the junit vintage engine. I am not clear if there is still an issue with powermock and junit5 and it seems like Streams still uses powermock. |
|
Personally, I would prefer to make the migration incrementally. |
|
Doing things incrementally over a long period of time is a bit confusing since you cannot enforce that JUnit 4 or JUnit 5 is used at any point in time. My take is that it's simplest if the conversion is done quickly. However, it's best to convert the tests to Mockito first - that part is more complicated and can be done incrementally. |
|
I agree that the migration should be done quickly.
For options 2 and 3 committers should be made aware to only accept JUnit 5 tests in new PRs. That should be easy for Streams. I am in favor of 3 because it happened to me that I already added some tests in JUnit5 in some of my PRs because I was not aware that JUnit 4 and JUnit 5 do not run alongside each other in our builds. Migrating the JUnit 5 tests to JUnit 4 in my PRs do not seem to be a big deal, though. I am also fine with option 1. Option 2 seems the oddest to me. I would like to know the preferences of @clolov and @divijvaidya since they are driving this migration? |
|
I am fine with 3 as long as we don't make changes that make it worse for modules that have already converted to JUnit 5. |
|
Divij and I also prefer option 3 because of the same reasons posted by Bruno. So the next steps on our side are:
I will be away until 2nd of August so Divij will provide updates on #12441. Once I am back I will continue with the plan as detailed above. Of course, if there are any suggestions for it to be done otherwise I am more than happy to discuss those. |
|
Option 3 says not to continue JUnit 5 migrations though (step 2) - it says to do the mockito migration first. |
|
Well somewhere between reading the comments, having a discussion and typing my response I confused the options. I don't see why allowing JUnit 4 tests to run alongside JUnit 5 tests albeit with a separate engine would be problematic while moving between them. After all, that's exactly what the vintage engine is supposed to do and what I as a developer want as an experience. I furthermore don't think enabling it on the overarching project level would be problematic. After all, there are two engines and JUnit 5 is smart enough to know which tests to run with which engine. To confirm/deny this statement I will add tests reports as Divij has suggested to the pull request for enabling the above change once I am back. What I am expecting the report to show is that more tests have been ran for streams and there has not been a change in the tests for other modules (barring flaky tests). As to "PowerMock/EasyMock -> Mockito done first", "pure JUnit 4 -> JUnit 5 done first" I don't see why order matters. The sets of pure JUnit 4 tests and JUnit 4 + PowerMock/EasyMock tests are disjoint and can be addressed separately. In other words, I do not see reasons to reject pull requests (such as this one) given they advance the state of the world to JUnit 5. As a summary, let me focus my efforts on #12441 if it has not been agreed upon and merged by the time I am back. I believe we all agree that is a prerequisite to any incremental change. After that I will be opening pull requests for moving from PowerMock/EasyMock to Mockito and whatever tests can already be moved to JUnit 5 and you can review and merge them in whatever order you prefer :) |
When the migration of the Streams project to JUnit 5 started with PR #12285, we discovered that the migrated tests were not run by the PR builds. This PR ensures that Streams' tests that are written in JUnit 4 and JUnit 5 are run in the PR builds. Co-authored-by: Divij Vaidya <diviv@amazon.com> Reviewers: Ismael Juma <ismael@juma.me.uk>, Bruno Cadonna <cadonna@apache.org>
This pull request addresses https://issues.apache.org/jira/browse/KAFKA-14001. It is the first of a series of pull requests which address the move of Kafka Streams tests from JUnit 4 to JUnit 5.
The below description is kept to track the history of this pull request.
Committer Checklist (excluded from commit message)