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-14006: Parameterize WorkerConnectorTest suite #12307

Merged
merged 1 commit into from Jun 8, 2023

Conversation

C0urante
Copy link
Contributor

Jira

Tweaks this test class to add complete coverage for both source and sink connectors. This helped unearth a NullPointerException in the shutdown logic for sink connectors introduced by a not-yet-released change for KIP-618.

Committer Checklist (excluded from commit message)

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

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.

Hello! I believe there is a general push to replace PowerMock and EasyMock with Mockito here https://issues.apache.org/jira/browse/KAFKA-7438. Since I have been involved with the JUnit 4 to JUnit 5 migration I have also started looking out for PowerMock, EasyMock -> Mockito opportunities (or at the very least to not make the migration effort harder). Would you be willing to, instead of changing from EasyMock to PowerMock to try and change things to Mockito directly so we can alleviate some future effort?

Copy link
Collaborator

@vamossagar12 vamossagar12 left a comment

Choose a reason for hiding this comment

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

Only 1 minor comment. Other than that, LGTM.

Comment on lines 177 to 183
if (connectorType == ConnectorType.SOURCE) {
offsetStorageReader.close();
expectLastCall();

offsetStore.stop();
expectLastCall();
offsetStore.stop();
expectLastCall();
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I see these lines repeat in a few tests. Would it be better to move them to a separate method and invoke that method here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't see this as significantly different than a lot of the other repeated sections in the test, such as the expectations for clean startup of a non-paused connector. While it might be nice to fold some of these sections into reusable methods, the changes here don't make this repetition any worse than it already is, and I'm worried that decomposing them might complicate the Mockito transition that @clolov has mentioned.

Copy link
Collaborator

Choose a reason for hiding this comment

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

hmm I did see the other repeated sections in the tests but since they are out of scope for the context of this PR, didn't bring them up. I guess we can live with these newer repetitions.

@C0urante
Copy link
Contributor Author

@clolov Hi! I'm aware of the effort to transition to Mockito; I don't think this change makes that transition significantly harder. There are already examples of parameterized tests in the Connect code base that use Mockito (such as the WorkerTest suite) that can be followed when we make that transition for this test suite, and all of the other logic in the changes here is trivial to translate between the two mocking libraries. I'd rather keep the changes here focused and in-scope for the ticket that they aim to address, so I would prefer not to add switching over to a new mocking library to this PR.

@clolov
Copy link
Collaborator

clolov commented Jun 20, 2022

Okay, your reasoning makes sense to me. Would you not need to add the class to the list in https://github.com/apache/kafka/blob/trunk/build.gradle#L397-L416?

@C0urante
Copy link
Contributor Author

C0urante commented Jun 20, 2022

@clolov I don't think it's necessary to add these tests to that list since they're still passing locally with Java versions 16-18 and on Jenkins with Java 17. It's a little risky to add tests to that list, too, since it causes them to be skipped with Java versions 16+.

FWIW, it seems like the reason that tests still work is that they use the org.easymock.Mockorg.easymock.Mock annotation, instead of org.powermock.api.easymock.annotation.Mock, which is used by at least some of the tests that have to be skipped for Java 16+.

@clolov
Copy link
Collaborator

clolov commented Jun 20, 2022

Got it, okay, looks good to me, thanks for the detailed explanation :)

@vamossagar12
Copy link
Collaborator

LGTM!

@C0urante
Copy link
Contributor Author

C0urante commented Jun 6, 2023

@mimaison @showuon if you have a moment, would you mind taking a look? Thanks!

Copy link
Member

@mimaison mimaison left a comment

Choose a reason for hiding this comment

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

LGTM

@C0urante
Copy link
Contributor Author

C0urante commented Jun 7, 2023

Rebuilt locally after rebasing on trunk and discovered a few small issues caused by newly-introduced tests; pushed a fix for those. Will merge pending CI build

@C0urante
Copy link
Contributor Author

C0urante commented Jun 8, 2023

Test failures appear unrelated; merging...

@C0urante C0urante merged commit 6b128d7 into apache:trunk Jun 8, 2023
1 check failed
@C0urante C0urante deleted the kafka-14006 branch June 8, 2023 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
5 participants