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:
GUILLAUME GROSSETIE 2016-06-01 17:14:13 +02:00
parent f32f35bec4
commit 9411f18f27
2 changed files with 28 additions and 28 deletions

View File

@ -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());
} }
} }

View File

@ -74,11 +74,11 @@ public class ListPluginsCommandTests extends ESTestCase {
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,43 +97,43 @@ 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{