Search in sources :

Example 86 with Environment

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

the class HunspellServiceTests method testLocaleDirectoryWithLocaleSpecificConfig.

public void testLocaleDirectoryWithLocaleSpecificConfig() throws Exception {
    Settings settings = Settings.builder().put(Environment.PATH_CONF_SETTING.getKey(), getDataPath("/indices/analyze/conf_dir")).put(HUNSPELL_LAZY_LOAD.getKey(), randomBoolean()).put(HUNSPELL_IGNORE_CASE.getKey(), true).put("indices.analysis.hunspell.dictionary.en_US.strict_affix_parsing", false).put("indices.analysis.hunspell.dictionary.en_US.ignore_case", false).put(Environment.PATH_HOME_SETTING.getKey(), createTempDir()).build();
    Dictionary dictionary = new HunspellService(settings, new Environment(settings), emptyMap()).getDictionary("en_US");
    assertThat(dictionary, notNullValue());
    assertFalse(dictionary.getIgnoreCase());
    // testing that dictionary specific settings override node level settings
    dictionary = new HunspellService(settings, new Environment(settings), emptyMap()).getDictionary("en_US_custom");
    assertThat(dictionary, notNullValue());
    assertTrue(dictionary.getIgnoreCase());
}
Also used : Dictionary(org.apache.lucene.analysis.hunspell.Dictionary) HunspellService(org.elasticsearch.indices.analysis.HunspellService) Environment(org.elasticsearch.env.Environment) Settings(org.elasticsearch.common.settings.Settings)

Example 87 with Environment

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

the class HunspellServiceTests method testDicWithNoAff.

public void testDicWithNoAff() throws Exception {
    Settings settings = Settings.builder().put(Environment.PATH_CONF_SETTING.getKey(), getDataPath("/indices/analyze/no_aff_conf_dir")).put(HUNSPELL_LAZY_LOAD.getKey(), randomBoolean()).put(Environment.PATH_HOME_SETTING.getKey(), createTempDir()).build();
    IllegalStateException e = expectThrows(IllegalStateException.class, () -> new HunspellService(settings, new Environment(settings), emptyMap()).getDictionary("en_US"));
    assertEquals("failed to load hunspell dictionary for locale: en_US", e.getMessage());
    assertThat(e.getCause(), hasToString(containsString("Missing affix file")));
}
Also used : HunspellService(org.elasticsearch.indices.analysis.HunspellService) Environment(org.elasticsearch.env.Environment) Settings(org.elasticsearch.common.settings.Settings)

Example 88 with Environment

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

the class AbstractScriptTestCase method init.

@Before
public void init() throws Exception {
    Settings settings = Settings.builder().put("path.home", createTempDir()).put(ScriptService.SCRIPT_AUTO_RELOAD_ENABLED_SETTING.getKey(), false).build();
    ScriptEngineRegistry scriptEngineRegistry = new ScriptEngineRegistry(Arrays.asList(new MustacheScriptEngineService()));
    ScriptContextRegistry scriptContextRegistry = new ScriptContextRegistry(Collections.emptyList());
    ScriptSettings scriptSettings = new ScriptSettings(scriptEngineRegistry, scriptContextRegistry);
    ScriptService scriptService = new ScriptService(settings, new Environment(settings), null, scriptEngineRegistry, scriptContextRegistry, scriptSettings);
    templateService = new InternalTemplateService(scriptService);
}
Also used : ScriptService(org.elasticsearch.script.ScriptService) ScriptSettings(org.elasticsearch.script.ScriptSettings) ScriptEngineRegistry(org.elasticsearch.script.ScriptEngineRegistry) Environment(org.elasticsearch.env.Environment) Settings(org.elasticsearch.common.settings.Settings) ScriptSettings(org.elasticsearch.script.ScriptSettings) MustacheScriptEngineService(org.elasticsearch.script.mustache.MustacheScriptEngineService) ScriptContextRegistry(org.elasticsearch.script.ScriptContextRegistry) Before(org.junit.Before)

Example 89 with Environment

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

the class RemovePluginCommandTests method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    home = createTempDir();
    Files.createDirectories(home.resolve("bin"));
    Files.createFile(home.resolve("bin").resolve("elasticsearch"));
    Files.createDirectories(home.resolve("plugins"));
    Settings settings = Settings.builder().put("path.home", home).build();
    env = new Environment(settings);
}
Also used : Environment(org.elasticsearch.env.Environment) Settings(org.elasticsearch.common.settings.Settings) Before(org.junit.Before)

Example 90 with Environment

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

the class RemovePluginCommandTests method removePlugin.

static MockTerminal removePlugin(String name, Path home) throws Exception {
    Environment env = new Environment(Settings.builder().put("path.home", home).build());
    MockTerminal terminal = new MockTerminal();
    new RemovePluginCommand().execute(terminal, name, env);
    return terminal;
}
Also used : Environment(org.elasticsearch.env.Environment) MockTerminal(org.elasticsearch.cli.MockTerminal)

Aggregations

Environment (org.elasticsearch.env.Environment)130 Settings (org.elasticsearch.common.settings.Settings)84 Path (java.nio.file.Path)66 Matchers.containsString (org.hamcrest.Matchers.containsString)42 NodeEnvironment (org.elasticsearch.env.NodeEnvironment)26 TestEnvironment (org.elasticsearch.env.TestEnvironment)22 IndexSettings (org.elasticsearch.index.IndexSettings)21 UserException (org.elasticsearch.cli.UserException)17 IOException (java.io.IOException)15 AnalysisModule (org.elasticsearch.indices.analysis.AnalysisModule)9 MockTerminal (org.elasticsearch.cli.MockTerminal)8 ClusterState (org.elasticsearch.cluster.ClusterState)8 ScriptService (org.elasticsearch.script.ScriptService)8 HashMap (java.util.HashMap)7 ScriptContextRegistry (org.elasticsearch.script.ScriptContextRegistry)7 ScriptEngineRegistry (org.elasticsearch.script.ScriptEngineRegistry)7 ScriptSettings (org.elasticsearch.script.ScriptSettings)7 ArrayList (java.util.ArrayList)6 ElasticsearchException (org.elasticsearch.ElasticsearchException)6 Before (org.junit.Before)6