|
@@ -20,6 +20,7 @@
|
|
|
package org.elasticsearch.plugins;
|
|
|
|
|
|
import org.apache.lucene.util.LuceneTestCase;
|
|
|
+import org.elasticsearch.cli.ExitCodes;
|
|
|
import org.elasticsearch.cli.MockTerminal;
|
|
|
import org.elasticsearch.cli.UserException;
|
|
|
import org.elasticsearch.common.settings.Settings;
|
|
@@ -27,7 +28,9 @@ import org.elasticsearch.env.Environment;
|
|
|
import org.elasticsearch.test.ESTestCase;
|
|
|
import org.junit.Before;
|
|
|
|
|
|
+import java.io.BufferedReader;
|
|
|
import java.io.IOException;
|
|
|
+import java.io.StringReader;
|
|
|
import java.nio.file.DirectoryStream;
|
|
|
import java.nio.file.Files;
|
|
|
import java.nio.file.Path;
|
|
@@ -43,6 +46,7 @@ public class RemovePluginCommandTests extends ESTestCase {
|
|
|
private Path home;
|
|
|
private Environment env;
|
|
|
|
|
|
+ @Override
|
|
|
@Before
|
|
|
public void setUp() throws Exception {
|
|
|
super.setUp();
|
|
@@ -130,8 +134,24 @@ public class RemovePluginCommandTests extends ESTestCase {
|
|
|
assertThat(terminal.getOutput(), not(containsString(expectedConfigDirPreservedMessage(configDir))));
|
|
|
}
|
|
|
|
|
|
+ public void testRemoveUninstalledPluginErrors() throws Exception {
|
|
|
+ UserException e = expectThrows(UserException.class, () -> removePlugin("fake", home));
|
|
|
+ assertEquals(ExitCodes.CONFIG, e.exitCode);
|
|
|
+ assertEquals("plugin fake not found; run 'elasticsearch-plugin list' to get list of installed plugins", e.getMessage());
|
|
|
+
|
|
|
+ MockTerminal terminal = new MockTerminal();
|
|
|
+ new RemovePluginCommand().main(new String[] { "-Epath.home=" + home, "fake" }, terminal);
|
|
|
+ try (BufferedReader reader = new BufferedReader(new StringReader(terminal.getOutput()))) {
|
|
|
+ assertEquals("-> Removing fake...", reader.readLine());
|
|
|
+ assertEquals("ERROR: plugin fake not found; run 'elasticsearch-plugin list' to get list of installed plugins",
|
|
|
+ reader.readLine());
|
|
|
+ assertNull(reader.readLine());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private String expectedConfigDirPreservedMessage(final Path configDir) {
|
|
|
return "-> Preserving plugin config files [" + configDir + "] in case of upgrade, delete manually if not needed";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|