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-16472: Fix integration tests in Java with parameter name #15663

Merged
merged 1 commit into from
Apr 6, 2024

Conversation

FrankYang0529
Copy link
Member

@FrankYang0529 FrankYang0529 commented Apr 5, 2024

Following test cases don't really run kraft case. The reason is that the test info doesn't contain parameter name, so it always returns false in TestInfoUtils#isKRaft.

  • TopicCommandIntegrationTest
  • DeleteConsumerGroupsTest
  • AuthorizerIntegrationTest
  • DeleteOffsetsConsumerGroupCommandIntegrationTest

We can fix it by adding options.compilerArgs << '-parameters' after

kafka/build.gradle

Lines 264 to 273 in 376e9e2

tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
options.compilerArgs << "-Xlint:all"
// temporary exclusions until all the warnings are fixed
if (!project.path.startsWith(":connect"))
options.compilerArgs << "-Xlint:-rawtypes"
options.compilerArgs << "-Xlint:-serial"
options.compilerArgs << "-Xlint:-try"
options.compilerArgs << "-Werror"

Also, we have to add String quorum to cases in DeleteOffsetsConsumerGroupCommandIntegrationTest.

Committer Checklist (excluded from commit message)

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

@showuon
Copy link
Contributor

showuon commented Apr 5, 2024

@FrankYang0529 , thanks for the fix! Nice catch!
Questions:

  1. How could we confirm the String quorum missing only in DeleteOffsetsConsumerGroupCommandIntegrationTest, not other places?
  2. How could we avoid this things happen in the future? Like adding some checking before the tests startup or something? Do you have any idea?

@FrankYang0529
Copy link
Member Author

  1. How could we avoid this things happen in the future? Like adding some checking before the tests startup or something? Do you have any idea?

I don't have a good idea to do the check in gradle or before the tests startup. The possible way maybe check whether TestInfo#getDisplayName contains . but not =.

For example, before the fix, DeleteOffsetsConsumerGroupCommandIntegrationTest#testDeleteOffsetsNonExistingGroup shows (String). and TopicCommandIntegrationTest#testCreate shows (String).zk or (String).kraft.

After the fix, both test cases show (String).quorum=zk or (String).quorum=kraft. So we can know that if display name has ., but not =, it means the case misses parameter name.

However, this way still doesn't check whether "parameter name" is correct. Probably, we can give another check is that if display name contains zk or kraft, but not quorum, then throwing error in TestInfoUtils#isKRaft.

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
Copy link
Contributor

chia7712 commented Apr 5, 2024

However, this way still doesn't check whether "parameter name" is correct. Probably, we can give another check is that if display name contains zk or kraft, but not quorum, then throwing error in TestInfoUtils#isKRaft.

@FrankYang0529 Could you file jira to trace this?

build.gradle Outdated
@@ -270,6 +270,7 @@ subprojects {
options.compilerArgs << "-Xlint:-serial"
options.compilerArgs << "-Xlint:-try"
options.compilerArgs << "-Werror"
options.compilerArgs << "-parameters"
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add comments for this arg?

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated it. Thank you.

@FrankYang0529
Copy link
Member Author

However, this way still doesn't check whether "parameter name" is correct. Probably, we can give another check is that if display name contains zk or kraft, but not quorum, then throwing error in TestInfoUtils#isKRaft.

@FrankYang0529 Could you file jira to trace this?

Yes, added it. https://issues.apache.org/jira/browse/KAFKA-16476

@showuon
Copy link
Contributor

showuon commented Apr 5, 2024

Sorry @FrankYang0529 , I saw this: https://stackoverflow.com/questions/44067477/drawbacks-of-javac-parameters-flag

Briefly, the stated reasons to make parameter names optional are concerns about class file size, compatibility surface, and exposure of sensitive information.

I think the class file size increasing is indeed a direct drawback after adding -parameter option because we'll include all the parameters into .class files. I'd like to know if there's any other way to fix this? Could we use ARGUMENTS instead of ARGUMENTS_WITH_NAMES?

@chia7712
Copy link
Contributor

chia7712 commented Apr 5, 2024

I think the class file size increasing is indeed a direct drawback after adding -parameter option because we'll include all the parameters into .class files. I'd like to know if there's any other way to fix this? Could we use ARGUMENTS instead of ARGUMENTS_WITH_NAMES?

Or we can add the new arg to compileTestJava only to avoid impacting production binary

Signed-off-by: PoAn Yang <payang@apache.org>
@FrankYang0529
Copy link
Member Author

I think the class file size increasing is indeed a direct drawback after adding -parameter option because we'll include all the parameters into .class files. I'd like to know if there's any other way to fix this? Could we use ARGUMENTS instead of ARGUMENTS_WITH_NAMES?

Or we can add the new arg to compileTestJava only to avoid impacting production binary

Updated it as compileTestJava.options.compilerArgs.add "-parameters". Thanks for the suggestion @chia7712 @showuon .

@chia7712
Copy link
Contributor

chia7712 commented Apr 5, 2024

@ijuma Could you please take a look at this PR?

@chia7712
Copy link
Contributor

chia7712 commented Apr 6, 2024

I'm going to merge this PR in order to make other tool tests can run with KRaft. We can address all late reviews in other PRs.

@chia7712 chia7712 merged commit 5c1b819 into apache:trunk Apr 6, 2024
1 check failed
@FrankYang0529 FrankYang0529 deleted the KAFKA-16472 branch April 6, 2024 02:44
chia7712 pushed a commit that referenced this pull request Apr 6, 2024
Following test cases don't really run kraft case. The reason is that the test info doesn't contain parameter name, so it always returns false in TestInfoUtils#isKRaft.

1) TopicCommandIntegrationTest
2) DeleteConsumerGroupsTest
3) AuthorizerIntegrationTest
4) DeleteOffsetsConsumerGroupCommandIntegrationTest

We can fix it by adding options.compilerArgs << '-parameters' after

Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
@showuon
Copy link
Contributor

showuon commented Apr 6, 2024

LGTM! Thanks @FrankYang0529 ! Really nice catch!

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