diff options
author | Øyvind Grønnesby <oyving@verizonmedia.com> | 2019-10-10 09:51:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-10 09:51:02 +0200 |
commit | 607c054896d7034175ee2958ebabbfe79038c5a3 (patch) | |
tree | 408d8b9eb9ac943021c2c45bd2e2611648adf984 /controller-server/src/test | |
parent | bd2a77e32e6138418981c6c202b371811fd08e54 (diff) | |
parent | 9ed8162d11b2f1e7042fef2d4a5e030af71948ed (diff) |
Merge pull request #10934 from vespa-engine/mpolden/change-status-of-all-endpoints
Change status of all endpoints when overriding global status
Diffstat (limited to 'controller-server/src/test')
2 files changed, 16 insertions, 14 deletions
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java index dad4b80de68..1558656b086 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java @@ -46,6 +46,7 @@ import java.util.Optional; import java.util.Set; import java.util.function.Function; import java.util.function.Supplier; +import java.util.stream.Collectors; import static com.yahoo.config.provision.SystemName.main; import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.component; @@ -236,29 +237,31 @@ public class ControllerTest { new RoutingEndpoint("http://old-endpoint.vespa.yahooapis.com:4080", "host1", false, "upstream2"), new RoutingEndpoint("http://qrs-endpoint.vespa.yahooapis.com:4080", "host1", false, "upstream1"), new RoutingEndpoint("http://feeding-endpoint.vespa.yahooapis.com:4080", "host2", false, "upstream3"), + new RoutingEndpoint("http://global-endpoint-2.vespa.yahooapis.com:4080", "host2", true, "upstream4"), new RoutingEndpoint("http://global-endpoint.vespa.yahooapis.com:4080", "host1", true, "upstream1"), new RoutingEndpoint("http://alias-endpoint.vespa.yahooapis.com:4080", "host1", true, "upstream1") )); - Supplier<Map<RoutingEndpoint, EndpointStatus>> rotationStatus = () -> tester.controller().applications().globalRotationStatus(deployment); - Function<String, Optional<EndpointStatus>> findStatusByUpstream = (upstreamName) -> { - return rotationStatus.get() - .entrySet().stream() - .filter(kv -> kv.getKey().upstreamName().equals(upstreamName)) - .findFirst() - .map(Map.Entry::getValue); + Supplier<Map<RoutingEndpoint, EndpointStatus>> globalRotationStatus = () -> tester.controller().applications().globalRotationStatus(deployment); + Supplier<List<EndpointStatus>> upstreamOneEndpoints = () -> { + return globalRotationStatus.get() + .entrySet().stream() + .filter(kv -> kv.getKey().upstreamName().equals("upstream1")) + .map(Map.Entry::getValue) + .collect(Collectors.toList()); }; // Check initial rotation status - assertEquals(1, rotationStatus.get().size()); - assertEquals(findStatusByUpstream.apply("upstream1").get().getStatus(), EndpointStatus.Status.in); + assertEquals(3, globalRotationStatus.get().size()); + assertEquals(2, upstreamOneEndpoints.get().size()); + assertTrue("All upstreams are in", upstreamOneEndpoints.get().stream().allMatch(es -> es.getStatus() == EndpointStatus.Status.in)); // Set the global rotations out of service EndpointStatus status = new EndpointStatus(EndpointStatus.Status.out, "unit-test", "Test", tester.clock().instant().getEpochSecond()); tester.controller().applications().setGlobalRotationStatus(deployment, status); - assertEquals(1, rotationStatus.get().size()); - assertEquals(findStatusByUpstream.apply("upstream1").get().getStatus(), EndpointStatus.Status.out); - assertEquals("unit-test", findStatusByUpstream.apply("upstream1").get().getReason()); + assertEquals(2, upstreamOneEndpoints.get().size()); + assertTrue("All upstreams are out", upstreamOneEndpoints.get().stream().allMatch(es -> es.getStatus() == EndpointStatus.Status.out)); + assertTrue("Reason is set", upstreamOneEndpoints.get().stream().allMatch(es -> es.getReason().equals("unit-test"))); // Deployment without a global endpoint tester.serviceRegistry().routingGeneratorMock().putEndpoints(deployment, List.of( @@ -266,7 +269,6 @@ public class ControllerTest { new RoutingEndpoint("http://qrs-endpoint.vespa.yahooapis.com:4080", "host1", false, "upstream1"), new RoutingEndpoint("http://feeding-endpoint.vespa.yahooapis.com:4080", "host2", false, "upstream3") )); - assertFalse("No global endpoint exists", findStatusByUpstream.apply("upstream1").isPresent()); try { tester.controller().applications().setGlobalRotationStatus(deployment, status); fail("Expected exception"); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/global-rotation-get.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/global-rotation-get.json index 860d6c49cdf..52aabab1584 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/global-rotation-get.json +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/global-rotation-get.json @@ -1 +1 @@ -{"globalrotationoverride":["upstream1",{"status":"in","reason":"","agent":"","timestamp":1497618757}]} +{"globalrotationoverride":["upstream1",{"status":"in","reason":"","agent":"","timestamp":1497618757},"upstream1",{"status":"in","reason":"","agent":"","timestamp":1497618757}]} |