Search in sources :

Example 26 with Environment

use of org.elasticsearch.env.Environment in project elasticsearch by elastic.

the class InstallPluginCommandTests method testMissingDirectory.

public void testMissingDirectory() throws Exception {
    Tuple<Path, Environment> env = createEnv(fs, temp);
    Path pluginDir = createPluginDir(temp);
    Files.createFile(pluginDir.resolve(PluginInfo.ES_PLUGIN_PROPERTIES));
    String pluginZip = writeZip(pluginDir, null);
    UserException e = expectThrows(UserException.class, () -> installPlugin(pluginZip, env.v1()));
    assertTrue(e.getMessage(), e.getMessage().contains("`elasticsearch` directory is missing in the plugin zip"));
    assertInstallCleaned(env.v2());
}
Also used : Path(java.nio.file.Path) Environment(org.elasticsearch.env.Environment) Matchers.containsString(org.hamcrest.Matchers.containsString) UserException(org.elasticsearch.cli.UserException)

Example 27 with Environment

use of org.elasticsearch.env.Environment in project elasticsearch by elastic.

the class InstallPluginCommandTests method testBinConflict.

public void testBinConflict() throws Exception {
    Tuple<Path, Environment> env = createEnv(fs, temp);
    Path pluginDir = createPluginDir(temp);
    Path binDir = pluginDir.resolve("bin");
    Files.createDirectory(binDir);
    Files.createFile(binDir.resolve("somescript"));
    String pluginZip = createPlugin("elasticsearch", pluginDir);
    FileAlreadyExistsException e = expectThrows(FileAlreadyExistsException.class, () -> installPlugin(pluginZip, env.v1()));
    assertTrue(e.getMessage(), e.getMessage().contains(env.v2().binFile().resolve("elasticsearch").toString()));
    assertInstallCleaned(env.v2());
}
Also used : Path(java.nio.file.Path) FileAlreadyExistsException(java.nio.file.FileAlreadyExistsException) Environment(org.elasticsearch.env.Environment) Matchers.containsString(org.hamcrest.Matchers.containsString)

Example 28 with Environment

use of org.elasticsearch.env.Environment in project elasticsearch by elastic.

the class InstallPluginCommandTests method testMissingPluginId.

public void testMissingPluginId() throws IOException {
    final Tuple<Path, Environment> env = createEnv(fs, temp);
    final UserException e = expectThrows(UserException.class, () -> installPlugin(null, env.v1()));
    assertTrue(e.getMessage(), e.getMessage().contains("plugin id is required"));
}
Also used : Path(java.nio.file.Path) Environment(org.elasticsearch.env.Environment) UserException(org.elasticsearch.cli.UserException)

Example 29 with Environment

use of org.elasticsearch.env.Environment in project elasticsearch by elastic.

the class InstallPluginCommandTests method testInstallMisspelledOfficialPlugins.

public void testInstallMisspelledOfficialPlugins() throws Exception {
    Tuple<Path, Environment> env = createEnv(fs, temp);
    UserException e = expectThrows(UserException.class, () -> installPlugin("xpack", env.v1()));
    assertThat(e.getMessage(), containsString("Unknown plugin xpack, did you mean [x-pack]?"));
    e = expectThrows(UserException.class, () -> installPlugin("analysis-smartnc", env.v1()));
    assertThat(e.getMessage(), containsString("Unknown plugin analysis-smartnc, did you mean [analysis-smartcn]?"));
    e = expectThrows(UserException.class, () -> installPlugin("repository", env.v1()));
    assertThat(e.getMessage(), containsString("Unknown plugin repository, did you mean any of [repository-s3, repository-gcs]?"));
    e = expectThrows(UserException.class, () -> installPlugin("unknown_plugin", env.v1()));
    assertThat(e.getMessage(), containsString("Unknown plugin unknown_plugin"));
}
Also used : Path(java.nio.file.Path) Environment(org.elasticsearch.env.Environment) UserException(org.elasticsearch.cli.UserException)

Example 30 with Environment

use of org.elasticsearch.env.Environment in project elasticsearch by elastic.

the class InstallPluginCommandTests method testPluginAlreadyInstalled.

public void testPluginAlreadyInstalled() throws Exception {
    Tuple<Path, Environment> env = createEnv(fs, temp);
    Path pluginDir = createPluginDir(temp);
    String pluginZip = createPlugin("fake", pluginDir);
    installPlugin(pluginZip, env.v1());
    final UserException e = expectThrows(UserException.class, () -> installPlugin(pluginZip, env.v1(), randomBoolean()));
    assertThat(e.getMessage(), equalTo("plugin directory [" + env.v2().pluginsFile().resolve("fake") + "] already exists; " + "if you need to update the plugin, uninstall it first using command 'remove fake'"));
}
Also used : Path(java.nio.file.Path) Environment(org.elasticsearch.env.Environment) Matchers.containsString(org.hamcrest.Matchers.containsString) UserException(org.elasticsearch.cli.UserException)

Aggregations

Environment (org.elasticsearch.env.Environment)103 Settings (org.elasticsearch.common.settings.Settings)63 Path (java.nio.file.Path)60 Matchers.containsString (org.hamcrest.Matchers.containsString)28 IndexSettings (org.elasticsearch.index.IndexSettings)20 UserException (org.elasticsearch.cli.UserException)14 IOException (java.io.IOException)11 NodeEnvironment (org.elasticsearch.env.NodeEnvironment)8 ScriptService (org.elasticsearch.script.ScriptService)8 AnalysisModule (org.elasticsearch.indices.analysis.AnalysisModule)7 ScriptContextRegistry (org.elasticsearch.script.ScriptContextRegistry)7 ScriptEngineRegistry (org.elasticsearch.script.ScriptEngineRegistry)7 ScriptSettings (org.elasticsearch.script.ScriptSettings)7 Collections (java.util.Collections)5 Before (org.junit.Before)5 FileAlreadyExistsException (java.nio.file.FileAlreadyExistsException)4 HashMap (java.util.HashMap)4 Map (java.util.Map)4 Logger (org.apache.logging.log4j.Logger)4 MockScriptEngine (org.elasticsearch.script.MockScriptEngine)4