Skip to content

Commit

Permalink
Add test for classpath plugin extended plugin loading
Browse files Browse the repository at this point in the history
Signed-off-by: Craig Perkins <[email protected]>
  • Loading branch information
cwperks committed Dec 22, 2024
1 parent 7b4d7d7 commit 1614706
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
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();
}
}
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

0 comments on commit 1614706

Please sign in to comment.