|
@@ -43,6 +43,9 @@ public class ElasticsearchCliTests extends ESElasticsearchCliTestCase {
|
|
|
runTestThatVersionIsMutuallyExclusiveToOtherOptions("--version", "--daemonize");
|
|
|
runTestThatVersionIsMutuallyExclusiveToOtherOptions("--version", "-p", "/tmp/pid");
|
|
|
runTestThatVersionIsMutuallyExclusiveToOtherOptions("--version", "--pidfile", "/tmp/pid");
|
|
|
+ runTestThatVersionIsMutuallyExclusiveToOtherOptions("--version", "-q");
|
|
|
+ runTestThatVersionIsMutuallyExclusiveToOtherOptions("--version", "--quiet");
|
|
|
+
|
|
|
runTestThatVersionIsReturned("-V");
|
|
|
runTestThatVersionIsReturned("--version");
|
|
|
}
|
|
@@ -66,7 +69,7 @@ public class ElasticsearchCliTests extends ESElasticsearchCliTestCase {
|
|
|
}
|
|
|
|
|
|
private void runTestVersion(int expectedStatus, Consumer<String> outputConsumer, String... args) throws Exception {
|
|
|
- runTest(expectedStatus, false, outputConsumer, (foreground, pidFile, esSettings) -> {}, args);
|
|
|
+ runTest(expectedStatus, false, outputConsumer, (foreground, pidFile, quiet, esSettings) -> {}, args);
|
|
|
}
|
|
|
|
|
|
public void testPositionalArgs() throws Exception {
|
|
@@ -74,21 +77,21 @@ public class ElasticsearchCliTests extends ESElasticsearchCliTestCase {
|
|
|
ExitCodes.USAGE,
|
|
|
false,
|
|
|
output -> assertThat(output, containsString("Positional arguments not allowed, found [foo]")),
|
|
|
- (foreground, pidFile, esSettings) -> {},
|
|
|
+ (foreground, pidFile, quiet, esSettings) -> {},
|
|
|
"foo"
|
|
|
);
|
|
|
runTest(
|
|
|
ExitCodes.USAGE,
|
|
|
false,
|
|
|
output -> assertThat(output, containsString("Positional arguments not allowed, found [foo, bar]")),
|
|
|
- (foreground, pidFile, esSettings) -> {},
|
|
|
+ (foreground, pidFile, quiet, esSettings) -> {},
|
|
|
"foo", "bar"
|
|
|
);
|
|
|
runTest(
|
|
|
ExitCodes.USAGE,
|
|
|
false,
|
|
|
output -> assertThat(output, containsString("Positional arguments not allowed, found [foo]")),
|
|
|
- (foreground, pidFile, esSettings) -> {},
|
|
|
+ (foreground, pidFile, quiet, esSettings) -> {},
|
|
|
"-E", "foo=bar", "foo", "-E", "baz=qux"
|
|
|
);
|
|
|
}
|
|
@@ -109,7 +112,7 @@ public class ElasticsearchCliTests extends ESElasticsearchCliTestCase {
|
|
|
expectedStatus,
|
|
|
expectedInit,
|
|
|
outputConsumer,
|
|
|
- (foreground, pidFile, esSettings) -> assertThat(pidFile.toString(), equalTo(expectedPidFile.toString())),
|
|
|
+ (foreground, pidFile, quiet, esSettings) -> assertThat(pidFile.toString(), equalTo(expectedPidFile.toString())),
|
|
|
args);
|
|
|
}
|
|
|
|
|
@@ -124,7 +127,22 @@ public class ElasticsearchCliTests extends ESElasticsearchCliTestCase {
|
|
|
ExitCodes.OK,
|
|
|
true,
|
|
|
output -> {},
|
|
|
- (foreground, pidFile, esSettings) -> assertThat(foreground, equalTo(!expectedDaemonize)),
|
|
|
+ (foreground, pidFile, quiet, esSettings) -> assertThat(foreground, equalTo(!expectedDaemonize)),
|
|
|
+ args);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void testThatParsingQuietOptionWorks() throws Exception {
|
|
|
+ runQuietTest(true, "-q");
|
|
|
+ runQuietTest(true, "--quiet");
|
|
|
+ runQuietTest(false);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void runQuietTest(final boolean expectedQuiet, final String... args) throws Exception {
|
|
|
+ runTest(
|
|
|
+ ExitCodes.OK,
|
|
|
+ true,
|
|
|
+ output -> {},
|
|
|
+ (foreground, pidFile, quiet, esSettings) -> assertThat(quiet, equalTo(expectedQuiet)),
|
|
|
args);
|
|
|
}
|
|
|
|
|
@@ -133,7 +151,7 @@ public class ElasticsearchCliTests extends ESElasticsearchCliTestCase {
|
|
|
ExitCodes.OK,
|
|
|
true,
|
|
|
output -> {},
|
|
|
- (foreground, pidFile, esSettings) -> {
|
|
|
+ (foreground, pidFile, quiet, esSettings) -> {
|
|
|
assertThat(esSettings.size(), equalTo(2));
|
|
|
assertThat(esSettings, hasEntry("foo", "bar"));
|
|
|
assertThat(esSettings, hasEntry("baz", "qux"));
|
|
@@ -147,7 +165,7 @@ public class ElasticsearchCliTests extends ESElasticsearchCliTestCase {
|
|
|
ExitCodes.USAGE,
|
|
|
false,
|
|
|
output -> assertThat(output, containsString("Setting [foo] must not be empty")),
|
|
|
- (foreground, pidFile, esSettings) -> {},
|
|
|
+ (foreground, pidFile, quiet, esSettings) -> {},
|
|
|
"-E", "foo="
|
|
|
);
|
|
|
}
|
|
@@ -157,7 +175,7 @@ public class ElasticsearchCliTests extends ESElasticsearchCliTestCase {
|
|
|
ExitCodes.USAGE,
|
|
|
false,
|
|
|
output -> assertThat(output, containsString("network.host is not a recognized option")),
|
|
|
- (foreground, pidFile, esSettings) -> {},
|
|
|
+ (foreground, pidFile, quiet, esSettings) -> {},
|
|
|
"--network.host");
|
|
|
}
|
|
|
|