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

MINOR: Added test for ClusterConfig #16110

Merged
merged 6 commits into from
Jun 6, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions core/src/test/java/kafka/test/ClusterConfigTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -96,4 +99,16 @@ public void testDisksPerBrokerIsZero() {
.setDisksPerBroker(0)
.build());
}

@Test
public void testDisplayTags() {
List<String> tags = Collections.singletonList("example tag");
ClusterConfig clusterConfig = ClusterConfig.defaultBuilder().setTags(tags).build();

Set<String> expectedDisplayTags = new LinkedHashSet<>(tags);
Copy link
Member

Choose a reason for hiding this comment

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

This testing code is almost same with production code. Maybe we don't need to verify the "format" of display tags. Instead, we check the output which should "contain" expected strings. WDYT?

Copy link
Contributor Author

@caysony1 caysony1 Jun 4, 2024

Choose a reason for hiding this comment

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

@chia7712 Thanks for the review. I addressed the comments in my latest commit.

expectedDisplayTags.add("MetadataVersion=" + MetadataVersion.latestTesting());
expectedDisplayTags.add("Security=" + SecurityProtocol.PLAINTEXT);

Assertions.assertEquals(expectedDisplayTags, clusterConfig.displayTags());
}
}