Skip to content

KAFKA-16557 Implemented OffsetFetchRequestState toStringBase and added a test for it in CommitRequestManagerTest#16115

Closed
brenden20 wants to merge 26 commits intoapache:trunkfrom
brenden20:16557
Closed

KAFKA-16557 Implemented OffsetFetchRequestState toStringBase and added a test for it in CommitRequestManagerTest#16115
brenden20 wants to merge 26 commits intoapache:trunkfrom
brenden20:16557

Conversation

@brenden20
Copy link
Copy Markdown
Contributor

I changed OffsetFetchRequestState toString to toStringBase. I also added the instance fields from OffsetFetchRequestState and RetriableState to the toStringBase method. Within RetriableState, I also added a getter method for expirationTimeMs for testing purposes.

I added a new test to CommitRequestManagerTest that tests the new toStringBase method. In the test, a string variable 'target' is instantiated and will be compared to the new toStringBase method. The test calls OffsetFetchRequestState toStringBase() and compares it to the target string. All tests in CommitRequestManagerTest pass.

brenden20 added 7 commits May 24, 2024 14:11
Changed toString() override to toStringBase() and implemented some fields in toStringBase()
Added test for OffsetFetchRequestState.toStringBase().
Added more relevant fields in toStringBase() and updated the test to reflect the changes in OffsetFetchRequestState.toStringBase()
Added println to toStringBase() test to see if it works. Also added example hashcode
Added an assertEquals statement
Added fields inherited from RetriableRequestState to the toStringBase method. Had to add a get method for expirationTimeMs to make it work.

Also updated the test to reflect the changes.
Remove hashcode comment
Copy link
Copy Markdown
Contributor

@kirktrue kirktrue left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, @brenden20!

I'd never really thought to add a unit test for toString(), but it's not a bad idea 👍

Just to echo @philipnee, revert any unnecessary whitespace/indentation changes.

brenden20 added 2 commits May 29, 2024 08:52
Added visible for testing comment
Updated toStringBase() to have better output formatting, also added a toString() method for MemberInfo class.

Updated toStringBase() test to reflect changes
@kirktrue
Copy link
Copy Markdown
Contributor

@brenden20, as mentioned on another one of your PRs, there's a checkstyle violation here. You can run this command locally to avoid waiting for the CI infrastructure to catch it:

./gradlew check -x test

@philipnee
Copy link
Copy Markdown
Contributor

hi @brenden20 - left some comments. lmk what do you think.

brenden20 added 2 commits June 3, 2024 09:16
Updated testOffsetFetchRequestStateToStringBase(), changed some variable scope and changed the target string slightly. Also made a small update to toStringBase() and MemberInfo.toString()
Fixed build error
@brenden20
Copy link
Copy Markdown
Contributor Author

@philipnee I have implemented all suggested changes except for the whitespace issue, I am going to use Emacs to try to figure it out

Copy link
Copy Markdown
Contributor

@kirktrue kirktrue left a comment

Choose a reason for hiding this comment

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

LGTM! Can we move this from Draft to Ready to review?

@brenden20 brenden20 marked this pull request as ready for review June 5, 2024 18:20
@brenden20
Copy link
Copy Markdown
Contributor Author

brenden20 commented Jun 5, 2024

Marked ready to review @kirktrue


String target = requestState.toStringBase() +
", memberInfo=" + memberInfo +
", expirationTimeMs=" + (offsetFetchRequestState.expirationTimeMs().isPresent() ? offsetFetchRequestState.expirationTimeMs() : "undefined") +
Copy link
Copy Markdown
Contributor

@philipnee philipnee Jun 9, 2024

Choose a reason for hiding this comment

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

we can directly do expirationTimeMs=1000 here. in this case we do that we don't need to change the scope of expirationTimeMs()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Looking at the code, I am able to do this, however it will cause an issue with OffsetFetchRequestState.toStringBase(). expirationTimeMs() is needed to implement the toStringBase() method, since OffsetFetchRequestState cannot access RetriableRequestState.expirationTimeMs since it is a private field.

@brenden20 brenden20 marked this pull request as draft June 11, 2024 19:11
@brenden20
Copy link
Copy Markdown
Contributor Author

Had a lot of merge issues, was taking too much time to fix so I made a new branch with my changes. New PR is here: #16291

@brenden20 brenden20 closed this Jun 11, 2024
@brenden20 brenden20 deleted the 16557 branch June 13, 2024 18:03
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.

3 participants