KAFKA-19009: Move MetadataCacheTest to metadata module#22118
Open
FrankYang0529 wants to merge 1 commit intoapache:trunkfrom
Open
KAFKA-19009: Move MetadataCacheTest to metadata module#22118FrankYang0529 wants to merge 1 commit intoapache:trunkfrom
FrankYang0529 wants to merge 1 commit intoapache:trunkfrom
Conversation
Signed-off-by: PoAn Yang <payang@apache.org>
d4fb200 to
3bd18f1
Compare
mimaison
reviewed
Apr 23, 2026
Member
mimaison
left a comment
There was a problem hiding this comment.
Thanks for the PR. I left a few suggestions
|
|
||
| public class MetadataCacheTest { | ||
|
|
||
| protected final long brokerEpoch = 0L; |
Comment on lines
+70
to
+71
| if (cache instanceof KRaftMetadataCache) { | ||
| KRaftMetadataCache c = (KRaftMetadataCache) cache; |
Member
There was a problem hiding this comment.
We can use pattern matching if (cache instanceof KRaftMetadataCache c) {
| String topic0 = "topic-0"; | ||
| String topic1 = "topic-1"; | ||
|
|
||
| Map<String, Uuid> topicIds = new HashMap<>(); |
| public void getTopicMetadataPartitionLeaderNotAvailable(MetadataCache cache) { | ||
| SecurityProtocol securityProtocol = SecurityProtocol.PLAINTEXT; | ||
| ListenerName listenerName = ListenerName.forSecurityProtocol(securityProtocol); | ||
| List<RegisterBrokerRecord> brokers = Collections.singletonList( |
Member
There was a problem hiding this comment.
We can replace all the Collections calls with Set
| MetadataResponseData.MetadataResponsePartition partitionMetadata = partitionMetadatas.get(0); | ||
| assertEquals(0, partitionMetadata.partitionIndex()); | ||
| assertEquals(Errors.NONE.code(), partitionMetadata.errorCode()); | ||
| assertEquals(new HashSet<>(List.of(0, 1)), new HashSet<>(partitionMetadata.replicaNodes())); |
Member
There was a problem hiding this comment.
new HashSet<>(List.of(0, 1)) -> Set.of(0, 1)
Same below and in other tests
| String topic0 = "test0"; | ||
| String topic1 = "test1"; | ||
|
|
||
| Map<String, Uuid> topicIds = new HashMap<>(); |
Member
There was a problem hiding this comment.
Again Map.of can be used here and for partitionMap just below
It seems we can get rid of all the new HashMap call
Comment on lines
+990
to
+1000
| private static class BrokerInfo { | ||
| final int id; | ||
| final List<Uuid> dirs; | ||
|
|
||
| BrokerInfo(int id, List<Uuid> dirs) { | ||
| this.id = id; | ||
| this.dirs = dirs; | ||
| } | ||
| } | ||
|
|
||
| private static class PartitionInfo2 { |
Member
There was a problem hiding this comment.
Also let's keep the original names Broker and Partition
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.
Migrate
MetadataCacheTestto metadata module.Reviewers: Mickael Maison (@mimaison)