-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Enable testing for ExtensiblePlugins using classpath plugins #16908
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
Merged
cwperks
merged 30 commits into
opensearch-project:main
from
cwperks:extend-classpath-plugins
May 8, 2025
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
44154b5
Make extended plugins optional
cwperks 9501854
Make extended plugins optional
cwperks 9b3f406
Merge branch 'main' into optional-extended-plugins
cwperks 44a4042
Load extensions for classpath plugins
cwperks 7b4d7d7
Ensure only single instance for each classpath extension
cwperks 1614706
Add test for classpath plugin extended plugin loading
cwperks 4176c46
Enable testing for ExtensiblePlugins using classpath plugins
cwperks ef041b0
Merge branch 'main' into extend-classpath-plugins
cwperks 09d1c82
Merge branch 'main' into extend-classpath-plugins
cwperks f840850
Add to CHANGELOG
cwperks 69ceaab
Merge branch 'main' into extend-classpath-plugins
cwperks 0fbe489
Merge branch 'main' into extend-classpath-plugins
cwperks 7a07307
Merge branch 'extend-classpath-plugins' of https://github.com/cwperks…
cwperks 7ddd9a3
Define PluginInfos from test files for classpath plugins
cwperks 07df814
Merge branch 'main' into extend-classpath-plugins
cwperks df48c29
Add testing constructor for PluginsService
cwperks a4937bd
Single call to loadExtensions
cwperks 49ec944
Merge branch 'main' into extend-classpath-plugins
cwperks 4cf427c
Reduce number of MockNode constructors
cwperks f9bc2ae
Create 2 public constructors for MockNode
cwperks 278f767
Merge branch 'main' into extend-classpath-plugins
cwperks fc9c0b2
Update import
cwperks e04db2e
Merge branch 'main' into extend-classpath-plugins
cwperks 053fbf0
Merge branch 'main' into extend-classpath-plugins
cwperks 0ee15a4
Merge branch 'main' into extend-classpath-plugins
cwperks 5e4f843
Address code review comments
cwperks df46482
Merge branch 'main' into extend-classpath-plugins
cwperks 5cb2929
Fix logic
cwperks 9888b34
Address PR feedback
cwperks 3c3b621
Rename variables
cwperks File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
75 changes: 75 additions & 0 deletions
75
server/src/internalClusterTest/java/org/opensearch/plugins/ClasspathPluginIT.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| /* | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| * | ||
| * The OpenSearch Contributors require contributions made to | ||
| * this file be licensed under the Apache-2.0 license or a | ||
| * compatible open source license. | ||
| */ | ||
|
|
||
| package org.opensearch.plugins; | ||
|
|
||
| import org.opensearch.Version; | ||
| import org.opensearch.test.OpenSearchIntegTestCase; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.Collection; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
|
|
||
| import static org.hamcrest.Matchers.equalTo; | ||
|
|
||
| @OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.TEST, numDataNodes = 0) | ||
| public class ClasspathPluginIT extends OpenSearchIntegTestCase { | ||
|
|
||
| public interface SampleExtension {} | ||
|
|
||
| public static class SampleExtensiblePlugin extends Plugin implements ExtensiblePlugin { | ||
| public SampleExtensiblePlugin() {} | ||
|
|
||
| @Override | ||
| public void loadExtensions(ExtensiblePlugin.ExtensionLoader loader) { | ||
| int nLoaded = 0; | ||
| for (SampleExtension e : loader.loadExtensions(SampleExtension.class)) { | ||
| nLoaded++; | ||
| } | ||
|
|
||
| assertThat(nLoaded, equalTo(1)); | ||
| } | ||
| } | ||
|
|
||
| public static class SampleExtendingPlugin extends Plugin implements SampleExtension { | ||
| public SampleExtendingPlugin() {} | ||
| }; | ||
|
|
||
| @Override | ||
| protected Collection<PluginInfo> additionalNodePlugins() { | ||
| return List.of( | ||
| new PluginInfo( | ||
| SampleExtensiblePlugin.class.getName(), | ||
| "classpath plugin", | ||
| "NA", | ||
| Version.CURRENT, | ||
| "1.8", | ||
| SampleExtensiblePlugin.class.getName(), | ||
| null, | ||
| Collections.emptyList(), | ||
| false | ||
| ), | ||
| new PluginInfo( | ||
| SampleExtendingPlugin.class.getName(), | ||
| "classpath plugin", | ||
| "NA", | ||
| Version.CURRENT, | ||
| "1.8", | ||
| SampleExtendingPlugin.class.getName(), | ||
| null, | ||
| List.of(SampleExtensiblePlugin.class.getName()), | ||
| false | ||
| ) | ||
| ); | ||
| } | ||
|
|
||
| public void testPluginExtensionWithClasspathPlugins() throws IOException { | ||
| internalCluster().startNode(); | ||
| } | ||
| } |
8 changes: 8 additions & 0 deletions
8
...Test/resources/META-INF/services/org.opensearch.plugins.ClasspathPluginIT$SampleExtension
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # The OpenSearch Contributors require contributions made to | ||
| # this file be licensed under the Apache-2.0 license or a | ||
| # compatible open source license. | ||
|
|
||
| org.opensearch.plugins.ClasspathPluginIT$SampleExtendingPlugin |
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.