aboutsummaryrefslogtreecommitdiffstats
path: root/vespaclient-java/src/test/java/com/yahoo
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-12-02 12:08:22 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2022-12-02 12:18:53 +0000
commited16494373ec67881f4389cb72379eb84cb39bd2 (patch)
tree93a5472bf8c74ea0c8eb8bba20aa52b41772be97 /vespaclient-java/src/test/java/com/yahoo
parente88b274e49c2b74495caa210621ac0cc47d797cc (diff)
Move vespa-status-filedistribution to where the other clients are and use a common jar file.
Diffstat (limited to 'vespaclient-java/src/test/java/com/yahoo')
-rw-r--r--vespaclient-java/src/test/java/com/yahoo/vespa/filedistribution/status/FileDistributionStatusClientTest.java59
1 files changed, 59 insertions, 0 deletions
diff --git a/vespaclient-java/src/test/java/com/yahoo/vespa/filedistribution/status/FileDistributionStatusClientTest.java b/vespaclient-java/src/test/java/com/yahoo/vespa/filedistribution/status/FileDistributionStatusClientTest.java
new file mode 100644
index 00000000000..a724838e7c7
--- /dev/null
+++ b/vespaclient-java/src/test/java/com/yahoo/vespa/filedistribution/status/FileDistributionStatusClientTest.java
@@ -0,0 +1,59 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+package com.yahoo.vespa.filedistribution.status;
+
+import org.junit.Test;
+
+import static com.yahoo.vespa.filedistribution.status.FileDistributionStatusClient.CommandLineArguments;
+import static org.junit.Assert.assertEquals;
+
+public class FileDistributionStatusClientTest {
+
+ private static final CommandLineArguments arguments = createArguments("--tenant", "foo", "--application", "bar");
+ private final FileDistributionStatusClient client = new FileDistributionStatusClient(arguments);
+
+ @Test
+ public void finishedForAllHosts() {
+ String output = client.parseAndGenerateOutput("{\"status\":\"FINISHED\"}");
+ assertEquals("File distribution finished", output);
+ }
+
+ @Test
+ public void unknownForAllHosts() {
+ String output = client.parseAndGenerateOutput("{\"status\":\"UNKNOWN\", \"message\":\"Something went wrong\"}");
+ assertEquals("File distribution status unknown: Something went wrong", output);
+ }
+
+ @Test
+ public void manyHostsVariousStates() {
+ String statusForTwoHosts = createStatusForTwoHosts();
+ System.out.println(statusForTwoHosts);
+ String output = client.parseAndGenerateOutput(statusForTwoHosts);
+ assertEquals("File distribution in progress:\nlocalhost1: IN_PROGRESS (1 of 2 finished)\nlocalhost2: UNKNOWN (Connection timed out)", output);
+ }
+
+ private static CommandLineArguments createArguments(String... args) {
+ return CommandLineArguments.build(args);
+ }
+
+ private String createStatusForTwoHosts() {
+ return "{\"status\":\"IN_PROGRESS\"," +
+ "\"hosts\":[" + createInProgressStatusForHost("localhost1") + "," + createUnknownStatusForHost("localhost2") + "]" +
+ "}";
+ }
+
+ private String createInProgressStatusForHost(String hostname) {
+ return "{\"hostname\":\"" + hostname + "\"," +
+ "\"status\":\"IN_PROGRESS\"," +
+ "\"message\":\"\"," +
+ "\"fileReferences\":[" +
+ "{\"1234\":0.2}, {\"abcd\":1.0}]}";
+ }
+
+ private String createUnknownStatusForHost(String hostname) {
+ return "{\"hostname\":\"" + hostname + "\"," +
+ "\"status\":\"UNKNOWN\"," +
+ "\"message\":\"Connection timed out\"}";
+ }
+
+}