Skip to content

KAFKA-17833: Convert DescribeAuthorizedOperationsTest to use kraft#18252

Merged
mimaison merged 4 commits intoapache:trunkfrom
FrankYang0529:KAFKA-17833
Feb 7, 2025
Merged

KAFKA-17833: Convert DescribeAuthorizedOperationsTest to use kraft#18252
mimaison merged 4 commits intoapache:trunkfrom
FrankYang0529:KAFKA-17833

Conversation

@FrankYang0529
Copy link
Copy Markdown
Member

@FrankYang0529 FrankYang0529 commented Dec 18, 2024

We disabled DescribeAuthorizedOperationsTest when implementing KAFKA-17614. Re-enable with a new test framework.

Committer Checklist (excluded from commit message)

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

@github-actions github-actions Bot added the core Kafka Broker label Dec 18, 2024
@FrankYang0529 FrankYang0529 changed the title Convert DescribeAuthorizedOperationsTest to use kraft KAFKA-17833: Convert DescribeAuthorizedOperationsTest to use kraft Dec 18, 2024
@FrankYang0529 FrankYang0529 force-pushed the KAFKA-17833 branch 6 times, most recently from 7259a8d to 426b733 Compare December 22, 2024 12:03
@FrankYang0529 FrankYang0529 force-pushed the KAFKA-17833 branch 3 times, most recently from 81d206d to 59066ef Compare January 8, 2025 15:53
@dajac
Copy link
Copy Markdown
Member

dajac commented Jan 21, 2025

@FrankYang0529 Could you please rebase the PR? I can help with reviews for this one.

@FrankYang0529
Copy link
Copy Markdown
Member Author

@dajac Thanks. Rebased trunk.

@FrankYang0529 FrankYang0529 requested a review from dajac January 23, 2025 05:44
@FrankYang0529 FrankYang0529 force-pushed the KAFKA-17833 branch 7 times, most recently from 50da078 to 5cc93e3 Compare January 30, 2025 00:50
Signed-off-by: PoAn Yang <payang@apache.org>
Copy link
Copy Markdown
Member

@mimaison mimaison 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. I left a few comments.

return createAdminConfig(username, password, Map.of());
}

private Map<String, Object> createAdminConfig(String username, String password, Map<String, Object> additionalConfigs) {
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.

Not sure createAdminConfig() is the best name since this is also used to create consumer configs. What about createClientConfig() or createConfig()?

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.

We use alterConsumerGroupOffsets to create group, so we don't need this function. Thanks!

private static final AccessControlEntry ALTER_ENTRY = createAccessControlEntry(JaasUtils.KAFKA_PLAIN_USER1, ALTER);
private static final AccessControlEntry DESCRIBE_ENTRY = createAccessControlEntry(JaasUtils.KAFKA_PLAIN_USER1, DESCRIBE);

static List<ClusterConfig> generator() {
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.

Is this now the preferred approach over using @ClusterTest?

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.

All cases in this class use same configuration. However, ClusterTestDefaults doesn't have brokerSecurityProtocol and controllerSecurityProtocol fields, so I use ClusterTemplate to avoid defining similar configuration in each case. How about adding these fields to ClusterTestDefaults in another Jira? WDYT? Thanks.

Consumer<Byte, Byte> consumer3 = clusterInstance.consumer(createAdminConfig(JaasUtils.KAFKA_PLAIN_ADMIN, JaasUtils.KAFKA_PLAIN_ADMIN_PASSWORD, Map.of(ConsumerConfig.GROUP_ID_CONFIG, GROUP3)))
) {
// create consumers to avoid group not found error
consumer1.subscribe(List.of("topic1"));
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 use Admin.alterConsumerGroupOffsets() to create the consumer groups?

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.

Updated it. Thanks.

public void testConsumerGroupAuthorizedOperations(ClusterInstance clusterInstance) {
setupSecurity(clusterInstance);
try (Admin admin = clusterInstance.admin(createAdminConfig(JaasUtils.KAFKA_PLAIN_ADMIN, JaasUtils.KAFKA_PLAIN_ADMIN_PASSWORD))) {
assertDoesNotThrow(() -> admin.createTopics(List.of(new NewTopic("topic1", 1, (short) 1))));
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.

Do we need these assertDoesNotThrow() calls everywhere? If an exception was thrown wouldn't it automatically fail the test anyway?

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.

Removed useless assertDoesNotThrow. Thanks.

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.

There are still a bunch of assertDoesNotThrow() calls. Are they needed?

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.

Removed it. Thanks.

Signed-off-by: PoAn Yang <payang@apache.org>
Signed-off-by: PoAn Yang <payang@apache.org>
Copy link
Copy Markdown
Member

@mimaison mimaison left a comment

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

@mimaison mimaison merged commit b22c7d5 into apache:trunk Feb 7, 2025
mimaison pushed a commit that referenced this pull request Feb 7, 2025
…18252)


Reviewers: Mickael Maison <mickael.maison@gmail.com>
@mimaison
Copy link
Copy Markdown
Member

mimaison commented Feb 7, 2025

Applied to 4.0 too: b3837f8

@FrankYang0529
Copy link
Copy Markdown
Member Author

Thanks for the review. 😄

@FrankYang0529 FrankYang0529 deleted the KAFKA-17833 branch February 7, 2025 14:54
pdruley pushed a commit to pdruley/kafka that referenced this pull request Feb 12, 2025
manoj-mathivanan pushed a commit to manoj-mathivanan/kafka that referenced this pull request Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Kafka Broker

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants