summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Marius Venstad <jonmv@users.noreply.github.com>2021-05-26 17:32:25 +0200
committerGitHub <noreply@github.com>2021-05-26 17:32:25 +0200
commitb68b47e1df3820f0d7e87c92745ae5a2b6e16483 (patch)
tree758ccd200cc8a3d21722d8c9a112504097f71149
parent405914c1cb25f46187628a75777ddcc046f54311 (diff)
parent7b4cab8d78190252ebc073659373030cd8f0898c (diff)
Merge pull request #17993 from vespa-engine/bjorncs/vespa-feed-client
Bjorncs/vespa feed client
-rw-r--r--vespa-feed-client-cli/src/main/java/ai/vespa/feed/client/CliArguments.java21
-rw-r--r--vespa-feed-client-cli/src/main/java/ai/vespa/feed/client/CliClient.java7
-rw-r--r--vespa-feed-client-cli/src/test/java/ai/vespa/feed/client/CliArgumentsTest.java3
-rw-r--r--vespa-feed-client-cli/src/test/resources/help.txt1
4 files changed, 22 insertions, 10 deletions
diff --git a/vespa-feed-client-cli/src/main/java/ai/vespa/feed/client/CliArguments.java b/vespa-feed-client-cli/src/main/java/ai/vespa/feed/client/CliArguments.java
index 06c994b12b6..33c3d0e7894 100644
--- a/vespa-feed-client-cli/src/main/java/ai/vespa/feed/client/CliArguments.java
+++ b/vespa-feed-client-cli/src/main/java/ai/vespa/feed/client/CliArguments.java
@@ -31,17 +31,18 @@ class CliArguments {
private static final Options optionsDefinition = createOptions();
- private static final String HELP_OPTION = "help";
- private static final String VERSION_OPTION = "version";
+ private static final String BENCHMARK_OPTION = "benchmark";
+ private static final String CA_CERTIFICATES_OPTION = "ca-certificates";
+ private static final String CERTIFICATE_OPTION = "certificate";
+ private static final String CONNECTIONS_OPTION = "connections";
+ private static final String DISABLE_SSL_HOSTNAME_VERIFICATION_OPTION = "disable-ssl-hostname-verification";
private static final String ENDPOINT_OPTION = "endpoint";
private static final String FILE_OPTION = "file";
- private static final String CONNECTIONS_OPTION = "connections";
+ private static final String HEADER_OPTION = "header";
+ private static final String HELP_OPTION = "help";
private static final String MAX_STREAMS_PER_CONNECTION = "max-streams-per-connection";
- private static final String CERTIFICATE_OPTION = "certificate";
private static final String PRIVATE_KEY_OPTION = "private-key";
- private static final String CA_CERTIFICATES_OPTION = "ca-certificates";
- private static final String DISABLE_SSL_HOSTNAME_VERIFICATION_OPTION = "disable-ssl-hostname-verification";
- private static final String HEADER_OPTION = "header";
+ private static final String VERSION_OPTION = "version";
private final CommandLine arguments;
@@ -113,6 +114,8 @@ class CliArguments {
boolean sslHostnameVerificationDisabled() { return has(DISABLE_SSL_HOSTNAME_VERIFICATION_OPTION); }
+ boolean benchmarkModeEnabled() { return has(BENCHMARK_OPTION); }
+
private OptionalInt intValue(String option) throws CliArgumentsException {
try {
Number number = (Number) arguments.getParsedOptionValue(option);
@@ -135,6 +138,7 @@ class CliArguments {
private boolean has(String option) { return arguments.hasOption(option); }
private static Options createOptions() {
+ // TODO Add description to each option
return new Options()
.addOption(Option.builder()
.longOpt(HELP_OPTION)
@@ -188,6 +192,9 @@ class CliArguments {
.build())
.addOption(Option.builder()
.longOpt(DISABLE_SSL_HOSTNAME_VERIFICATION_OPTION)
+ .build())
+ .addOption(Option.builder()
+ .longOpt(BENCHMARK_OPTION)
.build());
}
diff --git a/vespa-feed-client-cli/src/main/java/ai/vespa/feed/client/CliClient.java b/vespa-feed-client-cli/src/main/java/ai/vespa/feed/client/CliClient.java
index 060f406f38f..27ecada98c3 100644
--- a/vespa-feed-client-cli/src/main/java/ai/vespa/feed/client/CliClient.java
+++ b/vespa-feed-client-cli/src/main/java/ai/vespa/feed/client/CliClient.java
@@ -4,6 +4,7 @@ package ai.vespa.feed.client;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSession;
import java.io.IOException;
+import java.io.InputStream;
import java.io.PrintStream;
import java.nio.file.Path;
import java.util.Properties;
@@ -17,16 +18,18 @@ public class CliClient {
private final PrintStream systemOut;
private final PrintStream systemError;
+ private final InputStream systemIn;
private final Properties systemProperties;
- private CliClient(PrintStream systemOut, PrintStream systemError, Properties systemProperties) {
+ private CliClient(PrintStream systemOut, PrintStream systemError, InputStream systemIn, Properties systemProperties) {
this.systemOut = systemOut;
this.systemError = systemError;
+ this.systemIn = systemIn;
this.systemProperties = systemProperties;
}
public static void main(String[] args) {
- CliClient client = new CliClient(System.out, System.err, System.getProperties());
+ CliClient client = new CliClient(System.out, System.err, System.in, System.getProperties());
int exitCode = client.run(args);
System.exit(exitCode);
}
diff --git a/vespa-feed-client-cli/src/test/java/ai/vespa/feed/client/CliArgumentsTest.java b/vespa-feed-client-cli/src/test/java/ai/vespa/feed/client/CliArgumentsTest.java
index be479d294d5..33ee31ff0dc 100644
--- a/vespa-feed-client-cli/src/test/java/ai/vespa/feed/client/CliArgumentsTest.java
+++ b/vespa-feed-client-cli/src/test/java/ai/vespa/feed/client/CliArgumentsTest.java
@@ -21,7 +21,7 @@ class CliArgumentsTest {
"--endpoint=https://vespa.ai:4443/", "--file=feed.json", "--connections=10",
"--max-streams-per-connection=128", "--certificate=cert.pem", "--private-key=key.pem",
"--ca-certificates=ca-certs.pem", "--disable-ssl-hostname-verification",
- "--header=\"My-Header: my-value\"", "--header", "Another-Header: another-value"});
+ "--header=\"My-Header: my-value\"", "--header", "Another-Header: another-value", "--benchmark"});
assertEquals(URI.create("https://vespa.ai:4443/"), args.endpoint());
assertEquals(Paths.get("feed.json"), args.inputFile());
assertEquals(10, args.connections().getAsInt());
@@ -35,6 +35,7 @@ class CliArgumentsTest {
assertEquals(2, args.headers().size());
assertEquals("my-value", args.headers().get("My-Header"));
assertEquals("another-value", args.headers().get("Another-Header"));
+ assertTrue(args.benchmarkModeEnabled());
}
@Test
diff --git a/vespa-feed-client-cli/src/test/resources/help.txt b/vespa-feed-client-cli/src/test/resources/help.txt
index 8ad153bc0e0..9ad7642d4ec 100644
--- a/vespa-feed-client-cli/src/test/resources/help.txt
+++ b/vespa-feed-client-cli/src/test/resources/help.txt
@@ -1,5 +1,6 @@
usage: vespa-feed-client <options>
Vespa feed client
+ --benchmark
--ca-certificates <arg>
--certificate <arg>
--connections <arg>