diff options
Diffstat (limited to 'controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/routing/RoutingApiTest.java')
-rw-r--r-- | controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/routing/RoutingApiTest.java | 190 |
1 files changed, 95 insertions, 95 deletions
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/routing/RoutingApiTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/routing/RoutingApiTest.java index ea7ec7c1589..cb402d700e2 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/routing/RoutingApiTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/routing/RoutingApiTest.java @@ -14,13 +14,13 @@ import com.yahoo.vespa.hosted.controller.deployment.DeploymentTester; import com.yahoo.vespa.hosted.controller.integration.ZoneApiMock; import com.yahoo.vespa.hosted.controller.restapi.ContainerTester; import com.yahoo.vespa.hosted.controller.restapi.ControllerContainerTest; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.File; import java.util.List; -import static org.junit.Assert.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; /** * @author mpolden @@ -32,7 +32,7 @@ public class RoutingApiTest extends ControllerContainerTest { private ContainerTester tester; private DeploymentTester deploymentTester; - @Before + @BeforeEach public void before() { tester = new ContainerTester(container, responseFiles); deploymentTester = new DeploymentTester(new ControllerTester(tester)); @@ -40,7 +40,7 @@ public class RoutingApiTest extends ControllerContainerTest { } @Test - public void discovery() { + void discovery() { // Deploy var context = deploymentTester.newDeploymentContext("t1", "a1", "default"); var westZone = ZoneId.from("prod", "us-west-1"); @@ -54,34 +54,34 @@ public class RoutingApiTest extends ControllerContainerTest { // GET root tester.assertResponse(operatorRequest("http://localhost:8080/routing/v1/", "", - Request.Method.GET), - new File("discovery/root.json")); + Request.Method.GET), + new File("discovery/root.json")); // GET tenant tester.assertResponse(operatorRequest("http://localhost:8080/routing/v1/status/tenant/t1", "", - Request.Method.GET), - new File("discovery/tenant.json")); + Request.Method.GET), + new File("discovery/tenant.json")); // GET application tester.assertResponse(operatorRequest("http://localhost:8080/routing/v1/status/tenant/t1/application/a1/", - "", - Request.Method.GET), - new File("discovery/application.json")); + "", + Request.Method.GET), + new File("discovery/application.json")); // GET instance tester.assertResponse(operatorRequest("http://localhost:8080/routing/v1/status/tenant/t1/application/a1/instance/default/", - "", - Request.Method.GET), - new File("discovery/instance.json")); + "", + Request.Method.GET), + new File("discovery/instance.json")); // GET environment tester.assertResponse(operatorRequest("http://localhost:8080/routing/v1/status/environment/", "", - Request.Method.GET), - new File("discovery/environment.json")); + Request.Method.GET), + new File("discovery/environment.json")); } @Test - public void recursion() { + void recursion() { var context1 = deploymentTester.newDeploymentContext("t1", "a1", "default"); var westZone = ZoneId.from("prod", "us-west-1"); var eastZone = ZoneId.from("prod", "us-east-3"); @@ -102,33 +102,33 @@ public class RoutingApiTest extends ControllerContainerTest { // GET tenant recursively tester.assertResponse(operatorRequest("http://localhost:8080/routing/v1/status/tenant/t1?recursive=true", "", - Request.Method.GET), - new File("recursion/tenant.json")); + Request.Method.GET), + new File("recursion/tenant.json")); // GET application recursively tester.assertResponse(operatorRequest("http://localhost:8080/routing/v1/status/tenant/t1/application/a1?recursive=true", "", - Request.Method.GET), - new File("recursion/application.json")); + Request.Method.GET), + new File("recursion/application.json")); // GET instance recursively tester.assertResponse(operatorRequest("http://localhost:8080/routing/v1/status/tenant/t1/application/a1/instance/default?recursive=true", "", - Request.Method.GET), - new File("recursion/application.json")); + Request.Method.GET), + new File("recursion/application.json")); // GET environment recursively tester.assertResponse(operatorRequest("http://localhost:8080/routing/v1/status/environment?recursive=true", "", - Request.Method.GET), - new File("recursion/environment.json")); + Request.Method.GET), + new File("recursion/environment.json")); } @Test - public void exclusive_routing() { + void exclusive_routing() { var context = deploymentTester.newDeploymentContext(); // Zones support direct routing var westZone = ZoneId.from("prod", "us-west-1"); var eastZone = ZoneId.from("prod", "us-east-3"); deploymentTester.controllerTester().zoneRegistry().exclusiveRoutingIn(ZoneApiMock.from(westZone), - ZoneApiMock.from(eastZone)); + ZoneApiMock.from(eastZone)); // Deploy application var applicationPackage = new ApplicationPackageBuilder() .athenzIdentity(AthenzDomain.from("domain"), AthenzService.from("service")) @@ -140,45 +140,45 @@ public class RoutingApiTest extends ControllerContainerTest { // GET initial deployment status tester.assertResponse(operatorRequest("http://localhost:8080/routing/v1/status/tenant/tenant/application/application/instance/default/environment/prod/region/us-west-1", - "", Request.Method.GET), - new File("policy/deployment-status-initial.json")); + "", Request.Method.GET), + new File("policy/deployment-status-initial.json")); // POST sets deployment out tester.assertResponse(operatorRequest("http://localhost:8080/routing/v1/inactive/tenant/tenant/application/application/instance/default/environment/prod/region/us-west-1", - "", Request.Method.POST), - "{\"message\":\"Set global routing status for tenant.application in prod.us-west-1 to OUT\"}"); + "", Request.Method.POST), + "{\"message\":\"Set global routing status for tenant.application in prod.us-west-1 to OUT\"}"); tester.assertResponse(operatorRequest("http://localhost:8080/routing/v1/status/tenant/tenant/application/application/instance/default/environment/prod/region/us-west-1", - "", Request.Method.GET), - new File("policy/deployment-status-out.json")); + "", Request.Method.GET), + new File("policy/deployment-status-out.json")); // DELETE sets deployment in tester.assertResponse(operatorRequest("http://localhost:8080/routing/v1/inactive/tenant/tenant/application/application/instance/default/environment/prod/region/us-west-1", - "", Request.Method.DELETE), - "{\"message\":\"Set global routing status for tenant.application in prod.us-west-1 to IN\"}"); + "", Request.Method.DELETE), + "{\"message\":\"Set global routing status for tenant.application in prod.us-west-1 to IN\"}"); tester.assertResponse(operatorRequest("http://localhost:8080/routing/v1/status/tenant/tenant/application/application/instance/default/environment/prod/region/us-west-1", - "", Request.Method.GET), - new File("policy/deployment-status-in.json")); + "", Request.Method.GET), + new File("policy/deployment-status-in.json")); // GET initial zone status tester.assertResponse(operatorRequest("http://localhost:8080/routing/v1/status/environment/prod/region/us-west-1", - "", Request.Method.GET), - new File("policy/zone-status-initial.json")); + "", Request.Method.GET), + new File("policy/zone-status-initial.json")); // POST sets zone out tester.assertResponse(operatorRequest("http://localhost:8080/routing/v1/inactive/environment/prod/region/us-west-1", - "", Request.Method.POST), - "{\"message\":\"Set global routing status for deployments in prod.us-west-1 to OUT\"}"); + "", Request.Method.POST), + "{\"message\":\"Set global routing status for deployments in prod.us-west-1 to OUT\"}"); tester.assertResponse(operatorRequest("http://localhost:8080/routing/v1/status/environment/prod/region/us-west-1", - "", Request.Method.GET), - new File("policy/zone-status-out.json")); + "", Request.Method.GET), + new File("policy/zone-status-out.json")); // DELETE sets zone in tester.assertResponse(operatorRequest("http://localhost:8080/routing/v1/inactive/environment/prod/region/us-west-1", - "", Request.Method.DELETE), - "{\"message\":\"Set global routing status for deployments in prod.us-west-1 to IN\"}"); + "", Request.Method.DELETE), + "{\"message\":\"Set global routing status for deployments in prod.us-west-1 to IN\"}"); tester.assertResponse(operatorRequest("http://localhost:8080/routing/v1/status/environment/prod/region/us-west-1", - "", Request.Method.GET), - new File("policy/zone-status-in.json")); + "", Request.Method.GET), + new File("policy/zone-status-in.json")); // Endpoint is removed applicationPackage = new ApplicationPackageBuilder() @@ -191,12 +191,12 @@ public class RoutingApiTest extends ControllerContainerTest { // GET deployment status. Now empty as no routing policies have global endpoints tester.assertResponse(operatorRequest("http://localhost:8080/routing/v1/status/tenant/tenant/application/application/instance/default/environment/prod/region/us-west-1", - "", Request.Method.GET), - "{\"deployments\":[]}"); + "", Request.Method.GET), + "{\"deployments\":[]}"); } @Test - public void shared_routing() { + void shared_routing() { // Deploy application var context = deploymentTester.newDeploymentContext(); var westZone = ZoneId.from("prod", "us-west-1"); @@ -208,61 +208,61 @@ public class RoutingApiTest extends ControllerContainerTest { .build(); context.submit(applicationPackage).deploy(); - assertNotEquals("Rotation is assigned", List.of(), context.instance().rotations()); + assertNotEquals(List.of(), context.instance().rotations(), "Rotation is assigned"); // GET initial deployment status tester.assertResponse(operatorRequest("http://localhost:8080/routing/v1/status/tenant/tenant/application/application/instance/default/environment/prod/region/us-west-1", - "", Request.Method.GET), - new File("rotation/deployment-status-initial.json")); + "", Request.Method.GET), + new File("rotation/deployment-status-initial.json")); // POST sets deployment out tester.assertResponse(operatorRequest("http://localhost:8080/routing/v1/inactive/tenant/tenant/application/application/instance/default/environment/prod/region/us-west-1", - "", Request.Method.POST), - "{\"message\":\"Set global routing status for tenant.application in prod.us-west-1 to OUT\"}"); + "", Request.Method.POST), + "{\"message\":\"Set global routing status for tenant.application in prod.us-west-1 to OUT\"}"); tester.assertResponse(operatorRequest("http://localhost:8080/routing/v1/status/tenant/tenant/application/application/instance/default/environment/prod/region/us-west-1", - "", Request.Method.GET), - new File("rotation/deployment-status-out.json")); + "", Request.Method.GET), + new File("rotation/deployment-status-out.json")); // DELETE sets deployment in tester.assertResponse(operatorRequest("http://localhost:8080/routing/v1/inactive/tenant/tenant/application/application/instance/default/environment/prod/region/us-west-1", - "", Request.Method.DELETE), - "{\"message\":\"Set global routing status for tenant.application in prod.us-west-1 to IN\"}"); + "", Request.Method.DELETE), + "{\"message\":\"Set global routing status for tenant.application in prod.us-west-1 to IN\"}"); tester.assertResponse(operatorRequest("http://localhost:8080/routing/v1/status/tenant/tenant/application/application/instance/default/environment/prod/region/us-west-1", - "", Request.Method.GET), - new File("rotation/deployment-status-in.json")); + "", Request.Method.GET), + new File("rotation/deployment-status-in.json")); // GET initial zone status tester.assertResponse(operatorRequest("http://localhost:8080/routing/v1/status/environment/prod/region/us-west-1", - "", Request.Method.GET), - new File("rotation/zone-status-initial.json")); + "", Request.Method.GET), + new File("rotation/zone-status-initial.json")); // POST sets zone out tester.assertResponse(operatorRequest("http://localhost:8080/routing/v1/inactive/environment/prod/region/us-west-1", - "", Request.Method.POST), - "{\"message\":\"Set global routing status for deployments in prod.us-west-1 to OUT\"}"); + "", Request.Method.POST), + "{\"message\":\"Set global routing status for deployments in prod.us-west-1 to OUT\"}"); tester.assertResponse(operatorRequest("http://localhost:8080/routing/v1/status/environment/prod/region/us-west-1", - "", Request.Method.GET), - new File("rotation/zone-status-out.json")); + "", Request.Method.GET), + new File("rotation/zone-status-out.json")); // DELETE sets zone in tester.assertResponse(operatorRequest("http://localhost:8080/routing/v1/inactive/environment/prod/region/us-west-1", - "", Request.Method.DELETE), - "{\"message\":\"Set global routing status for deployments in prod.us-west-1 to IN\"}"); + "", Request.Method.DELETE), + "{\"message\":\"Set global routing status for deployments in prod.us-west-1 to IN\"}"); tester.assertResponse(operatorRequest("http://localhost:8080/routing/v1/status/environment/prod/region/us-west-1", - "", Request.Method.GET), - new File("rotation/zone-status-in.json")); + "", Request.Method.GET), + new File("rotation/zone-status-in.json")); } @Test - public void mixed_routing_multiple_zones() { + void mixed_routing_multiple_zones() { var westZone = ZoneId.from("prod", "us-west-1"); var eastZone = ZoneId.from("prod", "us-east-3"); // One shared and one exclusive zone deploymentTester.controllerTester().zoneRegistry().setRoutingMethod(ZoneApiMock.from(westZone), - RoutingMethod.sharedLayer4); + RoutingMethod.sharedLayer4); deploymentTester.controllerTester().zoneRegistry().setRoutingMethod(ZoneApiMock.from(eastZone), - RoutingMethod.exclusive); + RoutingMethod.exclusive); // Deploy application var context = deploymentTester.newDeploymentContext(); @@ -277,23 +277,23 @@ public class RoutingApiTest extends ControllerContainerTest { // GET status for zone using sharedLayer4 routing tester.assertResponse(operatorRequest("http://localhost:8080/routing/v1/status/tenant/tenant/application/application/instance/default/environment/prod/region/us-west-1", - "", Request.Method.GET), - new File("rotation/deployment-status-initial.json")); + "", Request.Method.GET), + new File("rotation/deployment-status-initial.json")); // GET status for zone using exclusive routing tester.assertResponse(operatorRequest("http://localhost:8080/routing/v1/status/tenant/tenant/application/application/instance/default/environment/prod/region/us-east-3", - "", Request.Method.GET), - "{\"deployments\":[{\"routingMethod\":\"exclusive\",\"instance\":\"tenant:application:default\"," + - "\"environment\":\"prod\",\"region\":\"us-east-3\",\"status\":\"in\",\"agent\":\"system\",\"changedAt\":0}]}"); + "", Request.Method.GET), + "{\"deployments\":[{\"routingMethod\":\"exclusive\",\"instance\":\"tenant:application:default\"," + + "\"environment\":\"prod\",\"region\":\"us-east-3\",\"status\":\"in\",\"agent\":\"system\",\"changedAt\":0}]}"); } @Test - public void invalid_requests() { + void invalid_requests() { // GET non-existent application tester.assertResponse(operatorRequest("http://localhost:8080/routing/v1/status/tenant/t1/application/a1/instance/default/environment/prod/region/us-west-1", - "", Request.Method.GET), - "{\"error-code\":\"BAD_REQUEST\",\"message\":\"t1.a1 not found\"}", - 400); + "", Request.Method.GET), + "{\"error-code\":\"BAD_REQUEST\",\"message\":\"t1.a1 not found\"}", + 400); // GET, DELETE non-existent deployment var context = deploymentTester.newDeploymentContext(); @@ -303,23 +303,23 @@ public class RoutingApiTest extends ControllerContainerTest { .build(); context.submit(applicationPackage).deploy(); tester.assertResponse(operatorRequest("http://localhost:8080/routing/v1/status/tenant/tenant/application/application/instance/default/environment/prod/region/us-west-1", - "", Request.Method.GET), - "{\"error-code\":\"BAD_REQUEST\",\"message\":\"No such deployment: tenant.application in prod.us-west-1\"}", - 400); + "", Request.Method.GET), + "{\"error-code\":\"BAD_REQUEST\",\"message\":\"No such deployment: tenant.application in prod.us-west-1\"}", + 400); tester.assertResponse(operatorRequest("http://localhost:8080/routing/v1/inactive/tenant/tenant/application/application/instance/default/environment/prod/region/us-west-1", - "", Request.Method.DELETE), - "{\"error-code\":\"BAD_REQUEST\",\"message\":\"No such deployment: tenant.application in prod.us-west-1\"}", - 400); + "", Request.Method.DELETE), + "{\"error-code\":\"BAD_REQUEST\",\"message\":\"No such deployment: tenant.application in prod.us-west-1\"}", + 400); // GET non-existent zone tester.assertResponse(operatorRequest("http://localhost:8080/routing/v1/status/environment/prod/region/us-north-1", - "", Request.Method.GET), - "{\"error-code\":\"BAD_REQUEST\",\"message\":\"No such zone: prod.us-north-1\"}", - 400); + "", Request.Method.GET), + "{\"error-code\":\"BAD_REQUEST\",\"message\":\"No such zone: prod.us-north-1\"}", + 400); } @Test - public void endpoints_list() { + void endpoints_list() { var context = deploymentTester.newDeploymentContext("t1", "a1", "default"); var westZone = ZoneId.from("prod", "us-west-1"); var eastZone = ZoneId.from("prod", "us-east-3"); @@ -331,7 +331,7 @@ public class RoutingApiTest extends ControllerContainerTest { context.submit(applicationPackage).deploy(); tester.assertResponse(operatorRequest("http://localhost:8080/routing/v1/status/tenant/t1/application/a1/instance/default/endpoint", "", Request.Method.GET), - new File("endpoint/endpoints.json")); + new File("endpoint/endpoints.json")); } } |