-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for classpath plugin extended plugin loading
Signed-off-by: Craig Perkins <[email protected]>
- Loading branch information
Showing
2 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
server/src/internalClusterTest/java/org/opensearch/plugins/ClasspathPluginIT.java
This file contains 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,52 @@ | ||
/* | ||
* 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.test.OpenSearchIntegTestCase; | ||
|
||
import java.io.IOException; | ||
import java.util.Collection; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.Stream; | ||
|
||
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<Class<? extends Plugin>> nodePlugins() { | ||
return Stream.concat(super.nodePlugins().stream(), Stream.of(SampleExtensiblePlugin.class, SampleExtendingPlugin.class)) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
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 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 |