Skip to content

MINOR: Use ClusterInstance#createTopic in various integration tests - #23513

Open
lytt925 wants to merge 14 commits into
apache:trunkfrom
lytt925:use-clusterinstance-createtopic
Open

lytt925 wants to merge 14 commits into
apache:trunkfrom
lytt925:use-clusterinstance-createtopic

Conversation

@lytt925

@lytt925 lytt925 commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to apache/kafka#22874
(comment)

Currently many tests running on ClusterInstance create topics manually
using Admin#createTopics. The post-creation waiting behavior is not
inconsistent. Some tests implement custom waits, some call
.all().get(), and others don't wait.

Changes

This PR switch these calls to ClusterInstance#createTopic or
ClusterInstance#createTopicWithAssignment.
when the topic is for test setup and maps to one of the
helpers.

Also add a new overload of createTopicWithAssignment to convert more
tests.

I kept the original createTopics calls where the test needs the returned
topic ID

Reviewers: Ming-Yen Chung mingyen066@gmail.com

Reviewers: Ken Huang s7133700@gmail.com

@github-actions github-actions Bot added triage PRs from the community core Kafka Broker tools tests Test fixes (including flaky tests) storage Pull requests that target the storage module clients small Small PRs labels Sep 18, 2026
@mingyen066

Copy link
Copy Markdown
Collaborator

Thanks for the cleanup! The follow-up in apache/kafka#22874 (comment) was meant to clean up the whole codebase, and there are still many places using the same pattern, such as TopicCommandTest and EligibleLeaderReplicasIntegrationTest. Could we clean them all up in this PR?

@github-actions github-actions Bot added tiered-storage Related to the Tiered Storage feature and removed small Small PRs labels Sep 19, 2026
@lytt925

lytt925 commented Sep 20, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the cleanup! The follow-up in apache/kafka#22874 (comment) was meant to clean up the whole codebase, and there are still many places using the same pattern, such as TopicCommandTest and EligibleLeaderReplicasIntegrationTest. Could we clean them all up in this PR?

Thank you for the review! Sorry for missing other files in the first place. I have added them in the new commits. Please let me know if I missed any.

@github-actions

Copy link
Copy Markdown

A label of 'needs-attention' was automatically added to this PR in order to raise the
attention of the committers. Once this issue has been triaged, the triage label
should be removed to prevent this automation from happening again.

@lytt925
lytt925 force-pushed the use-clusterinstance-createtopic branch from 5d03882 to 1c473c1 Compare September 29, 2026 04:32

@m1a2st m1a2st left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you also take a look at the following tests? They follow the same pattern:

  • DeleteTopicTest
  • ConnectInternalTopicsTest
  • BootstrapControllersIntegrationTest

There are also several tests that create a topic using only createTopics(...).all().get() (or .topicId(...).get()) without an explicit wait:

  • ConfigCommandIntegrationTest
  • DescribeConsumerGroupTest
  • DeleteOffsetsConsumerGroupCommandIntegrationTest
  • LeaderElectionCommandTest
  • ResetConsumerGroupOffsetTest
  • DeleteRecordsCommandTest
  • ConsumerIntegrationTest
  • ShareConsumerDLQTest
  • CordonedLogDirsIntegrationTest

@github-actions github-actions Bot removed needs-attention triage PRs from the community labels Sep 30, 2026
@lytt925
lytt925 force-pushed the use-clusterinstance-createtopic branch from 1c473c1 to cf7a92d Compare October 3, 2026 05:51
@lytt925

lytt925 commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor Author

@m1a2st Thanks for the review!

I've converted the tests you listed, plus a few more with the same pattern, and updated the PR description with the criteria I used.

Also few still create topics manually because they need a replica assignment together with configs. Would it make sense to add a createTopicWithAssignment(name, assignment, configs) overload?

@m1a2st m1a2st left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @lytt925 for the update.

Also few still create topics manually because they need a replica assignment together with configs. Would it make sense to add a createTopicWithAssignment(name, assignment, configs) overload?

Yes, I think adding an overload makes sense. It would allow us to convert the remaining call sites that require both a replica assignment and topic configs.

@@ -219,15 +219,15 @@ public void testStaticCordonUncordonLogDirs() throws Exception {
setCordonedLogDirs(admin, List.of(), BROKER_0);

// We can't create topics again

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This comment seems incorrect. Could you update it?

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.

Thank you. the overload and related tests are updated in a932362

and the comment is fixed in 8d2df08

@m1a2st m1a2st left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-approved clients core Kafka Broker storage Pull requests that target the storage module tests Test fixes (including flaky tests) tiered-storage Related to the Tiered Storage feature tools

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants