Skip to content

KAFKA-14596: Move TopicCommand to tools#13201

Merged
mimaison merged 11 commits into
apache:trunkfrom
OmniaGM:KAFKA-14596
Oct 17, 2023
Merged

KAFKA-14596: Move TopicCommand to tools#13201
mimaison merged 11 commits into
apache:trunkfrom
OmniaGM:KAFKA-14596

Conversation

@OmniaGM

@OmniaGM OmniaGM commented Feb 6, 2023

Copy link
Copy Markdown
Contributor

This pr include

  • The changes include switching Scala code to java
  • Move TopicCommand and all test cases to tools

Some implementation notes:

  • I added ToolsTestUtils.createBrokerProperties as a wrapper for TestUtils.createBrokerConfig to avoid converting between Map<Integer, String> and Map<Int, String>.
  • Replicated TestUtils.setReplicationThrottleForPartitions and TestUtils.removeReplicationThrottleForPartitions to ToolsTestUtils as the methods are used only TopicCommandIntegrationTest and ReassignPartitionsIntegrationTest. We need to remove it from TestUtils once we migrate ReassignPartitions
  • Replicated TestInfoUtils.TestWithParameterizedQuorumName to ToolsTestUtils as java convert this into a getter function which cannot be used with ParameterizedTest
  • Move CoreUtils.duplicate to ToolsUtils
  • Move TopicFilter out of core. (This is part of https://issues.apache.org/jira/browse/KAFKA-14647 which seems not moving for a while ) Used KAFKA-14647: Moving TopicFilter to server-common/utils #13158
  • Duplicate AdminCommandFailedException and AdminOperationException out of core. Used the new exceptions from KAFKA-14591 DeleteRecordsCommand moved to tools #13278

More detailed description of your change,
if necessary. The PR title and PR message become
the squashed commit message, so use a separate
comment to ping reviewers.

Summary of testing strategy (including rationale)
for the feature or bug fix. Unit and/or integration
tests are expected for any behaviour change and
system tests should be considered for larger changes.

Committer Checklist (excluded from commit message)

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

@github-actions

Copy link
Copy Markdown

This PR is being marked as stale since it has not had any activity in 90 days. If you would like to keep this PR alive, please ask a committer for review. If the PR has merge conflicts, please update it with the latest from trunk (or appropriate release branch)
If this PR is no longer valid or desired, please feel free to close it. If no activity occurrs in the next 30 days, it will be automatically closed.

@github-actions github-actions Bot added the stale Stale PRs label Jun 10, 2023
@divijvaidya

Copy link
Copy Markdown
Member

@OmniaGM can you please rebase this with trunk and I would be happy to begin a review for this.

@OmniaGM
OmniaGM force-pushed the KAFKA-14596 branch 3 times, most recently from b574ef2 to 68e39c0 Compare June 18, 2023 19:02
@OmniaGM

OmniaGM commented Jun 18, 2023

Copy link
Copy Markdown
Contributor Author

Hi @divijvaidya I just did rebase this with trunk

@github-actions github-actions Bot removed the stale Stale PRs label Jun 22, 2023
@fvaleri fvaleri added the tools label Jul 7, 2023
@fvaleri

fvaleri commented Jul 8, 2023

Copy link
Copy Markdown
Contributor

Hi @OmniaGM.

Move TopicFilter out of core. (This is part of https://issues.apache.org/jira/browse/KAFKA-14647 which seems not moving for a while )

I think #13158 is ready. I'll try to drive some attention to it.

Move CoreUtils.duplicate to ToolsUtils
Duplicate AdminCommandFailedException and AdminOperationException out of core.

I looks like AdminCommandFailedException and AdminOperationException are being moved in #13278. This also seems to be almost ready.

@OmniaGM

OmniaGM commented Jul 9, 2023

Copy link
Copy Markdown
Contributor Author

Hi @OmniaGM.

Move TopicFilter out of core. (This is part of https://issues.apache.org/jira/browse/KAFKA-14647 which seems not moving for a while )

I think #13158 is ready. I'll try to drive some attention to it.

Move CoreUtils.duplicate to ToolsUtils
Duplicate AdminCommandFailedException and AdminOperationException out of core.

I looks like AdminCommandFailedException and AdminOperationException are being moved in #13278. This also seems to be almost ready.

Will update this PR once these prs are merged.

@vamossagar12

Copy link
Copy Markdown
Contributor

Thanks @OmniaGM , @fvaleri . #13158 has been approved by Federico. Just waiting for a committer to review/merge it.

@OmniaGM

OmniaGM commented Aug 2, 2023

Copy link
Copy Markdown
Contributor Author

I have updated the PR to use #13158 and #13278. The test checks are failing because of an unrelated class.

However the :tools:compileTestJava is failing because it doesn't like JavaConverters.asScala and I can not reproduce this problem locally. Logs are here any suggestion?

Edit: Actually running ./gradlew :tools:compileTestJava -PscalaVersion=2.12 clean check -x test --profile --continue -PxmlSpotBugsReport=true -PkeepAliveMode=session do reproduce it locally. Pushed a fix.

Out of curiosity are we planning to move KafkaServerTestHarness and RackAwareTest out of core?

@OmniaGM
OmniaGM force-pushed the KAFKA-14596 branch 4 times, most recently from d126a39 to 993b6d6 Compare August 2, 2023 14:23

@fvaleri fvaleri 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.

Hi @OmniaGM, thanks. I left some comments.

Additionally, this error message is different from previous implementation:

### OLD
$ bin/kafka-topics.sh --bootstrap-server :9092 --describe --topic my-topic-foo --delete-config sdsad
Option "[delete-config]" can't be used with option "[describe]"

### NEW
$ bin/kafka-topics.sh --bootstrap-server :9092 --describe --topic my-topic-foo --delete-config sdsad
Option "[delete-config]" can't be used with option "[bootstrap-server]"

Comment thread tools/src/main/java/org/apache/kafka/tools/TopicCommand.java Outdated
Comment thread tools/src/main/java/org/apache/kafka/tools/TopicCommand.java Outdated
Comment thread tools/src/main/java/org/apache/kafka/tools/TopicCommand.java Outdated
Comment thread tools/src/main/java/org/apache/kafka/tools/TopicCommand.java Outdated
Comment thread tools/src/main/java/org/apache/kafka/tools/TopicCommand.java Outdated
Comment thread tools/src/main/java/org/apache/kafka/tools/TopicCommand.java Outdated
Comment thread tools/src/main/java/org/apache/kafka/tools/TopicCommand.java Outdated
Comment thread tools/src/main/java/org/apache/kafka/tools/TopicCommand.java Outdated
@OmniaGM
OmniaGM force-pushed the KAFKA-14596 branch 3 times, most recently from 07eaec5 to 81a0ef8 Compare August 23, 2023 15:19

@fvaleri fvaleri 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.

Hi @OmniaGM, there is still one formatting issue in the first output line:

$ bin/kafka-topics.sh --bootstrap-server :9092 --describe --topic my-topic
Topic: my-topic	TopicId: CITkda1vT5i6T7GdwrWCdA	PartitionCount: %s3	ReplicationFactor: %s2	Configs: %smin.insync.replicas=1
	Topic: my-topic	Partition: 0	Leader: 3	Replicas: 3,4	Isr: 3,4
	Topic: my-topic	Partition: 1	Leader: 4	Replicas: 4,2	Isr: 4,2
	Topic: my-topic	Partition: 2	Leader: 2	Replicas: 2,3	Isr: 2,3

After rebasing on your branch, I'm getting the following exception on the integration tests with quorum=kraft:

java.lang.NoClassDefFoundError: org/apache/kafka/server/log/remote/storage/RemoteStorageException

@fvaleri fvaleri 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.

Hi @OmniaGM, I think we are almost there.

Thanks for the effort of finding a workaround for the dependency issue. Well done.

Comment thread build.gradle Outdated

@fvaleri fvaleri 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.

LGTM. Thanks.

@fvaleri
fvaleri requested a review from mimaison September 15, 2023 14:06
@mimaison

mimaison commented Oct 3, 2023

Copy link
Copy Markdown
Member

@OmniaGM Thanks for the PR. Can you rebase on trunk to resolve the conflicts?

@OmniaGM

OmniaGM commented Oct 5, 2023

Copy link
Copy Markdown
Contributor Author

@OmniaGM Thanks for the PR. Can you rebase on trunk to resolve the conflicts?

Updated the pr waiting now for the pipeline to pass

@mimaison

mimaison commented Oct 9, 2023

Copy link
Copy Markdown
Member

@OmniaGM Thanks for the update. I've not had time to take a look yet but noticed there's a compilation failure:

> Task :tools:compileTestJava

/home/jenkins/jenkins-agent/workspace/Kafka_kafka-pr_PR-13201/tools/src/test/java/org/apache/kafka/tools/ToolsTestUtils.java:78: error: variable TEST_WITH_PARAMETERIZED_QUORUM_NAME is already defined in class ToolsTestUtils

    public static final String TEST_WITH_PARAMETERIZED_QUORUM_NAME = "{displayName}.quorum={0}";

@OmniaGM

OmniaGM commented Oct 10, 2023

Copy link
Copy Markdown
Contributor Author

@mimaison fixed the compilation issue. I spotted another one with Java21 and fixed it as well.

@mimaison mimaison left a comment

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.

Thanks for the PR, it wasn't an easy one to convert! It looks good overall, I left a few comments and suggestions.

Comment thread checkstyle/import-control.xml Outdated
Comment thread tools/src/main/java/org/apache/kafka/tools/TopicCommand.java Outdated
Comment thread tools/src/main/java/org/apache/kafka/tools/TopicCommand.java Outdated
Comment thread tools/src/main/java/org/apache/kafka/tools/TopicCommand.java Outdated
Comment thread tools/src/main/java/org/apache/kafka/tools/TopicCommand.java Outdated
Comment thread tools/src/test/java/org/apache/kafka/tools/TopicCommandIntegrationTest.java Outdated
Comment thread tools/src/test/java/org/apache/kafka/tools/TopicCommandIntegrationTest.java Outdated
Comment thread tools/src/test/java/org/apache/kafka/tools/TopicCommandTest.java Outdated
Comment thread tools/src/test/java/org/apache/kafka/tools/TopicCommandTest.java
Comment thread tools/src/test/java/org/apache/kafka/tools/TopicCommandTest.java

@mimaison mimaison left a comment

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.

Thanks for the updates! I left a few more small suggestions

Comment thread core/src/test/scala/unit/kafka/utils/TestUtils.scala Outdated
Comment thread tools/src/main/java/org/apache/kafka/tools/ToolsUtils.java Outdated
Comment thread tools/src/main/java/org/apache/kafka/tools/TopicCommand.java Outdated
@OmniaGM
OmniaGM requested a review from mimaison October 16, 2023 11:02
@mimaison

Copy link
Copy Markdown
Member

@OmniaGM thanks for the updates. I'm getting a test failure in TopicCommandIntegrationTest:

Gradle Test Run :tools:test > Gradle Test Executor 31 > TopicCommandIntegrationTest > testDescribeDoesNotFailWhenListingReassignmentIsUnauthorized(String) > testDescribeDoesNotFailWhenListingReassignmentIsUnauthorized(String).quorum=kraft FAILED
    java.lang.RuntimeException: java.lang.IllegalArgumentException: Topic 'testDescribeDoesNotFailWhenListingReassignmentIsUnauthorized-HbRT1wjRyV' does not exist as expected
        at org.apache.kafka.tools.TopicCommandIntegrationTest.lambda$captureDescribeTopicStandardOut$46(TopicCommandIntegrationTest.java:1006)
        at org.apache.kafka.tools.ToolsTestUtils.captureStandardStream(ToolsTestUtils.java:66)
        at org.apache.kafka.tools.ToolsTestUtils.captureStandardOut(ToolsTestUtils.java:50)
        at org.apache.kafka.tools.TopicCommandIntegrationTest.captureDescribeTopicStandardOut(TopicCommandIntegrationTest.java:1009)
        at org.apache.kafka.tools.TopicCommandIntegrationTest.testDescribeDoesNotFailWhenListingReassignmentIsUnauthorized(TopicCommandIntegrationTest.java:943)

        Caused by:
        java.lang.IllegalArgumentException: Topic 'testDescribeDoesNotFailWhenListingReassignmentIsUnauthorized-HbRT1wjRyV' does not exist as expected
            at org.apache.kafka.tools.TopicCommand.ensureTopicExists(TopicCommand.java:215)
            at org.apache.kafka.tools.TopicCommand.access$700(TopicCommand.java:78)
            at org.apache.kafka.tools.TopicCommand$TopicService.describeTopic(TopicCommand.java:559)
            at org.apache.kafka.tools.TopicCommandIntegrationTest.lambda$captureDescribeTopicStandardOut$46(TopicCommandIntegrationTest.java:1004)
            ... 4 more

@OmniaGM

OmniaGM commented Oct 16, 2023

Copy link
Copy Markdown
Contributor Author

@OmniaGM thanks for the updates. I'm getting a test failure in TopicCommandIntegrationTest:

Gradle Test Run :tools:test > Gradle Test Executor 31 > TopicCommandIntegrationTest > testDescribeDoesNotFailWhenListingReassignmentIsUnauthorized(String) > testDescribeDoesNotFailWhenListingReassignmentIsUnauthorized(String).quorum=kraft FAILED
    java.lang.RuntimeException: java.lang.IllegalArgumentException: Topic 'testDescribeDoesNotFailWhenListingReassignmentIsUnauthorized-HbRT1wjRyV' does not exist as expected
        at org.apache.kafka.tools.TopicCommandIntegrationTest.lambda$captureDescribeTopicStandardOut$46(TopicCommandIntegrationTest.java:1006)
        at org.apache.kafka.tools.ToolsTestUtils.captureStandardStream(ToolsTestUtils.java:66)
        at org.apache.kafka.tools.ToolsTestUtils.captureStandardOut(ToolsTestUtils.java:50)
        at org.apache.kafka.tools.TopicCommandIntegrationTest.captureDescribeTopicStandardOut(TopicCommandIntegrationTest.java:1009)
        at org.apache.kafka.tools.TopicCommandIntegrationTest.testDescribeDoesNotFailWhenListingReassignmentIsUnauthorized(TopicCommandIntegrationTest.java:943)

        Caused by:
        java.lang.IllegalArgumentException: Topic 'testDescribeDoesNotFailWhenListingReassignmentIsUnauthorized-HbRT1wjRyV' does not exist as expected
            at org.apache.kafka.tools.TopicCommand.ensureTopicExists(TopicCommand.java:215)
            at org.apache.kafka.tools.TopicCommand.access$700(TopicCommand.java:78)
            at org.apache.kafka.tools.TopicCommand$TopicService.describeTopic(TopicCommand.java:559)
            at org.apache.kafka.tools.TopicCommandIntegrationTest.lambda$captureDescribeTopicStandardOut$46(TopicCommandIntegrationTest.java:1004)
            ... 4 more

Hi @mimaison I think this is flaky test I added waitForTopicCreated(testTopicName);. The test isn't failing locally with me so will wait for the pipeline to finish.

@mimaison

Copy link
Copy Markdown
Member

With the latest updates it's not failing anymore on my laptop. I'll let the Apache CI run before merging.

@mimaison mimaison left a comment

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.

Thanks, LGTM

@mimaison
mimaison merged commit 9af1e74 into apache:trunk Oct 17, 2023
AnatolyPopov pushed a commit to aiven/kafka that referenced this pull request Feb 16, 2024
Reviewers: Mickael Maison <mickael.maison@gmail.com>, Federico Valeri <fedevaleri@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants