Skip to content
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

KAFKA-7342: Migrate tests in o.a.k.streams to JUnit 5 (except KafkaStreamsTest) #15942

Merged
merged 1 commit into from
May 17, 2024

Conversation

cadonna
Copy link
Contributor

@cadonna cadonna commented May 13, 2024

Migrates tests in org.apache.kafka.streams (excluding sub-packages) to JUnit 5.

KafkaStreamsTest is not migrated since it needs some more work due to unnecessary stubbings exceptions.

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

…Test)

Migrates tests in org.apache.kafka.streams (excluding sub-packages) to
JUnit 5.

KafkaStreamsTest is not migrated since it needs some more work due
to unnecessary stubbings exceptions.
@cadonna cadonna requested a review from clolov May 13, 2024 19:57
Copy link
Collaborator

@clolov clolov left a comment

Choose a reason for hiding this comment

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

Looks great to me!

@@ -330,8 +327,6 @@ public void shouldNotAllowToAddStateStoreToSink() {

private void mockStoreBuilder() {
when(storeBuilder.name()).thenReturn("store");
when(storeBuilder.logConfig()).thenReturn(Collections.emptyMap());
Copy link
Collaborator

Choose a reason for hiding this comment

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

I assume Mockito said these are unnecessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it is somehow strange. We tried to define Mockito with strict stubs but now with the migration to JUnit 5 it turns out that it was that strict after all. I haven't yet understood why we get unnecessary stubbing exceptions. 🤔
In this specific case, it does not make any difference from a stubbing point of view since the return values are the default return values. So instead of considering lenient, I just removed the stubs.

@clolov
Copy link
Collaborator

clolov commented May 14, 2024

There are some test failures of the following kind

[2024-05-14T03:28:54.106Z] Gradle Test Run :core:test > Gradle Test Executor 66 > KafkaZkClientTest > initializationError FAILED

[2024-05-14T03:28:54.106Z]     org.opentest4j.AssertionFailedError: Found 3 unexpected threads during @BeforeAll: `executor-Fetch,client-metrics-reaper,executor-raft-expiration-executor` ==> expected: <true> but was: <false>

I do not yet know whether these have been introduced by the MockitoExtensions in this PR or another PR which has already been merged

@cadonna
Copy link
Contributor Author

cadonna commented May 14, 2024

There are some test failures of the following kind

[2024-05-14T03:28:54.106Z] Gradle Test Run :core:test > Gradle Test Executor 66 > KafkaZkClientTest > initializationError FAILED

[2024-05-14T03:28:54.106Z]     org.opentest4j.AssertionFailedError: Found 3 unexpected threads during @BeforeAll: `executor-Fetch,client-metrics-reaper,executor-raft-expiration-executor` ==> expected: <true> but was: <false>

I do not yet know whether these have been introduced by the MockitoExtensions in this PR or another PR which has already been merged

This comes from there:

def verifyNoUnexpectedThreads(context: String): Unit = {

I do not think it is related to this PR, but I will have a closer look.

@cadonna cadonna changed the title MINOR: Migrate tests in o.a.k.streams to JUnit 5 (except KafkaStreamsTest) KAFKA-7342: Migrate tests in o.a.k.streams to JUnit 5 (except KafkaStreamsTest) May 14, 2024
Copy link
Contributor

@chia7712 chia7712 left a comment

Choose a reason for hiding this comment

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

LGTM

@chia7712 chia7712 merged commit 69fc4c5 into apache:trunk May 17, 2024
1 check failed
rreddy-22 pushed a commit to rreddy-22/kafka-rreddy that referenced this pull request May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants