CliTool: Various PluginManager fixes
The new plugin manager parser was not called correctly in the scripts. In addition the plugin manager now creates a plugins/ directory in case it does not exist. Also the integration tests called the plugin manager in the deprecated way.
This commit is contained in:
parent
2f54b89a23
commit
999d5ab801
|
@ -105,4 +105,4 @@ fi
|
|||
|
||||
export HOSTNAME=`hostname -s`
|
||||
|
||||
exec "$JAVA" $JAVA_OPTS $ES_JAVA_OPTS -Xmx64m -Xms16m -Delasticsearch -Des.path.home="$ES_HOME" $properties -cp "$ES_HOME/lib/*" org.elasticsearch.plugins.PluginManager $args
|
||||
exec "$JAVA" $JAVA_OPTS $ES_JAVA_OPTS -Xmx64m -Xms16m -Delasticsearch -Des.path.home="$ES_HOME" $properties -cp "$ES_HOME/lib/*" org.elasticsearch.plugins.PluginManagerCliParser $args
|
||||
|
|
|
@ -11,7 +11,7 @@ TITLE Elasticsearch Plugin Manager ${project.version}
|
|||
|
||||
SET HOSTNAME=%COMPUTERNAME%
|
||||
|
||||
"%JAVA_HOME%\bin\java" %JAVA_OPTS% %ES_JAVA_OPTS% -Xmx64m -Xms16m -Des.path.home="%ES_HOME%" -cp "%ES_HOME%/lib/*;" "org.elasticsearch.plugins.PluginManager" %*
|
||||
"%JAVA_HOME%\bin\java" %JAVA_OPTS% %ES_JAVA_OPTS% -Xmx64m -Xms16m -Des.path.home="%ES_HOME%" -cp "%ES_HOME%/lib/*;" "org.elasticsearch.plugins.PluginManagerCliParser" %*
|
||||
goto finally
|
||||
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@ import org.elasticsearch.ElasticsearchTimeoutException;
|
|||
import org.elasticsearch.ExceptionsHelper;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.bootstrap.JarHell;
|
||||
import org.elasticsearch.common.SuppressForbidden;
|
||||
import org.elasticsearch.common.cli.Terminal;
|
||||
import org.elasticsearch.common.http.client.HttpDownloadHelper;
|
||||
import org.elasticsearch.common.io.FileSystemUtils;
|
||||
|
@ -36,7 +35,6 @@ import org.elasticsearch.env.Environment;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
|
@ -109,6 +107,11 @@ public class PluginManager {
|
|||
progress = new HttpDownloadHelper.VerboseProgress(terminal.writer());
|
||||
}
|
||||
|
||||
if (!Files.exists(environment.pluginsFile())) {
|
||||
terminal.println("Plugins directory [%s] does not exist. Creating...", environment.pluginsFile());
|
||||
Files.createDirectory(environment.pluginsFile());
|
||||
}
|
||||
|
||||
if (!Files.isWritable(environment.pluginsFile())) {
|
||||
throw new IOException("plugin directory " + environment.pluginsFile() + " is read only");
|
||||
}
|
||||
|
@ -406,6 +409,10 @@ public class PluginManager {
|
|||
}
|
||||
|
||||
public Path[] getListInstalledPlugins() throws IOException {
|
||||
if (!Files.exists(environment.pluginsFile())) {
|
||||
return new Path[0];
|
||||
}
|
||||
|
||||
try (DirectoryStream<Path> stream = Files.newDirectoryStream(environment.pluginsFile())) {
|
||||
return Iterators.toArray(stream.iterator(), Path.class);
|
||||
}
|
||||
|
|
|
@ -74,12 +74,6 @@ public class PluginManagerTests extends ElasticsearchIntegrationTest {
|
|||
public void setup() throws Exception {
|
||||
initialSettings = buildInitialSettings();
|
||||
System.setProperty("es.default.path.home", initialSettings.v1().get("path.home"));
|
||||
try {
|
||||
Files.createDirectories(initialSettings.v2().pluginsFile());
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
Path binDir = initialSettings.v2().homeFile().resolve("bin");
|
||||
if (!Files.exists(binDir)) {
|
||||
Files.createDirectories(binDir);
|
||||
|
@ -323,6 +317,13 @@ public class PluginManagerTests extends ElasticsearchIntegrationTest {
|
|||
assertThat(terminal.getTerminalOutput(), hasItem(containsString("No plugin detected")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListInstalledEmptyWithExistingPluginDirectory() throws IOException {
|
||||
Files.createDirectory(initialSettings.v2().pluginsFile());
|
||||
assertStatusOk("list");
|
||||
assertThat(terminal.getTerminalOutput(), hasItem(containsString("No plugin detected")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInstallPlugin() throws IOException {
|
||||
String pluginName = "plugin-classfile";
|
||||
|
|
|
@ -86,7 +86,7 @@
|
|||
|
||||
<!-- install plugin -->
|
||||
<echo>Installing plugin @{name}...</echo>
|
||||
<run-script dir="@{home}" script="bin/plugin" args="-u ${url} -i @{name}"/>
|
||||
<run-script dir="@{home}" script="bin/plugin" args="install @{name} -u ${url}"/>
|
||||
|
||||
<!-- check that plugin was installed into correct place -->
|
||||
<local name="longname"/>
|
||||
|
|
Loading…
Reference in New Issue