diff --git a/server/src/internalClusterTest/java/org/opensearch/plugins/ClasspathPluginIT.java b/server/src/internalClusterTest/java/org/opensearch/plugins/ClasspathPluginIT.java new file mode 100644 index 0000000000000..fffef3f55c5b3 --- /dev/null +++ b/server/src/internalClusterTest/java/org/opensearch/plugins/ClasspathPluginIT.java @@ -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> nodePlugins() { + return Stream.concat(super.nodePlugins().stream(), Stream.of(SampleExtensiblePlugin.class, SampleExtendingPlugin.class)) + .collect(Collectors.toList()); + } + + public void testPluginExtensionWithClasspathPlugins() throws IOException { + internalCluster().startNode(); + } +} diff --git a/server/src/internalClusterTest/resources/META-INF/services/org.opensearch.plugins.ClasspathPluginIT$SampleExtension b/server/src/internalClusterTest/resources/META-INF/services/org.opensearch.plugins.ClasspathPluginIT$SampleExtension new file mode 100644 index 0000000000000..f369b9d0f63b7 --- /dev/null +++ b/server/src/internalClusterTest/resources/META-INF/services/org.opensearch.plugins.ClasspathPluginIT$SampleExtension @@ -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