HDDS-12807. Clean up TestKeyManagerImpl unit test#10640
Open
echonesis wants to merge 1 commit into
Open
Conversation
adoroszlai
reviewed
Jul 2, 2026
adoroszlai
left a comment
Contributor
There was a problem hiding this comment.
Thanks @echonesis for the patch. Overall LGTM, few minor improvements suggested.
| for (int j = 0; j < testCase.getNumberOfBucketsPerVolume(); j++) { | ||
| for (int k = 0; k < testCase.getNumberOfKeysPerBucket(); k++) { | ||
| String key = getTableKey(volumeNamePrefix, i, bucketNamePrefix, j, keyPrefix, k); | ||
| V value = valueClass == String.class ? (V) key : mock(valueClass); |
Contributor
There was a problem hiding this comment.
This lets us avoid the need for SuppressWarnings("unchecked"):
Suggested change
| V value = valueClass == String.class ? (V) key : mock(valueClass); | |
| V value = valueClass == String.class ? valueClass.cast(key) : mock(valueClass); |
| throws IOException { | ||
| @ParameterizedTest(name = "{0}") | ||
| @MethodSource("getSuccessfulTableIteratorParameters") | ||
| public void testGetDeletedKeyEntries(TableIteratorTestCase testCase) throws IOException { |
Contributor
There was a problem hiding this comment.
Class 'TableIteratorTestCase' is exposed outside its defined visibility scope
Suggested change
| public void testGetDeletedKeyEntries(TableIteratorTestCase testCase) throws IOException { | |
| void testGetDeletedKeyEntries(TableIteratorTestCase testCase) throws IOException { |
Also applies to other parameterized test methods.
Since JUnit 5, test methods do not need to be public. It's better to keep them package-private for simplicity/brevity regardless of this warning.
| String bucketNamePrefix = "bucket"; | ||
| String keyPrefix = "key"; | ||
| OzoneConfiguration configuration = new OzoneConfiguration(); | ||
| OMMetadataManager metadataManager = Mockito.mock(OMMetadataManager.class); |
Contributor
There was a problem hiding this comment.
Mockito.mock is already imported
Suggested change
| OMMetadataManager metadataManager = Mockito.mock(OMMetadataManager.class); | |
| OMMetadataManager metadataManager = mock(OMMetadataManager.class); |
Also in few other places.
| return Long.parseLong(key.split("/")[3]); | ||
| } | ||
|
|
||
| private static final class TableIteratorTestCase { |
Contributor
There was a problem hiding this comment.
nit: class can be renamed to TestCase since it's private
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
This PR cleans up
TestKeyManagerImplby replacing the long parameter lists in the parameterized table iterator tests with a smallTableIteratorTestCasebuilder.The change also separates successful and invalid table iterator cases, so the expected exception path is tested explicitly instead of being mixed into the common assertion flow.
Generated-by: OpenAI Codex (GPT-5)
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-12807
How was this patch tested?
Tested with:
GitHub Actions CI: https://github.com/echonesis/ozone/actions/runs/28430712787