Skip to content

KAFKA-19248: Multiversioning in Kafka Connect - Plugin Loading Isolation Tests#18325

Merged
gharris1727 merged 243 commits intoapache:trunkfrom
snehashisp:mvn-plugins-test
Jun 5, 2025
Merged

KAFKA-19248: Multiversioning in Kafka Connect - Plugin Loading Isolation Tests#18325
gharris1727 merged 243 commits intoapache:trunkfrom
snehashisp:mvn-plugins-test

Conversation

@snehashisp
Copy link
Copy Markdown
Contributor

@snehashisp snehashisp commented Dec 27, 2024

This adds tests for
KIP-891.
It primarily focuses on tests for the new additions in plugin loading
isolation. It has dependency on the actual KIP implementation PRs and
should be merged post #17742

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

for (Map.Entry<String, String> entry : replacements.entrySet()) {
content = content.replace(entry.getKey(), entry.getValue());
}
File tmpFile = new File(System.getProperty("java.io.tmpdir") + File.separator + source.getName());
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.

nit: use Files.createTempFile?

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.

Tried this but it unfortunately always adds a random numerical id to the file generated, even with both prefix and suffix (with one of them as ""). It will add the id in between the prefix and suffix. This fails compilation as the file name of the class is required to have the same name as the class with the .java suffix.

try {
String content = Files.readString(source.toPath());
for (Map.Entry<String, String> entry : replacements.entrySet()) {
content = content.replace(entry.getKey(), entry.getValue());
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.

nit: I don't really like this "modifying arbitrary source code before compilation" technique, it's very powerful and open-ended, and could be misused and be more difficult to debug like self-modifying code. But because the current application is within reason, maybe this is good enough to merge.

Prior art here is the ReadVersionFromResourcePlugin, whose code is duplicated in read-version-from-resource-v1 and read-version-from-resource-v2, with version files are specified explicitly. I think that we shouldn't follow this same strategy for these new plugins and versions, but there's a middle ground where we generate version files from Strings specified in createPluginJar/writeJar.

Copy link
Copy Markdown
Contributor Author

@snehashisp snehashisp Apr 30, 2025

Choose a reason for hiding this comment

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

Yeah its powerful. It would be interesting to see in what ways people start misusing this capability. If it turns out to be problematic, I will followup and see if the version file approach can be introduced instead.

}

public synchronized Path build(String pluginDir) throws IOException {
Path pluginDirPath = Files.createTempDirectory(pluginDir);
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 method is leaking files on each run. I found a bunch of files left over on my machine:

cd /var/folders/k1/6b93_bm16596yf4d3dlp6vbh0000gn/T
ls
rm -rf SINK_CONNECTOR-* SOURCE_CONNECTOR-* PREDICATE-* TRANSFORMATION-* HEADER_CONVERTER-* CONVERTER-* all_versioned_artifact*

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.

Thanks for catching this. Added deleteOnExit on the created temp plugins so that it gets cleaned up.

@github-actions github-actions Bot removed triage PRs from the community needs-attention labels Apr 25, 2025
@snehashisp snehashisp changed the title [WIP] KIP-891: Multiversioning in Kafka Connect - Plugin Loading Isolation Tests KAFKA-19248: Multiversioning in Kafka Connect - Plugin Loading Isolation Tests May 6, 2025
@snehashisp
Copy link
Copy Markdown
Contributor Author

Hi @gharris1727. Have addressed the comments in this PR, PTAL soon.

Copy link
Copy Markdown
Contributor

@gharris1727 gharris1727 left a comment

Choose a reason for hiding this comment

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

LGTM.

I was having some difficulty running this locally due to https://issues.apache.org/jira/browse/KAFKA-18834 . As it's unrelated and seems to be well understood, I'll just keep an eye out to see if this causes more problems on trunk.

@gharris1727 gharris1727 merged commit 2694d7a into apache:trunk Jun 5, 2025
23 checks passed
Mirai1129 pushed a commit to Mirai1129/kafka that referenced this pull request Jun 5, 2025
…ion Tests (apache#18325)

This adds tests for [KIP-891](https://cwiki.apache.org/confluence/display/KAFKA/KIP-891%3A+Running+multiple+versions+of+Connector+plugins).
It primarily focuses on tests for the new additions in plugin loading
isolation. It has dependency on the actual KIP implementation PRs and
should be merged post apache#17742

Reviewers: Greg Harris <greg.harris@aiven.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants