Add one test for plugin type to PluginsLoaderTests#117725
Merged
ldematte merged 6 commits intoelastic:mainfrom Dec 12, 2024
Merged
Add one test for plugin type to PluginsLoaderTests#117725ldematte merged 6 commits intoelastic:mainfrom
PluginsLoaderTests#117725ldematte merged 6 commits intoelastic:mainfrom
Conversation
ldematte
commented
Nov 28, 2024
| private record LoadedPluginLayer( | ||
| PluginBundle pluginBundle, | ||
| ClassLoader pluginClassLoader, | ||
| ModuleLayer pluginModuleLayer, |
Contributor
Author
There was a problem hiding this comment.
Fear not, this is not added here just for this test: we need it anyway/it's one of the reasons we wanted to split PluginsLoader out (see it in use in #117239)
ldematte
commented
Nov 28, 2024
| } | ||
|
|
||
| static final String toPackageName(String className) { | ||
| static String toPackageName(String className) { |
Contributor
Author
There was a problem hiding this comment.
Automatic cleanup (IJ complaining)
Contributor
There was a problem hiding this comment.
I'm surprised that wasn't caught before.
Collaborator
|
Pinging @elastic/es-core-infra (Team:Core/Infra) |
…e/elasticsearch into entitlements/plugin-loader-tests
jdconrad
approved these changes
Dec 11, 2024
Contributor
jdconrad
left a comment
There was a problem hiding this comment.
LGTM! Thanks for adding these additional tests.
| } | ||
|
|
||
| static final String toPackageName(String className) { | ||
| static String toPackageName(String className) { |
Contributor
There was a problem hiding this comment.
I'm surprised that wasn't caught before.
| ); | ||
|
|
||
| Path jar = plugin.resolve("impl.jar"); | ||
| JarUtils.createJarWithEntries(jar, Map.of("p/A.class", InMemoryJavaCompiler.compile("p.A", """ |
Contributor
There was a problem hiding this comment.
This is quite clever to use in testing :)
ldematte
added a commit
to ldematte/elasticsearch
that referenced
this pull request
Dec 12, 2024
* Add one test for plugin type to PluginsLoaderTests * Suppress ExtraFs (or PluginsUtils etc could fail with extra0 files)
elasticsearchmachine
pushed a commit
that referenced
this pull request
Dec 12, 2024
* Add one test for plugin type to PluginsLoaderTests * Suppress ExtraFs (or PluginsUtils etc could fail with extra0 files)
maxhniebergall
pushed a commit
to maxhniebergall/elasticsearch
that referenced
this pull request
Dec 16, 2024
…elastic#118529) * Add one test for plugin type to PluginsLoaderTests * Suppress ExtraFs (or PluginsUtils etc could fail with extra0 files)
maxhniebergall
pushed a commit
to maxhniebergall/elasticsearch
that referenced
this pull request
Dec 16, 2024
…elastic#118529) * Add one test for plugin type to PluginsLoaderTests * Suppress ExtraFs (or PluginsUtils etc could fail with extra0 files)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add one test per plugin type (modular, stable, non-modular) to
PluginsLoaderTests.We split responsibility of
PluginsServicein a separatePluginsLoader; thePluginsLoadernow is responsible to find and create all plugins bundles and descriptors (which is delegated toPluginsUtils, and partially covered byPluginsUtilsTests), and particularly to create all the ClassLoaders and Layers that will be used to load the plugin classes and create the plugin objects.Currently,
PluginsLoaderfunctions are tested (in part) byPluginsServiceTests; this PR borrows from these tests (with partial duplication, ATM) and adds new ones toPluginsLoaderTests; the new tests focus on the responsibilities ofPluginsLoader(find the jars, build the descriptors, build the layers), covering all 3 plugin types we can create.Tests in
PluginsServiceTestsshould probably be re-worked to remove duplication, and focus more on what responsibilities remain inPluginsService(actual plugin loading/creation, filtering, holding the registry), but I'd like to work incrementally and do that in a separate PR.