Search in sources :

Example 6 with MockTerminal

use of org.opensearch.cli.MockTerminal in project OpenSearch by opensearch-project.

the class ListPluginsCommandTests method testPluginWithoutVerboseMultiplePlugins.

public void testPluginWithoutVerboseMultiplePlugins() throws Exception {
    buildFakePlugin(env, "fake desc 1", "fake_plugin1", "org.fake");
    buildFakePlugin(env, "fake desc 2", "fake_plugin2", "org.fake2");
    MockTerminal terminal = listPlugins(home, new String[0]);
    String output = terminal.getOutput();
    assertEquals(buildMultiline("fake_plugin1", "fake_plugin2"), output);
}
Also used : MockTerminal(org.opensearch.cli.MockTerminal)

Example 7 with MockTerminal

use of org.opensearch.cli.MockTerminal in project OpenSearch by opensearch-project.

the class ListPluginsCommandTests method testOnePlugin.

public void testOnePlugin() throws Exception {
    buildFakePlugin(env, "fake desc", "fake", "org.fake");
    MockTerminal terminal = listPlugins(home);
    assertEquals(buildMultiline("fake"), terminal.getOutput());
}
Also used : MockTerminal(org.opensearch.cli.MockTerminal)

Example 8 with MockTerminal

use of org.opensearch.cli.MockTerminal in project OpenSearch by opensearch-project.

the class ListPluginsCommandTests method testPluginWithVerbose.

public void testPluginWithVerbose() throws Exception {
    buildFakePlugin(env, "fake desc", "fake_plugin", "org.fake");
    String[] params = { "-v" };
    MockTerminal terminal = listPlugins(home, params);
    assertEquals(buildMultiline("Plugins directory: " + env.pluginsDir(), "fake_plugin", "- Plugin information:", "Name: fake_plugin", "Description: fake desc", "Version: 1.0", "OpenSearch Version: " + Version.CURRENT.toString(), "Java Version: 1.8", "Native Controller: false", "Extended Plugins: []", " * Classname: org.fake", "Folder name: custom-folder"), terminal.getOutput());
}
Also used : MockTerminal(org.opensearch.cli.MockTerminal)

Example 9 with MockTerminal

use of org.opensearch.cli.MockTerminal in project OpenSearch by opensearch-project.

the class RemovePluginCommandTests method testPurgeOnlyMarkerFileExists.

public void testPurgeOnlyMarkerFileExists() throws Exception {
    final Path configDir = env.configDir().resolve("fake");
    final Path removing = env.pluginsDir().resolve(".removing-fake");
    Files.createFile(removing);
    final MockTerminal terminal = removePlugin("fake", home, randomBoolean());
    assertFalse(Files.exists(removing));
    assertThat(terminal.getOutput(), not(containsString(expectedConfigDirPreservedMessage(configDir))));
}
Also used : Path(java.nio.file.Path) MockTerminal(org.opensearch.cli.MockTerminal)

Example 10 with MockTerminal

use of org.opensearch.cli.MockTerminal in project OpenSearch by opensearch-project.

the class RemovePluginCommandTests method removePlugin.

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

Aggregations

MockTerminal (org.opensearch.cli.MockTerminal)51 Environment (org.opensearch.env.Environment)17 Matchers.containsString (org.hamcrest.Matchers.containsString)16 Settings (org.opensearch.common.settings.Settings)16 TestEnvironment (org.opensearch.env.TestEnvironment)16 Path (java.nio.file.Path)15 OptionSet (joptsimple.OptionSet)13 OpenSearchException (org.opensearch.OpenSearchException)12 IOException (java.io.IOException)10 OptionParser (joptsimple.OptionParser)10 Version (org.opensearch.Version)10 ClusterState (org.opensearch.cluster.ClusterState)10 NodeEnvironment (org.opensearch.env.NodeEnvironment)10 IndexMetadata (org.opensearch.cluster.metadata.IndexMetadata)8 TranslogCorruptedException (org.opensearch.index.translog.TranslogCorruptedException)8 Metadata (org.opensearch.cluster.metadata.Metadata)7 IndexSettings (org.opensearch.index.IndexSettings)7 Files (java.nio.file.Files)6 Arrays (java.util.Arrays)6 Matcher (java.util.regex.Matcher)6