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

KAFKA-14596: Move TopicCommand to tools #13201

Merged
merged 11 commits into from
Oct 17, 2023
Merged

Conversation

OmniaGM
Copy link
Contributor

@OmniaGM OmniaGM commented Feb 6, 2023

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

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
Contributor

@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
Copy link
Contributor Author

OmniaGM commented Jun 18, 2023

Hi @divijvaidya I just did rebase this with trunk

@fvaleri
Copy link
Collaborator

fvaleri commented Jul 8, 2023

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
Copy link
Contributor Author

OmniaGM commented Jul 9, 2023

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
Collaborator

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

@OmniaGM
Copy link
Contributor Author

OmniaGM commented Aug 2, 2023

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
Copy link
Collaborator

@fvaleri fvaleri left a comment

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]"

@OmniaGM OmniaGM force-pushed the KAFKA-14596 branch 3 times, most recently from 07eaec5 to 81a0ef8 Compare August 23, 2023 15:19
Copy link
Collaborator

@fvaleri fvaleri left a comment

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

Copy link
Collaborator

@fvaleri fvaleri left a comment

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.

build.gradle Outdated Show resolved Hide resolved
Copy link
Collaborator

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

@mimaison
Copy link
Member

mimaison commented Oct 3, 2023

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

@OmniaGM
Copy link
Contributor Author

OmniaGM commented Oct 5, 2023

@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
Copy link
Member

mimaison commented Oct 9, 2023

@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
Copy link
Contributor Author

OmniaGM commented Oct 10, 2023

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

Copy link
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, it wasn't an easy one to convert! It looks good overall, I left a few comments and suggestions.

Copy link
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 updates! I left a few more small suggestions

core/src/test/scala/unit/kafka/utils/TestUtils.scala Outdated Show resolved Hide resolved
tools/src/main/java/org/apache/kafka/tools/ToolsUtils.java Outdated Show resolved Hide resolved
@OmniaGM OmniaGM requested a review from mimaison October 16, 2023 11:02
@mimaison
Copy link
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
Copy link
Contributor Author

OmniaGM commented Oct 16, 2023

@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
Member

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

Copy link
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, LGTM

@mimaison mimaison merged commit 9af1e74 into apache:trunk Oct 17, 2023
1 check failed
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
5 participants