Search in sources :

Example 56 with Environment

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

the class UnsafeBootstrapAndDetachCommandIT method testBootstrapNoNodeMetadata.

public void testBootstrapNoNodeMetadata() throws IOException {
    Settings envSettings = buildEnvSettings(Settings.EMPTY);
    Environment environment = TestEnvironment.newEnvironment(envSettings);
    try (NodeEnvironment nodeEnvironment = new NodeEnvironment(envSettings, environment)) {
        NodeMetadata.FORMAT.cleanupOldFiles(-1, nodeEnvironment.nodeDataPaths());
    }
    expectThrows(() -> unsafeBootstrap(environment), ElasticsearchNodeCommand.NO_NODE_METADATA_FOUND_MSG);
}
Also used : NodeEnvironment(org.elasticsearch.env.NodeEnvironment) Environment(org.elasticsearch.env.Environment) NodeEnvironment(org.elasticsearch.env.NodeEnvironment) TestEnvironment(org.elasticsearch.env.TestEnvironment) Settings(org.elasticsearch.common.settings.Settings)

Example 57 with Environment

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

the class UnsafeBootstrapAndDetachCommandIT method testBootstrapNoClusterState.

public void testBootstrapNoClusterState() throws IOException {
    internalCluster().setBootstrapMasterNodeIndex(0);
    String node = internalCluster().startNode();
    Settings dataPathSettings = internalCluster().dataPathSettings(node);
    ensureStableCluster(1);
    NodeEnvironment nodeEnvironment = internalCluster().getMasterNodeInstance(NodeEnvironment.class);
    internalCluster().stopRandomDataNode();
    Environment environment = TestEnvironment.newEnvironment(Settings.builder().put(internalCluster().getDefaultSettings()).put(dataPathSettings).build());
    PersistedClusterStateService.deleteAll(nodeEnvironment.nodeDataPaths());
    expectThrows(() -> unsafeBootstrap(environment), ElasticsearchNodeCommand.NO_NODE_METADATA_FOUND_MSG);
}
Also used : NodeEnvironment(org.elasticsearch.env.NodeEnvironment) Environment(org.elasticsearch.env.Environment) NodeEnvironment(org.elasticsearch.env.NodeEnvironment) TestEnvironment(org.elasticsearch.env.TestEnvironment) Matchers.containsString(org.hamcrest.Matchers.containsString) Settings(org.elasticsearch.common.settings.Settings)

Example 58 with Environment

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

the class UnsafeBootstrapAndDetachCommandIT method testBootstrapNodeLocked.

public void testBootstrapNodeLocked() throws IOException {
    Settings envSettings = buildEnvSettings(Settings.EMPTY);
    Environment environment = TestEnvironment.newEnvironment(envSettings);
    try (NodeEnvironment ignored = new NodeEnvironment(envSettings, environment)) {
        expectThrows(() -> unsafeBootstrap(environment), ElasticsearchNodeCommand.FAILED_TO_OBTAIN_NODE_LOCK_MSG);
    }
}
Also used : NodeEnvironment(org.elasticsearch.env.NodeEnvironment) Environment(org.elasticsearch.env.Environment) NodeEnvironment(org.elasticsearch.env.NodeEnvironment) TestEnvironment(org.elasticsearch.env.TestEnvironment) Settings(org.elasticsearch.common.settings.Settings)

Example 59 with Environment

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

the class RemoveSettingsCommandIT method executeCommand.

private MockTerminal executeCommand(ElasticsearchNodeCommand command, Environment environment, boolean abort, String... args) throws Exception {
    final MockTerminal terminal = new MockTerminal();
    final OptionSet options = command.getParser().parse(args);
    final String input;
    if (abort) {
        input = randomValueOtherThanMany(c -> c.equalsIgnoreCase("y"), () -> randomAlphaOfLength(1));
    } else {
        input = randomBoolean() ? "y" : "Y";
    }
    terminal.addTextInput(input);
    try {
        command.execute(terminal, options, environment);
    } finally {
        assertThat(terminal.getOutput(), containsString(ElasticsearchNodeCommand.STOP_WARNING_MSG));
    }
    return terminal;
}
Also used : ElasticsearchException(org.elasticsearch.ElasticsearchException) Settings(org.elasticsearch.common.settings.Settings) TestEnvironment(org.elasticsearch.env.TestEnvironment) ESIntegTestCase(org.elasticsearch.test.ESIntegTestCase) Matchers.contains(org.hamcrest.Matchers.contains) DiskThresholdSettings(org.elasticsearch.cluster.routing.allocation.DiskThresholdSettings) Environment(org.elasticsearch.env.Environment) Matchers.not(org.hamcrest.Matchers.not) Matchers.containsString(org.hamcrest.Matchers.containsString) MockTerminal(org.elasticsearch.cli.MockTerminal) OptionSet(joptsimple.OptionSet) UserException(org.elasticsearch.cli.UserException) Matchers.containsString(org.hamcrest.Matchers.containsString) OptionSet(joptsimple.OptionSet) MockTerminal(org.elasticsearch.cli.MockTerminal)

Example 60 with Environment

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

the class RemoveSettingsCommandIT method testRemoveSettingsSuccessful.

public void testRemoveSettingsSuccessful() throws Exception {
    internalCluster().setBootstrapMasterNodeIndex(0);
    String node = internalCluster().startNode();
    client().admin().cluster().prepareUpdateSettings().setPersistentSettings(Settings.builder().put(DiskThresholdSettings.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING.getKey(), false).build()).get();
    assertThat(client().admin().cluster().prepareState().get().getState().metadata().persistentSettings().keySet(), contains(DiskThresholdSettings.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING.getKey()));
    Settings dataPathSettings = internalCluster().dataPathSettings(node);
    ensureStableCluster(1);
    internalCluster().stopRandomDataNode();
    Environment environment = TestEnvironment.newEnvironment(Settings.builder().put(internalCluster().getDefaultSettings()).put(dataPathSettings).build());
    MockTerminal terminal = removeSettings(environment, false, randomBoolean() ? new String[] { DiskThresholdSettings.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING.getKey() } : new String[] { "cluster.routing.allocation.disk.*" });
    assertThat(terminal.getOutput(), containsString(RemoveSettingsCommand.SETTINGS_REMOVED_MSG));
    assertThat(terminal.getOutput(), containsString("The following settings will be removed:"));
    assertThat(terminal.getOutput(), containsString(DiskThresholdSettings.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING.getKey() + ": " + false));
    internalCluster().startNode(dataPathSettings);
    assertThat(client().admin().cluster().prepareState().get().getState().metadata().persistentSettings().keySet(), not(contains(DiskThresholdSettings.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING.getKey())));
}
Also used : TestEnvironment(org.elasticsearch.env.TestEnvironment) Environment(org.elasticsearch.env.Environment) Matchers.containsString(org.hamcrest.Matchers.containsString) MockTerminal(org.elasticsearch.cli.MockTerminal) Settings(org.elasticsearch.common.settings.Settings) DiskThresholdSettings(org.elasticsearch.cluster.routing.allocation.DiskThresholdSettings)

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