Plugins: Store elasticsearch and java versions in PluginInfo (#28556)
Plugin descriptors currently contain an elasticsearch version, which the plugin was built against, and a java version, which the plugin was built with. These versions are read and validated, but not stored. This commit keeps them in PluginInfo so they can be used later. While seeing the elasticsearch version is less interesting (since it is enforced to match that of the running elasticsearc node), the java version is interesting since we only validate the format, not the actual version. This also makes PluginInfo have full parity with the plugin properties file.
This commit is contained in:
parent
cb7159d4c9
commit
a55eda626f
|
@ -145,7 +145,8 @@ task verifyVersions {
|
|||
* after the backport of the backcompat code is complete.
|
||||
*/
|
||||
allprojects {
|
||||
ext.bwc_tests_enabled = true
|
||||
// TODO: re-enable after backport of https://github.com/elastic/elasticsearch/pull/28556
|
||||
ext.bwc_tests_enabled = false
|
||||
}
|
||||
|
||||
task verifyBwcTestsEnabled {
|
||||
|
|
|
@ -130,7 +130,7 @@ public class ListPluginsCommandTests extends ESTestCase {
|
|||
"name", name,
|
||||
"version", "1.0",
|
||||
"elasticsearch.version", Version.CURRENT.toString(),
|
||||
"java.version", System.getProperty("java.specification.version"),
|
||||
"java.version", "1.8",
|
||||
"classname", classname,
|
||||
"has.native.controller", Boolean.toString(hasNativeController),
|
||||
"requires.keystore", Boolean.toString(requiresKeystore));
|
||||
|
@ -192,6 +192,8 @@ public class ListPluginsCommandTests extends ESTestCase {
|
|||
"Name: fake_plugin",
|
||||
"Description: fake desc",
|
||||
"Version: 1.0",
|
||||
"Elasticsearch Version: " + Version.CURRENT.toString(),
|
||||
"Java Version: 1.8",
|
||||
"Native Controller: false",
|
||||
"Requires Keystore: false",
|
||||
"Extended Plugins: []",
|
||||
|
@ -211,6 +213,8 @@ public class ListPluginsCommandTests extends ESTestCase {
|
|||
"Name: fake_plugin1",
|
||||
"Description: fake desc 1",
|
||||
"Version: 1.0",
|
||||
"Elasticsearch Version: " + Version.CURRENT.toString(),
|
||||
"Java Version: 1.8",
|
||||
"Native Controller: true",
|
||||
"Requires Keystore: false",
|
||||
"Extended Plugins: []",
|
||||
|
@ -230,6 +234,8 @@ public class ListPluginsCommandTests extends ESTestCase {
|
|||
"Name: fake_plugin1",
|
||||
"Description: fake desc 1",
|
||||
"Version: 1.0",
|
||||
"Elasticsearch Version: " + Version.CURRENT.toString(),
|
||||
"Java Version: 1.8",
|
||||
"Native Controller: false",
|
||||
"Requires Keystore: true",
|
||||
"Extended Plugins: []",
|
||||
|
@ -250,6 +256,8 @@ public class ListPluginsCommandTests extends ESTestCase {
|
|||
"Name: fake_plugin1",
|
||||
"Description: fake desc 1",
|
||||
"Version: 1.0",
|
||||
"Elasticsearch Version: " + Version.CURRENT.toString(),
|
||||
"Java Version: 1.8",
|
||||
"Native Controller: false",
|
||||
"Requires Keystore: false",
|
||||
"Extended Plugins: []",
|
||||
|
@ -259,6 +267,8 @@ public class ListPluginsCommandTests extends ESTestCase {
|
|||
"Name: fake_plugin2",
|
||||
"Description: fake desc 2",
|
||||
"Version: 1.0",
|
||||
"Elasticsearch Version: " + Version.CURRENT.toString(),
|
||||
"Java Version: 1.8",
|
||||
"Native Controller: false",
|
||||
"Requires Keystore: false",
|
||||
"Extended Plugins: []",
|
||||
|
@ -281,6 +291,8 @@ public class ListPluginsCommandTests extends ESTestCase {
|
|||
"\tName: fake_plugin1",
|
||||
"\tDescription: fake desc 1",
|
||||
"\tVersion: 1.0",
|
||||
"\tElasticsearch Version: " + Version.CURRENT.toString(),
|
||||
"\tJava Version: 1.8",
|
||||
"\tNative Controller: false",
|
||||
"\tRequires Keystore: false",
|
||||
"\tExtended Plugins: []",
|
||||
|
@ -290,6 +302,8 @@ public class ListPluginsCommandTests extends ESTestCase {
|
|||
"\tName: fake_plugin2",
|
||||
"\tDescription: fake desc 2",
|
||||
"\tVersion: 1.0",
|
||||
"\tElasticsearch Version: " + Version.CURRENT.toString(),
|
||||
"\tJava Version: 1.8",
|
||||
"\tNative Controller: false",
|
||||
"\tRequires Keystore: false",
|
||||
"\tExtended Plugins: []",
|
||||
|
|
|
@ -22,7 +22,6 @@ package org.elasticsearch.plugins;
|
|||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.bootstrap.JarHell;
|
||||
import org.elasticsearch.common.Booleans;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.io.FileSystemUtils;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
|
@ -36,7 +35,6 @@ import java.io.InputStream;
|
|||
import java.nio.file.DirectoryStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
|
@ -60,6 +58,8 @@ public class PluginInfo implements Writeable, ToXContentObject {
|
|||
private final String name;
|
||||
private final String description;
|
||||
private final String version;
|
||||
private final Version elasticsearchVersion;
|
||||
private final String javaVersion;
|
||||
private final String classname;
|
||||
private final List<String> extendedPlugins;
|
||||
private final boolean hasNativeController;
|
||||
|
@ -68,19 +68,23 @@ public class PluginInfo implements Writeable, ToXContentObject {
|
|||
/**
|
||||
* Construct plugin info.
|
||||
*
|
||||
* @param name the name of the plugin
|
||||
* @param description a description of the plugin
|
||||
* @param version the version of Elasticsearch the plugin is built for
|
||||
* @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
|
||||
* @param requiresKeystore whether or not the plugin requires the elasticsearch keystore to be created
|
||||
* @param name the name of the plugin
|
||||
* @param description a description of the plugin
|
||||
* @param version an opaque version identifier for the plugin
|
||||
* @param elasticsearchVersion the version of Elasticsearch 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
|
||||
* @param requiresKeystore whether or not the plugin requires the elasticsearch keystore to be created
|
||||
*/
|
||||
public PluginInfo(String name, String description, String version, String classname,
|
||||
List<String> extendedPlugins, boolean hasNativeController, boolean requiresKeystore) {
|
||||
public PluginInfo(String name, String description, String version, Version elasticsearchVersion, String javaVersion,
|
||||
String classname, List<String> extendedPlugins, boolean hasNativeController, boolean requiresKeystore) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.version = version;
|
||||
this.elasticsearchVersion = elasticsearchVersion;
|
||||
this.javaVersion = javaVersion;
|
||||
this.classname = classname;
|
||||
this.extendedPlugins = Collections.unmodifiableList(extendedPlugins);
|
||||
this.hasNativeController = hasNativeController;
|
||||
|
@ -97,6 +101,15 @@ public class PluginInfo implements Writeable, ToXContentObject {
|
|||
this.name = in.readString();
|
||||
this.description = in.readString();
|
||||
this.version = in.readString();
|
||||
if (in.getVersion().onOrAfter(Version.V_6_3_0)) {
|
||||
elasticsearchVersion = Version.readVersion(in);
|
||||
javaVersion = in.readString();
|
||||
} else {
|
||||
// the plugin must have the version of whichever node we are talking to, since this is enforced on startup
|
||||
elasticsearchVersion = in.getVersion();
|
||||
// this might not be true, but it is not important, we just need something here for bwc that is a valid java version string
|
||||
javaVersion = "1.8";
|
||||
}
|
||||
this.classname = in.readString();
|
||||
if (in.getVersion().onOrAfter(Version.V_6_2_0)) {
|
||||
extendedPlugins = in.readList(StreamInput::readString);
|
||||
|
@ -120,6 +133,10 @@ public class PluginInfo implements Writeable, ToXContentObject {
|
|||
out.writeString(name);
|
||||
out.writeString(description);
|
||||
out.writeString(version);
|
||||
if (out.getVersion().onOrAfter(Version.V_6_3_0)) {
|
||||
Version.writeVersion(elasticsearchVersion, out);
|
||||
out.writeString(javaVersion);
|
||||
}
|
||||
out.writeString(classname);
|
||||
if (out.getVersion().onOrAfter(Version.V_6_2_0)) {
|
||||
out.writeStringList(extendedPlugins);
|
||||
|
@ -297,7 +314,8 @@ public class PluginInfo implements Writeable, ToXContentObject {
|
|||
throw new IllegalArgumentException("Unknown properties in plugin descriptor: " + propsMap.keySet());
|
||||
}
|
||||
|
||||
return new PluginInfo(name, description, version, classname, extendedPlugins, hasNativeController, requiresKeystore);
|
||||
return new PluginInfo(name, description, version, esVersion, javaVersionString,
|
||||
classname, extendedPlugins, hasNativeController, requiresKeystore);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -337,7 +355,7 @@ public class PluginInfo implements Writeable, ToXContentObject {
|
|||
}
|
||||
|
||||
/**
|
||||
* The version of Elasticsearch the plugin was built for.
|
||||
* The version of the plugin
|
||||
*
|
||||
* @return the version
|
||||
*/
|
||||
|
@ -345,6 +363,24 @@ public class PluginInfo implements Writeable, ToXContentObject {
|
|||
return version;
|
||||
}
|
||||
|
||||
/**
|
||||
* The version of Elasticsearch the plugin was built for.
|
||||
*
|
||||
* @return an Elasticsearch version
|
||||
*/
|
||||
public Version getElasticsearchVersion() {
|
||||
return elasticsearchVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* The version of Java the plugin was built with.
|
||||
*
|
||||
* @return a java version string
|
||||
*/
|
||||
public String getJavaVersion() {
|
||||
return javaVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not the plugin has a native controller.
|
||||
*
|
||||
|
@ -369,6 +405,8 @@ public class PluginInfo implements Writeable, ToXContentObject {
|
|||
{
|
||||
builder.field("name", name);
|
||||
builder.field("version", version);
|
||||
builder.field("elasticsearch_version", elasticsearchVersion);
|
||||
builder.field("java_version", javaVersion);
|
||||
builder.field("description", description);
|
||||
builder.field("classname", classname);
|
||||
builder.field("extended_plugins", extendedPlugins);
|
||||
|
@ -388,6 +426,7 @@ public class PluginInfo implements Writeable, ToXContentObject {
|
|||
PluginInfo that = (PluginInfo) o;
|
||||
|
||||
if (!name.equals(that.name)) return false;
|
||||
// TODO: since the plugins are unique by their directory name, this should only be a name check, version should not matter?
|
||||
if (version != null ? !version.equals(that.version) : that.version != null) return false;
|
||||
|
||||
return true;
|
||||
|
@ -409,6 +448,8 @@ public class PluginInfo implements Writeable, ToXContentObject {
|
|||
.append(prefix).append("Name: ").append(name).append("\n")
|
||||
.append(prefix).append("Description: ").append(description).append("\n")
|
||||
.append(prefix).append("Version: ").append(version).append("\n")
|
||||
.append(prefix).append("Elasticsearch Version: ").append(elasticsearchVersion).append("\n")
|
||||
.append(prefix).append("Java Version: ").append(javaVersion).append("\n")
|
||||
.append(prefix).append("Native Controller: ").append(hasNativeController).append("\n")
|
||||
.append(prefix).append("Requires Keystore: ").append(requiresKeystore).append("\n")
|
||||
.append(prefix).append("Extended Plugins: ").append(extendedPlugins).append("\n")
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.apache.lucene.codecs.Codec;
|
|||
import org.apache.lucene.codecs.DocValuesFormat;
|
||||
import org.apache.lucene.codecs.PostingsFormat;
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.action.admin.cluster.node.info.PluginsAndModules;
|
||||
import org.elasticsearch.bootstrap.JarHell;
|
||||
import org.elasticsearch.common.Strings;
|
||||
|
@ -102,7 +103,7 @@ public class PluginsService extends AbstractComponent {
|
|||
// first we load plugins that are on the classpath. this is for tests and transport clients
|
||||
for (Class<? extends Plugin> pluginClass : classpathPlugins) {
|
||||
Plugin plugin = loadPlugin(pluginClass, settings, configPath);
|
||||
PluginInfo pluginInfo = new PluginInfo(pluginClass.getName(), "classpath plugin", "NA",
|
||||
PluginInfo pluginInfo = new PluginInfo(pluginClass.getName(), "classpath plugin", "NA", Version.CURRENT, "1.8",
|
||||
pluginClass.getName(), Collections.emptyList(), false, false);
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("plugin loaded from classpath [{}]", pluginInfo);
|
||||
|
|
|
@ -144,15 +144,15 @@ public class NodeInfoStreamingTests extends ESTestCase {
|
|||
List<PluginInfo> plugins = new ArrayList<>();
|
||||
for (int i = 0; i < numPlugins; i++) {
|
||||
plugins.add(new PluginInfo(randomAlphaOfLengthBetween(3, 10), randomAlphaOfLengthBetween(3, 10),
|
||||
randomAlphaOfLengthBetween(3, 10), randomAlphaOfLengthBetween(3, 10), Collections.emptyList(),
|
||||
randomBoolean(), randomBoolean()));
|
||||
randomAlphaOfLengthBetween(3, 10), VersionUtils.randomVersion(random()), "1.8",
|
||||
randomAlphaOfLengthBetween(3, 10), Collections.emptyList(), randomBoolean(), randomBoolean()));
|
||||
}
|
||||
int numModules = randomIntBetween(0, 5);
|
||||
List<PluginInfo> modules = new ArrayList<>();
|
||||
for (int i = 0; i < numModules; i++) {
|
||||
modules.add(new PluginInfo(randomAlphaOfLengthBetween(3, 10), randomAlphaOfLengthBetween(3, 10),
|
||||
randomAlphaOfLengthBetween(3, 10), randomAlphaOfLengthBetween(3, 10), Collections.emptyList(),
|
||||
randomBoolean(), randomBoolean()));
|
||||
randomAlphaOfLengthBetween(3, 10), VersionUtils.randomVersion(random()), "1.8",
|
||||
randomAlphaOfLengthBetween(3, 10), Collections.emptyList(), randomBoolean(), randomBoolean()));
|
||||
}
|
||||
pluginsAndModules = new PluginsAndModules(plugins, modules);
|
||||
}
|
||||
|
|
|
@ -209,7 +209,7 @@ public class PluginInfoTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testSerialize() throws Exception {
|
||||
PluginInfo info = new PluginInfo("c", "foo", "dummy", "dummyclass",
|
||||
PluginInfo info = new PluginInfo("c", "foo", "dummy", Version.CURRENT, "1.8", "dummyclass",
|
||||
Collections.singletonList("foo"), randomBoolean(), randomBoolean());
|
||||
BytesStreamOutput output = new BytesStreamOutput();
|
||||
info.writeTo(output);
|
||||
|
@ -222,11 +222,16 @@ public class PluginInfoTests extends ESTestCase {
|
|||
|
||||
public void testPluginListSorted() {
|
||||
List<PluginInfo> plugins = new ArrayList<>();
|
||||
plugins.add(new PluginInfo("c", "foo", "dummy", "dummyclass", Collections.emptyList(), randomBoolean(), randomBoolean()));
|
||||
plugins.add(new PluginInfo("b", "foo", "dummy", "dummyclass", Collections.emptyList(),randomBoolean(), randomBoolean()));
|
||||
plugins.add(new PluginInfo( "e", "foo", "dummy", "dummyclass", Collections.emptyList(),randomBoolean(), randomBoolean()));
|
||||
plugins.add(new PluginInfo("a", "foo", "dummy", "dummyclass", Collections.emptyList(),randomBoolean(), randomBoolean()));
|
||||
plugins.add(new PluginInfo("d", "foo", "dummy", "dummyclass", Collections.emptyList(),randomBoolean(), randomBoolean()));
|
||||
plugins.add(new PluginInfo("c", "foo", "dummy", Version.CURRENT, "1.8", "dummyclass",
|
||||
Collections.emptyList(), randomBoolean(), randomBoolean()));
|
||||
plugins.add(new PluginInfo("b", "foo", "dummy", Version.CURRENT, "1.8", "dummyclass",
|
||||
Collections.emptyList(), randomBoolean(), randomBoolean()));
|
||||
plugins.add(new PluginInfo( "e", "foo", "dummy", Version.CURRENT, "1.8", "dummyclass",
|
||||
Collections.emptyList(), randomBoolean(), randomBoolean()));
|
||||
plugins.add(new PluginInfo("a", "foo", "dummy", Version.CURRENT, "1.8", "dummyclass",
|
||||
Collections.emptyList(), randomBoolean(), randomBoolean()));
|
||||
plugins.add(new PluginInfo("d", "foo", "dummy", Version.CURRENT, "1.8", "dummyclass",
|
||||
Collections.emptyList(), randomBoolean(), randomBoolean()));
|
||||
PluginsAndModules pluginsInfo = new PluginsAndModules(plugins, Collections.emptyList());
|
||||
|
||||
final List<PluginInfo> infos = pluginsInfo.getPluginInfos();
|
||||
|
|
|
@ -285,7 +285,8 @@ public class PluginsServiceTests extends ESTestCase {
|
|||
|
||||
public void testSortBundlesCycleSelfReference() throws Exception {
|
||||
Path pluginDir = createTempDir();
|
||||
PluginInfo info = new PluginInfo("foo", "desc", "1.0", "MyPlugin", Collections.singletonList("foo"), false, false);
|
||||
PluginInfo info = new PluginInfo("foo", "desc", "1.0", Version.CURRENT, "1.8",
|
||||
"MyPlugin", Collections.singletonList("foo"), false, false);
|
||||
PluginsService.Bundle bundle = new PluginsService.Bundle(info, pluginDir);
|
||||
IllegalStateException e = expectThrows(IllegalStateException.class, () ->
|
||||
PluginsService.sortBundles(Collections.singleton(bundle))
|
||||
|
@ -296,13 +297,17 @@ public class PluginsServiceTests extends ESTestCase {
|
|||
public void testSortBundlesCycle() throws Exception {
|
||||
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", "MyPlugin", Arrays.asList("bar", "other"), false, false);
|
||||
PluginInfo info = new PluginInfo("foo", "desc", "1.0", Version.CURRENT, "1.8",
|
||||
"MyPlugin", Arrays.asList("bar", "other"), false, false);
|
||||
bundles.add(new PluginsService.Bundle(info, pluginDir));
|
||||
PluginInfo info2 = new PluginInfo("bar", "desc", "1.0", "MyPlugin", Collections.singletonList("baz"), false, false);
|
||||
PluginInfo info2 = new PluginInfo("bar", "desc", "1.0", Version.CURRENT, "1.8",
|
||||
"MyPlugin", Collections.singletonList("baz"), false, false);
|
||||
bundles.add(new PluginsService.Bundle(info2, pluginDir));
|
||||
PluginInfo info3 = new PluginInfo("baz", "desc", "1.0", "MyPlugin", Collections.singletonList("foo"), false, false);
|
||||
PluginInfo info3 = new PluginInfo("baz", "desc", "1.0", Version.CURRENT, "1.8",
|
||||
"MyPlugin", Collections.singletonList("foo"), false, false);
|
||||
bundles.add(new PluginsService.Bundle(info3, pluginDir));
|
||||
PluginInfo info4 = new PluginInfo("other", "desc", "1.0", "MyPlugin", Collections.emptyList(), false, false);
|
||||
PluginInfo info4 = new PluginInfo("other", "desc", "1.0", Version.CURRENT, "1.8",
|
||||
"MyPlugin", Collections.emptyList(), false, false);
|
||||
bundles.add(new PluginsService.Bundle(info4, pluginDir));
|
||||
|
||||
IllegalStateException e = expectThrows(IllegalStateException.class, () -> PluginsService.sortBundles(bundles));
|
||||
|
@ -311,7 +316,8 @@ public class PluginsServiceTests extends ESTestCase {
|
|||
|
||||
public void testSortBundlesSingle() throws Exception {
|
||||
Path pluginDir = createTempDir();
|
||||
PluginInfo info = new PluginInfo("foo", "desc", "1.0", "MyPlugin", Collections.emptyList(), false, false);
|
||||
PluginInfo info = new PluginInfo("foo", "desc", "1.0", Version.CURRENT, "1.8",
|
||||
"MyPlugin", Collections.emptyList(), false, false);
|
||||
PluginsService.Bundle bundle = new PluginsService.Bundle(info, pluginDir);
|
||||
List<PluginsService.Bundle> sortedBundles = PluginsService.sortBundles(Collections.singleton(bundle));
|
||||
assertThat(sortedBundles, Matchers.contains(bundle));
|
||||
|
@ -320,13 +326,16 @@ public class PluginsServiceTests extends ESTestCase {
|
|||
public void testSortBundlesNoDeps() throws Exception {
|
||||
Path pluginDir = createTempDir();
|
||||
Set<PluginsService.Bundle> bundles = new LinkedHashSet<>(); // control iteration order
|
||||
PluginInfo info1 = new PluginInfo("foo", "desc", "1.0", "MyPlugin", Collections.emptyList(), false, false);
|
||||
PluginInfo info1 = new PluginInfo("foo", "desc", "1.0", Version.CURRENT, "1.8",
|
||||
"MyPlugin", Collections.emptyList(), false, false);
|
||||
PluginsService.Bundle bundle1 = new PluginsService.Bundle(info1, pluginDir);
|
||||
bundles.add(bundle1);
|
||||
PluginInfo info2 = new PluginInfo("bar", "desc", "1.0", "MyPlugin", Collections.emptyList(), false, false);
|
||||
PluginInfo info2 = new PluginInfo("bar", "desc", "1.0", Version.CURRENT, "1.8",
|
||||
"MyPlugin", Collections.emptyList(), false, false);
|
||||
PluginsService.Bundle bundle2 = new PluginsService.Bundle(info2, pluginDir);
|
||||
bundles.add(bundle2);
|
||||
PluginInfo info3 = new PluginInfo("baz", "desc", "1.0", "MyPlugin", Collections.emptyList(), false, false);
|
||||
PluginInfo info3 = new PluginInfo("baz", "desc", "1.0", Version.CURRENT, "1.8",
|
||||
"MyPlugin", Collections.emptyList(), false, false);
|
||||
PluginsService.Bundle bundle3 = new PluginsService.Bundle(info3, pluginDir);
|
||||
bundles.add(bundle3);
|
||||
List<PluginsService.Bundle> sortedBundles = PluginsService.sortBundles(bundles);
|
||||
|
@ -335,7 +344,8 @@ public class PluginsServiceTests extends ESTestCase {
|
|||
|
||||
public void testSortBundlesMissingDep() throws Exception {
|
||||
Path pluginDir = createTempDir();
|
||||
PluginInfo info = new PluginInfo("foo", "desc", "1.0", "MyPlugin", Collections.singletonList("dne"), false, false);
|
||||
PluginInfo info = new PluginInfo("foo", "desc", "1.0", Version.CURRENT, "1.8",
|
||||
"MyPlugin", Collections.singletonList("dne"), false, false);
|
||||
PluginsService.Bundle bundle = new PluginsService.Bundle(info, pluginDir);
|
||||
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () ->
|
||||
PluginsService.sortBundles(Collections.singleton(bundle))
|
||||
|
@ -346,16 +356,20 @@ public class PluginsServiceTests extends ESTestCase {
|
|||
public void testSortBundlesCommonDep() throws Exception {
|
||||
Path pluginDir = createTempDir();
|
||||
Set<PluginsService.Bundle> bundles = new LinkedHashSet<>(); // control iteration order
|
||||
PluginInfo info1 = new PluginInfo("grandparent", "desc", "1.0", "MyPlugin", Collections.emptyList(), false, false);
|
||||
PluginInfo info1 = new PluginInfo("grandparent", "desc", "1.0",Version.CURRENT, "1.8",
|
||||
"MyPlugin", Collections.emptyList(), false, false);
|
||||
PluginsService.Bundle bundle1 = new PluginsService.Bundle(info1, pluginDir);
|
||||
bundles.add(bundle1);
|
||||
PluginInfo info2 = new PluginInfo("foo", "desc", "1.0", "MyPlugin", Collections.singletonList("common"), false, false);
|
||||
PluginInfo info2 = new PluginInfo("foo", "desc", "1.0", Version.CURRENT, "1.8",
|
||||
"MyPlugin", Collections.singletonList("common"), false, false);
|
||||
PluginsService.Bundle bundle2 = new PluginsService.Bundle(info2, pluginDir);
|
||||
bundles.add(bundle2);
|
||||
PluginInfo info3 = new PluginInfo("bar", "desc", "1.0", "MyPlugin", Collections.singletonList("common"), false, false);
|
||||
PluginInfo info3 = new PluginInfo("bar", "desc", "1.0", Version.CURRENT, "1.8",
|
||||
"MyPlugin", Collections.singletonList("common"), false, false);
|
||||
PluginsService.Bundle bundle3 = new PluginsService.Bundle(info3, pluginDir);
|
||||
bundles.add(bundle3);
|
||||
PluginInfo info4 = new PluginInfo("common", "desc", "1.0", "MyPlugin", Collections.singletonList("grandparent"), false, false);
|
||||
PluginInfo info4 = new PluginInfo("common", "desc", "1.0", Version.CURRENT, "1.8",
|
||||
"MyPlugin", Collections.singletonList("grandparent"), false, false);
|
||||
PluginsService.Bundle bundle4 = new PluginsService.Bundle(info4, pluginDir);
|
||||
bundles.add(bundle4);
|
||||
List<PluginsService.Bundle> sortedBundles = PluginsService.sortBundles(bundles);
|
||||
|
@ -365,10 +379,12 @@ public class PluginsServiceTests extends ESTestCase {
|
|||
public void testSortBundlesAlreadyOrdered() throws Exception {
|
||||
Path pluginDir = createTempDir();
|
||||
Set<PluginsService.Bundle> bundles = new LinkedHashSet<>(); // control iteration order
|
||||
PluginInfo info1 = new PluginInfo("dep", "desc", "1.0", "MyPlugin", Collections.emptyList(), false, false);
|
||||
PluginInfo info1 = new PluginInfo("dep", "desc", "1.0", Version.CURRENT, "1.8",
|
||||
"MyPlugin", Collections.emptyList(), false, false);
|
||||
PluginsService.Bundle bundle1 = new PluginsService.Bundle(info1, pluginDir);
|
||||
bundles.add(bundle1);
|
||||
PluginInfo info2 = new PluginInfo("myplugin", "desc", "1.0", "MyPlugin", Collections.singletonList("dep"), false, false);
|
||||
PluginInfo info2 = new PluginInfo("myplugin", "desc", "1.0", Version.CURRENT, "1.8",
|
||||
"MyPlugin", Collections.singletonList("dep"), false, false);
|
||||
PluginsService.Bundle bundle2 = new PluginsService.Bundle(info2, pluginDir);
|
||||
bundles.add(bundle2);
|
||||
List<PluginsService.Bundle> sortedBundles = PluginsService.sortBundles(bundles);
|
||||
|
@ -426,7 +442,8 @@ public class PluginsServiceTests extends ESTestCase {
|
|||
makeJar(dupJar);
|
||||
Map<String, Set<URL>> transitiveDeps = new HashMap<>();
|
||||
transitiveDeps.put("dep", Collections.singleton(dupJar.toUri().toURL()));
|
||||
PluginInfo info1 = new PluginInfo("myplugin", "desc", "1.0", "MyPlugin", Collections.singletonList("dep"), false, false);
|
||||
PluginInfo info1 = new PluginInfo("myplugin", "desc", "1.0", Version.CURRENT, "1.8",
|
||||
"MyPlugin", Collections.singletonList("dep"), false, false);
|
||||
PluginsService.Bundle bundle = new PluginsService.Bundle(info1, pluginDir);
|
||||
IllegalStateException e = expectThrows(IllegalStateException.class, () ->
|
||||
PluginsService.checkBundleJarHell(bundle, transitiveDeps));
|
||||
|
@ -444,7 +461,8 @@ public class PluginsServiceTests extends ESTestCase {
|
|||
Map<String, Set<URL>> transitiveDeps = new HashMap<>();
|
||||
transitiveDeps.put("dep1", Collections.singleton(dupJar.toUri().toURL()));
|
||||
transitiveDeps.put("dep2", Collections.singleton(dupJar.toUri().toURL()));
|
||||
PluginInfo info1 = new PluginInfo("myplugin", "desc", "1.0", "MyPlugin", Arrays.asList("dep1", "dep2"), false, false);
|
||||
PluginInfo info1 = new PluginInfo("myplugin", "desc", "1.0", Version.CURRENT, "1.8",
|
||||
"MyPlugin", Arrays.asList("dep1", "dep2"), false, false);
|
||||
PluginsService.Bundle bundle = new PluginsService.Bundle(info1, pluginDir);
|
||||
IllegalStateException e = expectThrows(IllegalStateException.class, () ->
|
||||
PluginsService.checkBundleJarHell(bundle, transitiveDeps));
|
||||
|
@ -460,7 +478,8 @@ public class PluginsServiceTests extends ESTestCase {
|
|||
Path pluginDir = createTempDir();
|
||||
Path pluginJar = pluginDir.resolve("plugin.jar");
|
||||
makeJar(pluginJar, Level.class);
|
||||
PluginInfo info1 = new PluginInfo("myplugin", "desc", "1.0", "MyPlugin", Collections.emptyList(), false, false);
|
||||
PluginInfo info1 = new PluginInfo("myplugin", "desc", "1.0", Version.CURRENT, "1.8",
|
||||
"MyPlugin", Collections.emptyList(), false, false);
|
||||
PluginsService.Bundle bundle = new PluginsService.Bundle(info1, pluginDir);
|
||||
IllegalStateException e = expectThrows(IllegalStateException.class, () ->
|
||||
PluginsService.checkBundleJarHell(bundle, new HashMap<>()));
|
||||
|
@ -478,7 +497,8 @@ public class PluginsServiceTests extends ESTestCase {
|
|||
makeJar(depJar, DummyClass1.class);
|
||||
Map<String, Set<URL>> transitiveDeps = new HashMap<>();
|
||||
transitiveDeps.put("dep", Collections.singleton(depJar.toUri().toURL()));
|
||||
PluginInfo info1 = new PluginInfo("myplugin", "desc", "1.0", "MyPlugin", Collections.singletonList("dep"), false, false);
|
||||
PluginInfo info1 = new PluginInfo("myplugin", "desc", "1.0", Version.CURRENT, "1.8",
|
||||
"MyPlugin", Collections.singletonList("dep"), false, false);
|
||||
PluginsService.Bundle bundle = new PluginsService.Bundle(info1, pluginDir);
|
||||
IllegalStateException e = expectThrows(IllegalStateException.class, () ->
|
||||
PluginsService.checkBundleJarHell(bundle, transitiveDeps));
|
||||
|
@ -500,7 +520,8 @@ public class PluginsServiceTests extends ESTestCase {
|
|||
Map<String, Set<URL>> transitiveDeps = new HashMap<>();
|
||||
transitiveDeps.put("dep1", Collections.singleton(dep1Jar.toUri().toURL()));
|
||||
transitiveDeps.put("dep2", Collections.singleton(dep2Jar.toUri().toURL()));
|
||||
PluginInfo info1 = new PluginInfo("myplugin", "desc", "1.0", "MyPlugin", Arrays.asList("dep1", "dep2"), false, false);
|
||||
PluginInfo info1 = new PluginInfo("myplugin", "desc", "1.0", Version.CURRENT, "1.8",
|
||||
"MyPlugin", Arrays.asList("dep1", "dep2"), false, false);
|
||||
PluginsService.Bundle bundle = new PluginsService.Bundle(info1, pluginDir);
|
||||
IllegalStateException e = expectThrows(IllegalStateException.class, () ->
|
||||
PluginsService.checkBundleJarHell(bundle, transitiveDeps));
|
||||
|
@ -522,7 +543,8 @@ public class PluginsServiceTests extends ESTestCase {
|
|||
Map<String, Set<URL>> transitiveDeps = new HashMap<>();
|
||||
transitiveDeps.put("dep1", Collections.singleton(dep1Jar.toUri().toURL()));
|
||||
transitiveDeps.put("dep2", Collections.singleton(dep2Jar.toUri().toURL()));
|
||||
PluginInfo info1 = new PluginInfo("myplugin", "desc", "1.0", "MyPlugin", Arrays.asList("dep1", "dep2"), false, false);
|
||||
PluginInfo info1 = new PluginInfo("myplugin", "desc", "1.0", Version.CURRENT, "1.8",
|
||||
"MyPlugin", Arrays.asList("dep1", "dep2"), false, false);
|
||||
PluginsService.Bundle bundle = new PluginsService.Bundle(info1, pluginDir);
|
||||
PluginsService.checkBundleJarHell(bundle, transitiveDeps);
|
||||
Set<URL> deps = transitiveDeps.get("myplugin");
|
||||
|
|
Loading…
Reference in New Issue