Display plugins versions
This is useful to determine if a plugin needs to be updated when using deployment automation solution (like Ansible).
This commit is contained in:
parent
f32f35bec4
commit
9411f18f27
|
@ -60,8 +60,8 @@ class ListPluginsCommand extends SettingCommand {
|
||||||
}
|
}
|
||||||
Collections.sort(plugins);
|
Collections.sort(plugins);
|
||||||
for (final Path plugin : plugins) {
|
for (final Path plugin : plugins) {
|
||||||
terminal.println(plugin.getFileName().toString());
|
|
||||||
PluginInfo info = PluginInfo.readFromProperties(env.pluginsFile().resolve(plugin.toAbsolutePath()));
|
PluginInfo info = PluginInfo.readFromProperties(env.pluginsFile().resolve(plugin.toAbsolutePath()));
|
||||||
|
terminal.println(plugin.getFileName().toString() + "@" + info.getVersion());
|
||||||
terminal.println(Terminal.Verbosity.VERBOSE, info.toString());
|
terminal.println(Terminal.Verbosity.VERBOSE, info.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ public class ListPluginsCommandTests extends ESTestCase {
|
||||||
static MockTerminal listPlugins(Path home) throws Exception {
|
static MockTerminal listPlugins(Path home) throws Exception {
|
||||||
return listPlugins(home, new String[0]);
|
return listPlugins(home, new String[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static MockTerminal listPlugins(Path home, String[] args) throws Exception {
|
static MockTerminal listPlugins(Path home, String[] args) throws Exception {
|
||||||
String[] argsAndHome = new String[args.length + 1];
|
String[] argsAndHome = new String[args.length + 1];
|
||||||
System.arraycopy(args, 0, argsAndHome, 0, args.length);
|
System.arraycopy(args, 0, argsAndHome, 0, args.length);
|
||||||
|
@ -69,16 +69,16 @@ public class ListPluginsCommandTests extends ESTestCase {
|
||||||
assertEquals(ExitCodes.OK, status);
|
assertEquals(ExitCodes.OK, status);
|
||||||
return terminal;
|
return terminal;
|
||||||
}
|
}
|
||||||
|
|
||||||
static String buildMultiline(String... args){
|
static String buildMultiline(String... args){
|
||||||
return Arrays.asList(args).stream().collect(Collectors.joining("\n", "", "\n"));
|
return Arrays.asList(args).stream().collect(Collectors.joining("\n", "", "\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void buildFakePlugin(Environment env, String description, String name, String classname) throws IOException {
|
static void buildFakePlugin(Environment env, String description, String name, String classname, String version) throws IOException {
|
||||||
PluginTestUtil.writeProperties(env.pluginsFile().resolve(name),
|
PluginTestUtil.writeProperties(env.pluginsFile().resolve(name),
|
||||||
"description", description,
|
"description", description,
|
||||||
"name", name,
|
"name", name,
|
||||||
"version", "1.0",
|
"version", version,
|
||||||
"elasticsearch.version", Version.CURRENT.toString(),
|
"elasticsearch.version", Version.CURRENT.toString(),
|
||||||
"java.version", System.getProperty("java.specification.version"),
|
"java.version", System.getProperty("java.specification.version"),
|
||||||
"classname", classname);
|
"classname", classname);
|
||||||
|
@ -97,51 +97,51 @@ public class ListPluginsCommandTests extends ESTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testOnePlugin() throws Exception {
|
public void testOnePlugin() throws Exception {
|
||||||
buildFakePlugin(env, "fake desc", "fake", "org.fake");
|
buildFakePlugin(env, "fake desc", "fake", "org.fake", "1.0.0");
|
||||||
MockTerminal terminal = listPlugins(home);
|
MockTerminal terminal = listPlugins(home);
|
||||||
assertEquals(terminal.getOutput(), buildMultiline("fake"));
|
assertEquals(terminal.getOutput(), buildMultiline("fake@1.0.0"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testTwoPlugins() throws Exception {
|
public void testTwoPlugins() throws Exception {
|
||||||
buildFakePlugin(env, "fake desc", "fake1", "org.fake");
|
buildFakePlugin(env, "fake desc", "fake1", "org.fake", "1.2.3");
|
||||||
buildFakePlugin(env, "fake desc 2", "fake2", "org.fake");
|
buildFakePlugin(env, "fake desc 2", "fake2", "org.fake", "6.5.4");
|
||||||
MockTerminal terminal = listPlugins(home);
|
MockTerminal terminal = listPlugins(home);
|
||||||
assertEquals(terminal.getOutput(), buildMultiline("fake1", "fake2"));
|
assertEquals(terminal.getOutput(), buildMultiline("fake1@1.2.3", "fake2@6.5.4"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPluginWithVerbose() throws Exception {
|
public void testPluginWithVerbose() throws Exception {
|
||||||
buildFakePlugin(env, "fake desc", "fake_plugin", "org.fake");
|
buildFakePlugin(env, "fake desc", "fake_plugin", "org.fake", "1.0.0");
|
||||||
String[] params = { "-v" };
|
String[] params = { "-v" };
|
||||||
MockTerminal terminal = listPlugins(home, params);
|
MockTerminal terminal = listPlugins(home, params);
|
||||||
assertEquals(terminal.getOutput(), buildMultiline("Plugins directory: " + env.pluginsFile(), "fake_plugin",
|
assertEquals(terminal.getOutput(), buildMultiline("Plugins directory: " + env.pluginsFile(), "fake_plugin@1.0.0",
|
||||||
"- Plugin information:", "Name: fake_plugin", "Description: fake desc", "Version: 1.0", " * Classname: org.fake"));
|
"- Plugin information:", "Name: fake_plugin", "Description: fake desc", "Version: 1.0.0", " * Classname: org.fake"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPluginWithVerboseMultiplePlugins() throws Exception {
|
public void testPluginWithVerboseMultiplePlugins() throws Exception {
|
||||||
buildFakePlugin(env, "fake desc 1", "fake_plugin1", "org.fake");
|
buildFakePlugin(env, "fake desc 1", "fake_plugin1", "org.fake", "1.2.3");
|
||||||
buildFakePlugin(env, "fake desc 2", "fake_plugin2", "org.fake2");
|
buildFakePlugin(env, "fake desc 2", "fake_plugin2", "org.fake2", "6.5.4");
|
||||||
String[] params = { "-v" };
|
String[] params = { "-v" };
|
||||||
MockTerminal terminal = listPlugins(home, params);
|
MockTerminal terminal = listPlugins(home, params);
|
||||||
assertEquals(terminal.getOutput(), buildMultiline("Plugins directory: " + env.pluginsFile(),
|
assertEquals(terminal.getOutput(), buildMultiline("Plugins directory: " + env.pluginsFile(),
|
||||||
"fake_plugin1", "- Plugin information:", "Name: fake_plugin1", "Description: fake desc 1", "Version: 1.0",
|
"fake_plugin1@1.2.3", "- Plugin information:", "Name: fake_plugin1", "Description: fake desc 1", "Version: 1.2.3",
|
||||||
" * Classname: org.fake", "fake_plugin2", "- Plugin information:", "Name: fake_plugin2",
|
" * Classname: org.fake", "fake_plugin2@6.5.4", "- Plugin information:", "Name: fake_plugin2",
|
||||||
"Description: fake desc 2", "Version: 1.0", " * Classname: org.fake2"));
|
"Description: fake desc 2", "Version: 6.5.4", " * Classname: org.fake2"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPluginWithoutVerboseMultiplePlugins() throws Exception {
|
public void testPluginWithoutVerboseMultiplePlugins() throws Exception {
|
||||||
buildFakePlugin(env, "fake desc 1", "fake_plugin1", "org.fake");
|
buildFakePlugin(env, "fake desc 1", "fake_plugin1", "org.fake", "1.0.0");
|
||||||
buildFakePlugin(env, "fake desc 2", "fake_plugin2", "org.fake2");
|
buildFakePlugin(env, "fake desc 2", "fake_plugin2", "org.fake2", "1.0.0");
|
||||||
MockTerminal terminal = listPlugins(home, new String[0]);
|
MockTerminal terminal = listPlugins(home, new String[0]);
|
||||||
String output = terminal.getOutput();
|
String output = terminal.getOutput();
|
||||||
assertEquals(output, buildMultiline("fake_plugin1", "fake_plugin2"));
|
assertEquals(output, buildMultiline("fake_plugin1@1.0.0", "fake_plugin2@1.0.0"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPluginWithoutDescriptorFile() throws Exception{
|
public void testPluginWithoutDescriptorFile() throws Exception{
|
||||||
Files.createDirectories(env.pluginsFile().resolve("fake1"));
|
Files.createDirectories(env.pluginsFile().resolve("fake1"));
|
||||||
NoSuchFileException e = expectThrows(NoSuchFileException.class, () -> listPlugins(home));
|
NoSuchFileException e = expectThrows(NoSuchFileException.class, () -> listPlugins(home));
|
||||||
assertEquals(e.getFile(), env.pluginsFile().resolve("fake1").resolve(PluginInfo.ES_PLUGIN_PROPERTIES).toString());
|
assertEquals(e.getFile(), env.pluginsFile().resolve("fake1").resolve(PluginInfo.ES_PLUGIN_PROPERTIES).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPluginWithWrongDescriptorFile() throws Exception{
|
public void testPluginWithWrongDescriptorFile() throws Exception{
|
||||||
PluginTestUtil.writeProperties(env.pluginsFile().resolve("fake1"),
|
PluginTestUtil.writeProperties(env.pluginsFile().resolve("fake1"),
|
||||||
"description", "fake desc");
|
"description", "fake desc");
|
||||||
|
@ -149,5 +149,5 @@ public class ListPluginsCommandTests extends ESTestCase {
|
||||||
assertEquals(e.getMessage(), "Property [name] is missing in [" +
|
assertEquals(e.getMessage(), "Property [name] is missing in [" +
|
||||||
env.pluginsFile().resolve("fake1").resolve(PluginInfo.ES_PLUGIN_PROPERTIES).toString() + "]");
|
env.pluginsFile().resolve("fake1").resolve(PluginInfo.ES_PLUGIN_PROPERTIES).toString() + "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue