kafka-ops / julie

A solution to help you build automation and gitops in your Apache Kafka deployments. The Kafka gitops!
MIT License
418 stars 113 forks source link

JUnit5 migration #534

Closed timtebeek closed 1 year ago

timtebeek commented 2 years ago

Migrate unit tests to JUnit 5 using:

mvn org.openrewrite.maven:rewrite-maven-plugin:4.32.0:run -Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-testing-frameworks:1.26.1 -DactiveRecipes=org.openrewrite.java.testing.junit5.JUnit5BestPractices

Had to fix a few minor imperfections, but otherwise mostly automated.

TODO

purbon commented 2 years ago

that would be awesome, thanks a lot @timtebeek

timtebeek commented 2 years ago

Yeah happy to help! Finally noticed that if I run mvn test -Prbac locally it actually matches some tests. Was a bit surprising that plain mvn test didn't match anything; but then I noticed the profiles and exclusions. Did I miss some instructions there for newcomers?

One in six now fail with unnecessary stubbing due to the Mockito upgrade; typically because of stubbing in a BeforeEach method. @MockitoSettings(strictness = Strictness.LENIENT) should see that sorted, but it's back to work first for me. :)

timtebeek commented 2 years ago

Just FYI; the Run link in CONTRIBUTING.md is not working anymore.

timtebeek commented 2 years ago

The tests weren't run because of mismatched versions of surefire/failsafe; Fixed in https://github.com/kafka-ops/julie/pull/534/commits/cd3f0fcb6474ba6efc6806ace4b59ed72a0c0c70. @purbon Would you mind running the tests? :pray:

purbon commented 2 years ago

from the latest IT test run:

[INFO] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 107.204 s - in com.purbon.kafka.topology.integration.ConnectorManagerIT
[INFO] 
[INFO] Results:
[INFO] 
Error:  Failures: 
Error:    TopicManagerIT.topicCreation:121->verifyTopics:398->verifyTopics:418 Internal topics not found ==> expected: <true> but was: <false>
[INFO] 
Error:  Tests run: 62, Failures: 1, Errors: 0, Skipped: 0
[INFO] 
[INFO] ------------------------
timtebeek commented 2 years ago

I'm looking at the test now; it does indeed also fail locally. The test executes a plan to create two topics, which are indeed created.

What's unclear to me is why the test asserts there should also be some hidden topics. When I run the same test locally on master, that same test also fails without internal topics.

Could it be something else that's causing the test failure? There's hardly any relevant changes there in the PR.

timtebeek commented 1 year ago

@purbon the test failures was resolved in https://github.com/kafka-ops/julie/pull/534/commits/cf59d8d76475b0ffa968380ecb9b72666bdcb4d8; hope you agree!

timtebeek commented 1 year ago

Closing this one due to inactivity & conflicts; feel free to cherry pick any of the manual fixes, and then reapply the automations either separately for quicker review & merge or aggregated through JUnit Jupiter best practices.