aboutsummaryrefslogtreecommitdiffstats
path: root/vespa-feed-client-cli/src/main/java/ai/vespa/feed/client/impl/CliArguments.java
diff options
context:
space:
mode:
authorjonmv <venstad@gmail.com>2022-08-11 13:44:37 +0200
committerjonmv <venstad@gmail.com>2022-08-11 13:44:37 +0200
commit5fec3608e404237ac006b59a4acf41bcfb1353dc (patch)
tree35591f766954719296d124d8db9d9fee9e389d05 /vespa-feed-client-cli/src/main/java/ai/vespa/feed/client/impl/CliArguments.java
parent8be6039101a0c4006199c2946d8381c86428ec11 (diff)
Add --speedTest to feed client CLI, and dryRun to /doc/v1
Diffstat (limited to 'vespa-feed-client-cli/src/main/java/ai/vespa/feed/client/impl/CliArguments.java')
-rw-r--r--vespa-feed-client-cli/src/main/java/ai/vespa/feed/client/impl/CliArguments.java33
1 files changed, 30 insertions, 3 deletions
diff --git a/vespa-feed-client-cli/src/main/java/ai/vespa/feed/client/impl/CliArguments.java b/vespa-feed-client-cli/src/main/java/ai/vespa/feed/client/impl/CliArguments.java
index e024f961e26..0eb829c954f 100644
--- a/vespa-feed-client-cli/src/main/java/ai/vespa/feed/client/impl/CliArguments.java
+++ b/vespa-feed-client-cli/src/main/java/ai/vespa/feed/client/impl/CliArguments.java
@@ -39,6 +39,8 @@ class CliArguments {
private static final String CONNECTIONS_OPTION = "connections";
private static final String DISABLE_SSL_HOSTNAME_VERIFICATION_OPTION = "disable-ssl-hostname-verification";
private static final String DRYRUN_OPTION = "dryrun";
+ private static final String SPEED_TEST_OPTION = "speed-test";
+ private static final String TEST_PAYLOAD_SIZE_OPTION = "test-payload-size";
private static final String ENDPOINT_OPTION = "endpoint";
private static final String FILE_OPTION = "file";
private static final String HEADER_OPTION = "header";
@@ -78,8 +80,19 @@ class CliArguments {
if (!args.hasOption(ENDPOINT_OPTION)) {
throw new CliArgumentsException("Endpoint must be specified");
}
- if (args.hasOption(FILE_OPTION) == args.hasOption(STDIN_OPTION)) {
- throw new CliArgumentsException(String.format("Either option '%s' or '%s' must be specified", FILE_OPTION, STDIN_OPTION));
+ if (args.hasOption(SPEED_TEST_OPTION)) {
+ if ( args.hasOption(FILE_OPTION) && (args.hasOption(STDIN_OPTION) || args.hasOption(TEST_PAYLOAD_SIZE_OPTION))
+ || args.hasOption(STDIN_OPTION) && args.hasOption(TEST_PAYLOAD_SIZE_OPTION)) {
+ throw new CliArgumentsException(String.format("At most one of '%s', '%s' and '%s' may be specified", FILE_OPTION, STDIN_OPTION, TEST_PAYLOAD_SIZE_OPTION));
+ }
+ }
+ else {
+ if (args.hasOption(FILE_OPTION) == args.hasOption(STDIN_OPTION)) {
+ throw new CliArgumentsException(String.format("Exactly one of '%s' and '%s' must be specified", FILE_OPTION, STDIN_OPTION));
+ }
+ if (args.hasOption(TEST_PAYLOAD_SIZE_OPTION)) {
+ throw new CliArgumentsException(String.format("Option '%s' can only be specified together with '%s'", TEST_PAYLOAD_SIZE_OPTION, SPEED_TEST_OPTION));
+ }
}
if (args.hasOption(CERTIFICATE_OPTION) != args.hasOption(PRIVATE_KEY_OPTION)) {
throw new CliArgumentsException(
@@ -166,6 +179,10 @@ class CliArguments {
boolean dryrunEnabled() { return has(DRYRUN_OPTION); }
+ boolean speedTest() { return has(SPEED_TEST_OPTION); }
+
+ OptionalInt testPayloadSize() throws CliArgumentsException { return intValue(TEST_PAYLOAD_SIZE_OPTION); }
+
Optional<URI> proxy() throws CliArgumentsException {
try {
URL url = (URL) arguments.getParsedOptionValue(PROXY_OPTION);
@@ -304,7 +321,17 @@ class CliArguments {
.build())
.addOption(Option.builder()
.longOpt(DRYRUN_OPTION)
- .desc("Enable dryrun mode where each operation succeeds after " + DryrunCluster.DELAY.toMillis() + "ms")
+ .desc("Let each operation succeed after " + DryrunCluster.DELAY.toMillis() + "ms, instead of sending it across the network ")
+ .build())
+ .addOption(Option.builder()
+ .longOpt(SPEED_TEST_OPTION)
+ .desc("Perform a network speed test, where the server immediately responds to each feed operation with a successful response")
+ .build())
+ .addOption(Option.builder()
+ .longOpt(TEST_PAYLOAD_SIZE_OPTION)
+ .desc("Document JSON test payload size in bytes, for use with --speed-test; requires --file and -stdin to not be set; default is 1024")
+ .hasArg()
+ .type(Number.class)
.build())
.addOption(Option.builder()
.longOpt(VERBOSE_OPTION)