use of org.opensearch.cli.MockTerminal in project OpenSearch by opensearch-project.
the class RemoveCustomsCommandIT method testRemoveCustomsSuccessful.
public void testRemoveCustomsSuccessful() throws Exception {
internalCluster().setBootstrapClusterManagerNodeIndex(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());
}
use of org.opensearch.cli.MockTerminal in project OpenSearch by opensearch-project.
the class RemoveCustomsCommandIT method executeCommand.
private MockTerminal executeCommand(OpenSearchNodeCommand 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(OpenSearchNodeCommand.STOP_WARNING_MSG));
}
return terminal;
}
use of org.opensearch.cli.MockTerminal in project OpenSearch by opensearch-project.
the class RemoveCustomsCommandIT method removeCustoms.
private MockTerminal removeCustoms(Environment environment, boolean abort, String... args) throws Exception {
final MockTerminal terminal = executeCommand(new RemoveCustomsCommand(), environment, abort, args);
assertThat(terminal.getOutput(), containsString(RemoveCustomsCommand.CONFIRMATION_MSG));
assertThat(terminal.getOutput(), containsString(RemoveCustomsCommand.CUSTOMS_REMOVED_MSG));
return terminal;
}
use of org.opensearch.cli.MockTerminal in project OpenSearch by opensearch-project.
the class RemoveSettingsCommandIT method executeCommand.
private MockTerminal executeCommand(OpenSearchNodeCommand 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(OpenSearchNodeCommand.STOP_WARNING_MSG));
}
return terminal;
}
use of org.opensearch.cli.MockTerminal in project OpenSearch by opensearch-project.
the class RemoveSettingsCommandIT method removeSettings.
private MockTerminal removeSettings(Environment environment, boolean abort, String... args) throws Exception {
final MockTerminal terminal = executeCommand(new RemoveSettingsCommand(), environment, abort, args);
assertThat(terminal.getOutput(), containsString(RemoveSettingsCommand.CONFIRMATION_MSG));
assertThat(terminal.getOutput(), containsString(RemoveSettingsCommand.SETTINGS_REMOVED_MSG));
return terminal;
}
Aggregations