Skip to content

MINOR: make sure all generated data tests cover all versions#10078

Merged
chia7712 merged 6 commits into
apache:trunkfrom
chia7712:MINOR-10078
Mar 4, 2021
Merged

MINOR: make sure all generated data tests cover all versions#10078
chia7712 merged 6 commits into
apache:trunkfrom
chia7712:MINOR-10078

Conversation

@chia7712

@chia7712 chia7712 commented Feb 7, 2021

Copy link
Copy Markdown
Member

inspired by #10068

Committer Checklist (excluded from commit message)

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

@chia7712
chia7712 requested a review from dajac February 7, 2021 18:13
@chia7712 chia7712 changed the title MINOR: add missed versions to clients tests MINOR: Some tests in clients module does not cover all available versions Feb 8, 2021
public List<Short> allVersions() {
List<Short> versions = new ArrayList<>(latestVersion() - oldestVersion() + 1);
for (short version = oldestVersion(); version < latestVersion(); version++) {
for (short version = oldestVersion(); version <= latestVersion(); version++) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is not a critical bug as the method allVersions is used by testing only.

@chia7712 chia7712 changed the title MINOR: Some tests in clients module does not cover all available versions MINOR: make sure all generated data tests cover all versions Mar 3, 2021

@dajac dajac left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the PR. I have left few comments.

Comment thread clients/src/test/java/org/apache/kafka/common/requests/ProduceRequestTest.java Outdated
private static <T extends Throwable> void assertThrowsInvalidRecordExceptionForAllVersions(ProduceRequest.Builder builder,
Class<T> expectedType) {
for (short version = builder.oldestAllowedVersion(); version <= builder.latestAllowedVersion(); version++) {
short v = version;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could we get rid of v and use version below directly?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It requires final variable. I rewrite code by lambda foreach to eliminate duplicate intermediate variable.

Comment thread clients/src/test/java/org/apache/kafka/common/requests/RequestResponseTest.java Outdated
testEquivalentMessageRoundTrip(version, requestData);
} else if (version >= 2 && version <= 4) {
testAllMessageRoundTripsBetweenVersions(version, (short) 4, requestData, requestData);
testAllMessageRoundTripsBetweenVersions(version, (short) 5, requestData, requestData);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why are we changing this?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

testAllMessageRoundTripsBetweenVersions exclude the end number so it should pass 5 so as to test version 4

@dajac dajac left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks for the PR.

@chia7712
chia7712 merged commit be14768 into apache:trunk Mar 4, 2021
@chia7712
chia7712 deleted the MINOR-10078 branch March 25, 2024 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants