Skip to content

MINOR: extract TestSslUtils to new test-common-base#22193

Open
soarez wants to merge 11 commits intoapache:trunkfrom
soarez:minor-extract-testsslutils
Open

MINOR: extract TestSslUtils to new test-common-base#22193
soarez wants to merge 11 commits intoapache:trunkfrom
soarez:minor-extract-testsslutils

Conversation

@soarez
Copy link
Copy Markdown
Member

@soarez soarez commented May 2, 2026

This change moves TestSslUtils, TestUtils and accessory classes from the
test classpath in clients to a new module: test-common-base,
allowing other modules to use these classes for testing without having
to include all of the test classpath for clients.

The package name for these classes changed, from org.apache.kafka.test
to org.apache.kafka.base.test.

The move from a test classpath to a main classpath triggered some issues
with spotbugs which were addressed. A couple of reflection utilities
required a new exception, and were moved to their own class to isolate
it.

For some modules it was possible to replace the dependency on
project(':clients').sourceSets.test.output with
project(:test-common:test-common-base), but the others still have to
keep both dependencies for now.

For further details on the context and purpose of this change, check
this thread:
#20376 (comment)

Reviewers: Ken Huang s7133700@gmail.com, Chia-Ping Tsai
chia7712@gmail.com

@github-actions github-actions Bot added streams core Kafka Broker producer consumer tools connect performance kraft mirror-maker-2 storage Pull requests that target the storage module tiered-storage Related to the Tiered Storage feature KIP-932 Queues for Kafka build Gradle build or GitHub Actions transactions Transactions and EOS clients group-coordinator labels May 2, 2026
@github-actions github-actions Bot added the docker Official Docker image label May 2, 2026
Copy link
Copy Markdown
Collaborator

@m1a2st m1a2st left a comment

Choose a reason for hiding this comment

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

Thanks to @soarez for this patch. Could we add some documentation for this new module?

@soarez
Copy link
Copy Markdown
Member Author

soarez commented May 2, 2026

@m1a2st where would be a good place for docs? We can add a README.md, but I haven't found one for other modules. Currently there's only a few lines of comment in build.gradle, like others, to explain the purpose of this module.

@m1a2st
Copy link
Copy Markdown
Collaborator

m1a2st commented May 2, 2026

I think we can place the README.md in the root of the module, similar to https://github.com/apache/kafka/tree/trunk/trogdor

I’m wondering if we could add more comprehensive documentation to clarify what this module is intended to contain. There are already many different TestUtils in all module, and without clear guidelines, it’s easy for the utilities in to test-common-base grow too large.

For now, a comment in build.gradle might be sufficient.

SSL utilities, wait functions, file-related operations

Should JaasUtils also be moved to this new module?

<allow class="org.apache.kafka.raft.QuorumConfig"/>
<allow class="org.apache.kafka.raft.KRaftConfigs"/>
<allow class="org.apache.kafka.test.TestUtils"/>
<allow class="org.apache.kafka.nase.test.TestUtils"/>
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.

typo? nase

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.

yes, good catch. removed this rule


import kafka.server.KafkaBroker;

import org.apache.kafka.base.test.TestUtils;
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.

In order to align with other modules, maybe we should use org.apache.kafka.common.test.base instead

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.

Agreed. I renamed the package

*/
package org.apache.kafka.clients.admin;

import org.apache.kafka.base.test.ReflectionUtils;
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.

Have you considered using TestReflectionUtils?

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.

I didn't, but I like it. The 'Test' prefix makes it clear this is a test utility. Renamed

@soarez
Copy link
Copy Markdown
Member Author

soarez commented May 3, 2026

Should JaasUtils also be moved to this new module?

@m1a2st I can't see a reason why not. These are the implications:

  • test-common-runtime would have to depend on test-common-base.
  • JaasModule would have to move too.
  • Both classes would need a rewrite to avoid the use of record due to the language level requirement for test-common-base.

If we all think the above are acceptable changes, I'm happy to include this in a subsequent patch, as this one is already quite large and changes a lot of import statements, making it easy to run into merge conflicts.

@m1a2st
Copy link
Copy Markdown
Collaborator

m1a2st commented May 3, 2026

Thanks @soarez, I think we can address these in a follow-up patch.

Comment thread build.gradle Outdated
}

dependencies {
implementation project(':clients')
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.

This reference causes AppInfoParserTest to fail, as it makes the test scope depend on the JAR rather than class files. While not a serious issue, it does prompt me to rethink the approach of this PR. Perhaps we should consider using fixtures that allow us to keep the same package while maintaining isolation. WDYT?

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.

I noticed that you are using implementation project(':clients').sourceSets.main.output instead of fixtures. Would you mind sharing reasoning behind this?

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

Labels

build Gradle build or GitHub Actions clients connect consumer core Kafka Broker docker Official Docker image group-coordinator KIP-932 Queues for Kafka kraft mirror-maker-2 performance producer storage Pull requests that target the storage module streams tiered-storage Related to the Tiered Storage feature tools transactions Transactions and EOS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants