Kept the original constructor for PluginInfo to maintain bwc (#1206)
This commit is contained in:
parent
f37f29c996
commit
83332c8ab6
|
@ -99,6 +99,24 @@ public class PluginInfo implements Writeable, ToXContentObject {
|
|||
this.hasNativeController = hasNativeController;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct plugin info.
|
||||
*
|
||||
* @param name the name of the plugin
|
||||
* @param description a description of the plugin
|
||||
* @param version an opaque version identifier for the plugin
|
||||
* @param opensearchVersion the version of OpenSearch the plugin was built for
|
||||
* @param javaVersion the version of Java the plugin was built with
|
||||
* @param classname the entry point to the plugin
|
||||
* @param extendedPlugins other plugins this plugin extends through SPI
|
||||
* @param hasNativeController whether or not the plugin has a native controller
|
||||
*/
|
||||
public PluginInfo(String name, String description, String version, Version opensearchVersion, String javaVersion,
|
||||
String classname, List<String> extendedPlugins, boolean hasNativeController) {
|
||||
this(name, description, version, opensearchVersion, javaVersion, classname, null /* customFolderName */,
|
||||
extendedPlugins, hasNativeController);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct plugin info from a stream.
|
||||
*
|
||||
|
|
|
@ -237,7 +237,7 @@ public class PluginInfoTests extends OpenSearchTestCase {
|
|||
|
||||
public void testSerialize() throws Exception {
|
||||
PluginInfo info = new PluginInfo("c", "foo", "dummy", Version.CURRENT, "1.8", "dummyclass",
|
||||
"c", Collections.singletonList("foo"), randomBoolean());
|
||||
"c", Collections.singletonList("foo"), randomBoolean());
|
||||
BytesStreamOutput output = new BytesStreamOutput();
|
||||
info.writeTo(output);
|
||||
ByteBuffer buffer = ByteBuffer.wrap(output.bytes().toBytesRef().bytes);
|
||||
|
@ -250,15 +250,15 @@ public class PluginInfoTests extends OpenSearchTestCase {
|
|||
public void testPluginListSorted() {
|
||||
List<PluginInfo> plugins = new ArrayList<>();
|
||||
plugins.add(new PluginInfo("c", "foo", "dummy", Version.CURRENT, "1.8", "dummyclass",
|
||||
null, Collections.emptyList(), randomBoolean()));
|
||||
Collections.emptyList(), randomBoolean()));
|
||||
plugins.add(new PluginInfo("b", "foo", "dummy", Version.CURRENT, "1.8", "dummyclass",
|
||||
null, Collections.emptyList(), randomBoolean()));
|
||||
Collections.emptyList(), randomBoolean()));
|
||||
plugins.add(new PluginInfo( "e", "foo", "dummy", Version.CURRENT, "1.8", "dummyclass",
|
||||
null, Collections.emptyList(), randomBoolean()));
|
||||
Collections.emptyList(), randomBoolean()));
|
||||
plugins.add(new PluginInfo("a", "foo", "dummy", Version.CURRENT, "1.8", "dummyclass",
|
||||
null, Collections.emptyList(), randomBoolean()));
|
||||
Collections.emptyList(), randomBoolean()));
|
||||
plugins.add(new PluginInfo("d", "foo", "dummy", Version.CURRENT, "1.8", "dummyclass",
|
||||
null, Collections.emptyList(), randomBoolean()));
|
||||
Collections.emptyList(), randomBoolean()));
|
||||
PluginsAndModules pluginsInfo = new PluginsAndModules(plugins, Collections.emptyList());
|
||||
|
||||
final List<PluginInfo> infos = pluginsInfo.getPluginInfos();
|
||||
|
|
|
@ -323,7 +323,7 @@ public class PluginsServiceTests extends OpenSearchTestCase {
|
|||
public void testSortBundlesCycleSelfReference() throws Exception {
|
||||
Path pluginDir = createTempDir();
|
||||
PluginInfo info = new PluginInfo("foo", "desc", "1.0", Version.CURRENT, "1.8",
|
||||
"MyPlugin", null, Collections.singletonList("foo"), false);
|
||||
"MyPlugin", Collections.singletonList("foo"), false);
|
||||
PluginsService.Bundle bundle = new PluginsService.Bundle(info, pluginDir);
|
||||
IllegalStateException e = expectThrows(IllegalStateException.class, () ->
|
||||
PluginsService.sortBundles(Collections.singleton(bundle))
|
||||
|
@ -335,16 +335,16 @@ public class PluginsServiceTests extends OpenSearchTestCase {
|
|||
Path pluginDir = createTempDir();
|
||||
Set<PluginsService.Bundle> bundles = new LinkedHashSet<>(); // control iteration order, so we get know the beginning of the cycle
|
||||
PluginInfo info = new PluginInfo("foo", "desc", "1.0", Version.CURRENT, "1.8",
|
||||
"MyPlugin", null, Arrays.asList("bar", "other"), false);
|
||||
"MyPlugin", Arrays.asList("bar", "other"), false);
|
||||
bundles.add(new PluginsService.Bundle(info, pluginDir));
|
||||
PluginInfo info2 = new PluginInfo("bar", "desc", "1.0", Version.CURRENT, "1.8",
|
||||
"MyPlugin", null, Collections.singletonList("baz"), false);
|
||||
"MyPlugin", Collections.singletonList("baz"), false);
|
||||
bundles.add(new PluginsService.Bundle(info2, pluginDir));
|
||||
PluginInfo info3 = new PluginInfo("baz", "desc", "1.0", Version.CURRENT, "1.8",
|
||||
"MyPlugin", null, Collections.singletonList("foo"), false);
|
||||
"MyPlugin", Collections.singletonList("foo"), false);
|
||||
bundles.add(new PluginsService.Bundle(info3, pluginDir));
|
||||
PluginInfo info4 = new PluginInfo("other", "desc", "1.0", Version.CURRENT, "1.8",
|
||||
"MyPlugin", null, Collections.emptyList(), false);
|
||||
"MyPlugin", Collections.emptyList(), false);
|
||||
bundles.add(new PluginsService.Bundle(info4, pluginDir));
|
||||
|
||||
IllegalStateException e = expectThrows(IllegalStateException.class, () -> PluginsService.sortBundles(bundles));
|
||||
|
@ -354,7 +354,7 @@ public class PluginsServiceTests extends OpenSearchTestCase {
|
|||
public void testSortBundlesSingle() throws Exception {
|
||||
Path pluginDir = createTempDir();
|
||||
PluginInfo info = new PluginInfo("foo", "desc", "1.0", Version.CURRENT, "1.8",
|
||||
"MyPlugin", null, Collections.emptyList(), false);
|
||||
"MyPlugin", Collections.emptyList(), false);
|
||||
PluginsService.Bundle bundle = new PluginsService.Bundle(info, pluginDir);
|
||||
List<PluginsService.Bundle> sortedBundles = PluginsService.sortBundles(Collections.singleton(bundle));
|
||||
assertThat(sortedBundles, Matchers.contains(bundle));
|
||||
|
@ -364,15 +364,15 @@ public class PluginsServiceTests extends OpenSearchTestCase {
|
|||
Path pluginDir = createTempDir();
|
||||
Set<PluginsService.Bundle> bundles = new LinkedHashSet<>(); // control iteration order
|
||||
PluginInfo info1 = new PluginInfo("foo", "desc", "1.0", Version.CURRENT, "1.8",
|
||||
"MyPlugin", null, Collections.emptyList(), false);
|
||||
"MyPlugin", Collections.emptyList(), false);
|
||||
PluginsService.Bundle bundle1 = new PluginsService.Bundle(info1, pluginDir);
|
||||
bundles.add(bundle1);
|
||||
PluginInfo info2 = new PluginInfo("bar", "desc", "1.0", Version.CURRENT, "1.8",
|
||||
"MyPlugin", null, Collections.emptyList(), false);
|
||||
"MyPlugin", Collections.emptyList(), false);
|
||||
PluginsService.Bundle bundle2 = new PluginsService.Bundle(info2, pluginDir);
|
||||
bundles.add(bundle2);
|
||||
PluginInfo info3 = new PluginInfo("baz", "desc", "1.0", Version.CURRENT, "1.8",
|
||||
"MyPlugin", null, Collections.emptyList(), false);
|
||||
"MyPlugin", Collections.emptyList(), false);
|
||||
PluginsService.Bundle bundle3 = new PluginsService.Bundle(info3, pluginDir);
|
||||
bundles.add(bundle3);
|
||||
List<PluginsService.Bundle> sortedBundles = PluginsService.sortBundles(bundles);
|
||||
|
@ -382,7 +382,7 @@ public class PluginsServiceTests extends OpenSearchTestCase {
|
|||
public void testSortBundlesMissingDep() throws Exception {
|
||||
Path pluginDir = createTempDir();
|
||||
PluginInfo info = new PluginInfo("foo", "desc", "1.0", Version.CURRENT, "1.8",
|
||||
"MyPlugin", "", Collections.singletonList("dne"), false);
|
||||
"MyPlugin", Collections.singletonList("dne"), false);
|
||||
PluginsService.Bundle bundle = new PluginsService.Bundle(info, pluginDir);
|
||||
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () ->
|
||||
PluginsService.sortBundles(Collections.singleton(bundle))
|
||||
|
@ -394,19 +394,19 @@ public class PluginsServiceTests extends OpenSearchTestCase {
|
|||
Path pluginDir = createTempDir();
|
||||
Set<PluginsService.Bundle> bundles = new LinkedHashSet<>(); // control iteration order
|
||||
PluginInfo info1 = new PluginInfo("grandparent", "desc", "1.0",Version.CURRENT, "1.8",
|
||||
"MyPlugin", null, Collections.emptyList(), false);
|
||||
"MyPlugin", Collections.emptyList(), false);
|
||||
PluginsService.Bundle bundle1 = new PluginsService.Bundle(info1, pluginDir);
|
||||
bundles.add(bundle1);
|
||||
PluginInfo info2 = new PluginInfo("foo", "desc", "1.0", Version.CURRENT, "1.8",
|
||||
"MyPlugin", null, Collections.singletonList("common"), false);
|
||||
"MyPlugin", Collections.singletonList("common"), false);
|
||||
PluginsService.Bundle bundle2 = new PluginsService.Bundle(info2, pluginDir);
|
||||
bundles.add(bundle2);
|
||||
PluginInfo info3 = new PluginInfo("bar", "desc", "1.0", Version.CURRENT, "1.8",
|
||||
"MyPlugin", null, Collections.singletonList("common"), false);
|
||||
"MyPlugin", Collections.singletonList("common"), false);
|
||||
PluginsService.Bundle bundle3 = new PluginsService.Bundle(info3, pluginDir);
|
||||
bundles.add(bundle3);
|
||||
PluginInfo info4 = new PluginInfo("common", "desc", "1.0", Version.CURRENT, "1.8",
|
||||
"MyPlugin", null, Collections.singletonList("grandparent"), false);
|
||||
"MyPlugin", Collections.singletonList("grandparent"), false);
|
||||
PluginsService.Bundle bundle4 = new PluginsService.Bundle(info4, pluginDir);
|
||||
bundles.add(bundle4);
|
||||
List<PluginsService.Bundle> sortedBundles = PluginsService.sortBundles(bundles);
|
||||
|
@ -417,11 +417,11 @@ public class PluginsServiceTests extends OpenSearchTestCase {
|
|||
Path pluginDir = createTempDir();
|
||||
Set<PluginsService.Bundle> bundles = new LinkedHashSet<>(); // control iteration order
|
||||
PluginInfo info1 = new PluginInfo("dep", "desc", "1.0", Version.CURRENT, "1.8",
|
||||
"MyPlugin", null, Collections.emptyList(), false);
|
||||
"MyPlugin", Collections.emptyList(), false);
|
||||
PluginsService.Bundle bundle1 = new PluginsService.Bundle(info1, pluginDir);
|
||||
bundles.add(bundle1);
|
||||
PluginInfo info2 = new PluginInfo("myplugin", "desc", "1.0", Version.CURRENT, "1.8",
|
||||
"MyPlugin", null, Collections.singletonList("dep"), false);
|
||||
"MyPlugin", Collections.singletonList("dep"), false);
|
||||
PluginsService.Bundle bundle2 = new PluginsService.Bundle(info2, pluginDir);
|
||||
bundles.add(bundle2);
|
||||
List<PluginsService.Bundle> sortedBundles = PluginsService.sortBundles(bundles);
|
||||
|
@ -480,7 +480,7 @@ public class PluginsServiceTests extends OpenSearchTestCase {
|
|||
Map<String, Set<URL>> transitiveDeps = new HashMap<>();
|
||||
transitiveDeps.put("dep", Collections.singleton(dupJar.toUri().toURL()));
|
||||
PluginInfo info1 = new PluginInfo("myplugin", "desc", "1.0", Version.CURRENT, "1.8",
|
||||
"MyPlugin", null, Collections.singletonList("dep"), false);
|
||||
"MyPlugin", Collections.singletonList("dep"), false);
|
||||
PluginsService.Bundle bundle = new PluginsService.Bundle(info1, pluginDir);
|
||||
IllegalStateException e = expectThrows(IllegalStateException.class, () ->
|
||||
PluginsService.checkBundleJarHell(JarHell.parseClassPath(), bundle, transitiveDeps));
|
||||
|
@ -499,7 +499,7 @@ public class PluginsServiceTests extends OpenSearchTestCase {
|
|||
transitiveDeps.put("dep1", Collections.singleton(dupJar.toUri().toURL()));
|
||||
transitiveDeps.put("dep2", Collections.singleton(dupJar.toUri().toURL()));
|
||||
PluginInfo info1 = new PluginInfo("myplugin", "desc", "1.0", Version.CURRENT, "1.8",
|
||||
"MyPlugin", null, Arrays.asList("dep1", "dep2"), false);
|
||||
"MyPlugin", Arrays.asList("dep1", "dep2"), false);
|
||||
PluginsService.Bundle bundle = new PluginsService.Bundle(info1, pluginDir);
|
||||
IllegalStateException e = expectThrows(IllegalStateException.class, () ->
|
||||
PluginsService.checkBundleJarHell(JarHell.parseClassPath(), bundle, transitiveDeps));
|
||||
|
@ -516,7 +516,7 @@ public class PluginsServiceTests extends OpenSearchTestCase {
|
|||
Path pluginJar = pluginDir.resolve("plugin.jar");
|
||||
makeJar(pluginJar, Level.class);
|
||||
PluginInfo info1 = new PluginInfo("myplugin", "desc", "1.0", Version.CURRENT, "1.8",
|
||||
"MyPlugin", null, Collections.emptyList(), false);
|
||||
"MyPlugin", Collections.emptyList(), false);
|
||||
PluginsService.Bundle bundle = new PluginsService.Bundle(info1, pluginDir);
|
||||
IllegalStateException e = expectThrows(IllegalStateException.class, () ->
|
||||
PluginsService.checkBundleJarHell(JarHell.parseClassPath(), bundle, new HashMap<>()));
|
||||
|
@ -535,7 +535,7 @@ public class PluginsServiceTests extends OpenSearchTestCase {
|
|||
Map<String, Set<URL>> transitiveDeps = new HashMap<>();
|
||||
transitiveDeps.put("dep", Collections.singleton(depJar.toUri().toURL()));
|
||||
PluginInfo info1 = new PluginInfo("myplugin", "desc", "1.0", Version.CURRENT, "1.8",
|
||||
"MyPlugin", null, Collections.singletonList("dep"), false);
|
||||
"MyPlugin", Collections.singletonList("dep"), false);
|
||||
PluginsService.Bundle bundle = new PluginsService.Bundle(info1, pluginDir);
|
||||
IllegalStateException e = expectThrows(IllegalStateException.class, () ->
|
||||
PluginsService.checkBundleJarHell(JarHell.parseClassPath(), bundle, transitiveDeps));
|
||||
|
@ -558,7 +558,7 @@ public class PluginsServiceTests extends OpenSearchTestCase {
|
|||
transitiveDeps.put("dep1", Collections.singleton(dep1Jar.toUri().toURL()));
|
||||
transitiveDeps.put("dep2", Collections.singleton(dep2Jar.toUri().toURL()));
|
||||
PluginInfo info1 = new PluginInfo("myplugin", "desc", "1.0", Version.CURRENT, "1.8",
|
||||
"MyPlugin", null, Arrays.asList("dep1", "dep2"), false);
|
||||
"MyPlugin", Arrays.asList("dep1", "dep2"), false);
|
||||
PluginsService.Bundle bundle = new PluginsService.Bundle(info1, pluginDir);
|
||||
IllegalStateException e = expectThrows(IllegalStateException.class, () ->
|
||||
PluginsService.checkBundleJarHell(JarHell.parseClassPath(), bundle, transitiveDeps));
|
||||
|
@ -581,7 +581,7 @@ public class PluginsServiceTests extends OpenSearchTestCase {
|
|||
transitiveDeps.put("dep1", Collections.singleton(dep1Jar.toUri().toURL()));
|
||||
transitiveDeps.put("dep2", Collections.singleton(dep2Jar.toUri().toURL()));
|
||||
PluginInfo info1 = new PluginInfo("myplugin", "desc", "1.0", Version.CURRENT, "1.8",
|
||||
"MyPlugin", null, Arrays.asList("dep1", "dep2"), false);
|
||||
"MyPlugin", Arrays.asList("dep1", "dep2"), false);
|
||||
PluginsService.Bundle bundle = new PluginsService.Bundle(info1, pluginDir);
|
||||
PluginsService.checkBundleJarHell(JarHell.parseClassPath(), bundle, transitiveDeps);
|
||||
Set<URL> deps = transitiveDeps.get("myplugin");
|
||||
|
@ -630,14 +630,14 @@ public class PluginsServiceTests extends OpenSearchTestCase {
|
|||
|
||||
public void testIncompatibleOpenSearchVersion() throws Exception {
|
||||
PluginInfo info = new PluginInfo("my_plugin", "desc", "1.0", LegacyESVersion.V_6_0_0,
|
||||
"1.8", "FakePlugin", null, Collections.emptyList(), false);
|
||||
"1.8", "FakePlugin", Collections.emptyList(), false);
|
||||
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> PluginsService.verifyCompatibility(info));
|
||||
assertThat(e.getMessage(), containsString("was built for OpenSearch version 6.0.0"));
|
||||
}
|
||||
|
||||
public void testIncompatibleJavaVersion() throws Exception {
|
||||
PluginInfo info = new PluginInfo("my_plugin", "desc", "1.0", Version.CURRENT,
|
||||
"1000000.0", "FakePlugin", null, Collections.emptyList(), false);
|
||||
"1000000.0", "FakePlugin", Collections.emptyList(), false);
|
||||
IllegalStateException e = expectThrows(IllegalStateException.class, () -> PluginsService.verifyCompatibility(info));
|
||||
assertThat(e.getMessage(), containsString("my_plugin requires Java"));
|
||||
}
|
||||
|
@ -761,7 +761,7 @@ public class PluginsServiceTests extends OpenSearchTestCase {
|
|||
public void testExtensiblePlugin() {
|
||||
TestExtensiblePlugin extensiblePlugin = new TestExtensiblePlugin();
|
||||
PluginsService.loadExtensions(Collections.singletonList(
|
||||
Tuple.tuple(new PluginInfo("extensible", null, null, null, null, null, null, Collections.emptyList(), false), extensiblePlugin)
|
||||
Tuple.tuple(new PluginInfo("extensible", null, null, null, null, null, Collections.emptyList(), false), extensiblePlugin)
|
||||
));
|
||||
|
||||
assertThat(extensiblePlugin.extensions, notNullValue());
|
||||
|
@ -770,8 +770,8 @@ public class PluginsServiceTests extends OpenSearchTestCase {
|
|||
extensiblePlugin = new TestExtensiblePlugin();
|
||||
TestPlugin testPlugin = new TestPlugin();
|
||||
PluginsService.loadExtensions(Arrays.asList(
|
||||
Tuple.tuple(new PluginInfo("extensible", null, null, null, null, null, null, Collections.emptyList(), false), extensiblePlugin),
|
||||
Tuple.tuple(new PluginInfo("test", null, null, null, null, null, null, Collections.singletonList("extensible"), false),
|
||||
Tuple.tuple(new PluginInfo("extensible", null, null, null, null, null, Collections.emptyList(), false), extensiblePlugin),
|
||||
Tuple.tuple(new PluginInfo("test", null, null, null, null, null, Collections.singletonList("extensible"), false),
|
||||
testPlugin)
|
||||
));
|
||||
|
||||
|
|
Loading…
Reference in New Issue