use of org.opensearch.env.Environment in project OpenSearch by opensearch-project.
the class SpawnerNoBootstrapTests method testNoControllerSpawn.
/**
* Simplest case: a module with no controller daemon.
*/
public void testNoControllerSpawn() throws IOException {
Path esHome = createTempDir().resolve("esHome");
Settings.Builder settingsBuilder = Settings.builder();
settingsBuilder.put(Environment.PATH_HOME_SETTING.getKey(), esHome.toString());
Settings settings = settingsBuilder.build();
Environment environment = TestEnvironment.newEnvironment(settings);
// This plugin will NOT have a controller daemon
Path plugin = environment.modulesFile().resolve("a_plugin");
Files.createDirectories(environment.modulesFile());
Files.createDirectories(plugin);
PluginTestUtil.writePluginProperties(plugin, "description", "a_plugin", "version", Version.CURRENT.toString(), "opensearch.version", Version.CURRENT.toString(), "name", "a_plugin", "java.version", "1.8", "classname", "APlugin", "has.native.controller", "false");
try (Spawner spawner = new Spawner()) {
spawner.spawnNativeControllers(environment, false);
assertThat(spawner.getProcesses(), hasSize(0));
}
}
use of org.opensearch.env.Environment in project OpenSearch by opensearch-project.
the class UnsafeBootstrapAndDetachCommandIT method testDetachNodeLocked.
public void testDetachNodeLocked() throws IOException {
Settings envSettings = buildEnvSettings(Settings.EMPTY);
Environment environment = TestEnvironment.newEnvironment(envSettings);
try (NodeEnvironment ignored = new NodeEnvironment(envSettings, environment)) {
expectThrows(() -> detachCluster(environment), OpenSearchNodeCommand.FAILED_TO_OBTAIN_NODE_LOCK_MSG);
}
}
use of org.opensearch.env.Environment in project OpenSearch by opensearch-project.
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), OpenSearchNodeCommand.NO_NODE_METADATA_FOUND_MSG);
}
use of org.opensearch.env.Environment in project OpenSearch by opensearch-project.
the class RemoveCustomsCommandIT method testCustomDoesNotMatch.
public void testCustomDoesNotMatch() throws Exception {
internalCluster().setBootstrapMasterNodeIndex(0);
String node = internalCluster().startNode();
createIndex("test");
client().admin().indices().prepareDelete("test").get();
assertEquals(1, client().admin().cluster().prepareState().get().getState().metadata().indexGraveyard().getTombstones().size());
Settings dataPathSettings = internalCluster().dataPathSettings(node);
ensureStableCluster(1);
internalCluster().stopRandomDataNode();
Environment environment = TestEnvironment.newEnvironment(Settings.builder().put(internalCluster().getDefaultSettings()).put(dataPathSettings).build());
UserException ex = expectThrows(UserException.class, () -> removeCustoms(environment, false, new String[] { "index-greveyard-with-typos" }));
assertThat(ex.getMessage(), containsString("No custom metadata matching [index-greveyard-with-typos] were " + "found on this node"));
}
use of org.opensearch.env.Environment in project OpenSearch by opensearch-project.
the class RemoveCustomsCommandIT method testRemoveCustomsSuccessful.
public void testRemoveCustomsSuccessful() throws Exception {
internalCluster().setBootstrapMasterNodeIndex(0);
String node = internalCluster().startNode();
createIndex("test");
client().admin().indices().prepareDelete("test").get();
assertEquals(1, client().admin().cluster().prepareState().get().getState().metadata().indexGraveyard().getTombstones().size());
Settings dataPathSettings = internalCluster().dataPathSettings(node);
ensureStableCluster(1);
internalCluster().stopRandomDataNode();
Environment environment = TestEnvironment.newEnvironment(Settings.builder().put(internalCluster().getDefaultSettings()).put(dataPathSettings).build());
MockTerminal terminal = removeCustoms(environment, false, randomBoolean() ? new String[] { "index-graveyard" } : new String[] { "index-*" });
assertThat(terminal.getOutput(), containsString(RemoveCustomsCommand.CUSTOMS_REMOVED_MSG));
assertThat(terminal.getOutput(), containsString("The following customs will be removed:"));
assertThat(terminal.getOutput(), containsString("index-graveyard"));
internalCluster().startNode(dataPathSettings);
assertEquals(0, client().admin().cluster().prepareState().get().getState().metadata().indexGraveyard().getTombstones().size());
}
Aggregations