diff options
author | Jon Marius Venstad <venstad@gmail.com> | 2019-10-26 10:46:03 +0200 |
---|---|---|
committer | Jon Marius Venstad <venstad@gmail.com> | 2019-10-26 10:46:03 +0200 |
commit | 8e0425580cb8e15a2f793b5b518a325a7445df28 (patch) | |
tree | 0fd460802072bee940d5cfed4ad68aef250e6a3b /controller-server/src | |
parent | e7b68ad0a14fd74f70267738716fcc116e4f019d (diff) |
Use default instance prod deployments for prod test config for user instances
Diffstat (limited to 'controller-server/src')
4 files changed, 26 insertions, 18 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java index 29806f1355c..dd6179f7042 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java @@ -1581,6 +1581,7 @@ public class ApplicationApiHandler extends LoggingRequestHandler { } } + /** Returns test config for indicated job, with production deployments of the default instance. */ private HttpResponse testConfig(ApplicationId id, JobType type) { // TODO jonmv: Support non-default instances as well; requires API change in clients. ApplicationId defaultInstanceId = TenantAndApplicationId.from(id).defaultInstance(); @@ -1591,12 +1592,11 @@ public class ApplicationApiHandler extends LoggingRequestHandler { .collect(Collectors.toSet()); var testedZone = type.zone(controller.system()); - // This should not happen, unless one asks for test-config for a production job, which one shouldn't have use for. - if (deployments.stream().anyMatch(deploymentId -> deploymentId.zoneId().equals(testedZone) - && ! deploymentId.applicationId().equals(id))) - throw new IllegalStateException("Conflict: " + testedZone + " contains both default and " + id.instance().value() + " instances"); + // If a production job is specified, the production deployment of the _default instance_ is the relevant one, + // as user instances should not exist in prod. TODO jonmv: Remove this when multiple instances are supported (above). + if ( ! type.isProduction()) + deployments.add(new DeploymentId(id, testedZone)); - deployments.add(new DeploymentId(id, testedZone)); return new SlimeJsonResponse(testConfigSerializer.configSlime(id, type, false, diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java index 36366a34fa5..eac60b72c6f 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java @@ -27,6 +27,7 @@ import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.LockedTenant; import com.yahoo.vespa.hosted.controller.api.application.v4.EnvironmentResource; import com.yahoo.vespa.hosted.controller.api.application.v4.model.DeployOptions; +import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId; import com.yahoo.vespa.hosted.controller.api.identifiers.Property; import com.yahoo.vespa.hosted.controller.api.identifiers.PropertyId; import com.yahoo.vespa.hosted.controller.api.identifiers.ScrewdriverId; @@ -45,6 +46,8 @@ import com.yahoo.vespa.hosted.controller.api.integration.resource.MeteringInfo; import com.yahoo.vespa.hosted.controller.api.integration.resource.MockTenantCost; import com.yahoo.vespa.hosted.controller.api.integration.resource.ResourceAllocation; import com.yahoo.vespa.hosted.controller.api.integration.resource.ResourceSnapshot; +import com.yahoo.vespa.hosted.controller.api.integration.routing.RoutingEndpoint; +import com.yahoo.vespa.hosted.controller.api.integration.routing.RoutingGeneratorMock; import com.yahoo.vespa.hosted.controller.api.integration.stubs.MockMeteringClient; import com.yahoo.vespa.hosted.controller.application.ApplicationPackage; import com.yahoo.vespa.hosted.controller.application.Change; @@ -577,11 +580,6 @@ public class ApplicationApiTest extends ControllerContainerTest { .oktaAccessToken(OKTA_AT), new File("delete-with-active-deployments.json"), 400); - // GET test-config for local tests against a prod deployment - tester.assertResponse(request("/application/v4/tenant/tenant1/application/application1/instance/instance1/job/production-us-central-1/test-config", GET) - .userIdentity(USER_ID), - new File("test-config.json")); - // DELETE (deactivate) a deployment - dev tester.assertResponse(request("/application/v4/tenant/tenant1/application/application1/environment/dev/region/us-west-1/instance/instance1", DELETE) .userIdentity(USER_ID), @@ -598,7 +596,7 @@ public class ApplicationApiTest extends ControllerContainerTest { .screwdriverIdentity(SCREWDRIVER_ID), "{\"message\":\"Deactivated tenant1.application1.instance1 in prod.us-central-1\"}"); - // GET test-config for local tests against a dev deployment + // Setup for test config tests tester.controller().applications().deploy(ApplicationId.from("tenant1", "application1", "default"), ZoneId.from("prod", "us-central-1"), Optional.of(applicationPackageDefault), @@ -607,13 +605,23 @@ public class ApplicationApiTest extends ControllerContainerTest { ZoneId.from("dev", "us-east-1"), Optional.of(applicationPackageDefault), new DeployOptions(false, Optional.empty(), false, false)); + tester.serviceRegistry().routingGeneratorMock().putEndpoints(new DeploymentId(ApplicationId.from("tenant1", "application1", "default"), ZoneId.from("prod", "us-central-1")), + List.of(new RoutingEndpoint("https://us-central-1.prod.default", "host", false, "upstream"))); + tester.serviceRegistry().routingGeneratorMock().putEndpoints(new DeploymentId(ApplicationId.from("tenant1", "application1", "my-user"), ZoneId.from("dev", "us-east-1")), + List.of(new RoutingEndpoint("https://us-east-1.dev.my-user", "host", false, "upstream"))); + // GET test-config for local tests against a dev deployment tester.assertResponse(request("/application/v4/tenant/tenant1/application/application1/instance/my-user/job/dev-us-east-1/test-config", GET) .userIdentity(USER_ID), new File("test-config-dev.json")); + // GET test-config for local tests against a prod deployment + tester.assertResponse(request("/application/v4/tenant/tenant1/application/application1/instance/my-user/job/production-us-central-1/test-config", GET) + .userIdentity(USER_ID), + new File("test-config.json")); tester.controller().applications().deactivate(ApplicationId.from("tenant1", "application1", "default"), ZoneId.from("prod", "us-central-1")); tester.controller().applications().deactivate(ApplicationId.from("tenant1", "application1", "my-user"), ZoneId.from("dev", "us-east-1")); + // teardown for test config tests // POST an application package to start a deployment to dev tester.assertResponse(request("/application/v4/tenant/tenant1/application/application1/instance/instance1/deploy/dev-us-east-1", POST) diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/test-config-dev.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/test-config-dev.json index 1c09d4698a9..818dc72a9d9 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/test-config-dev.json +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/test-config-dev.json @@ -5,18 +5,18 @@ "isCI": false, "endpoints": { "dev.us-east-1": [ - "http://old-endpoint.vespa.yahooapis.com:4080" + "https://us-east-1.dev.my-user" ], "prod.us-central-1": [ - "http://old-endpoint.vespa.yahooapis.com:4080" + "https://us-central-1.prod.default" ] }, "zoneEndpoints": { "dev.us-east-1": { - "default": "http://old-endpoint.vespa.yahooapis.com:4080" + "default": "https://us-east-1.dev.my-user" }, "prod.us-central-1": { - "default": "http://old-endpoint.vespa.yahooapis.com:4080" + "default": "https://us-central-1.prod.default" } }, "clusters": { diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/test-config.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/test-config.json index b3fa30ee975..c1ccbc7100f 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/test-config.json +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/test-config.json @@ -1,16 +1,16 @@ { - "application": "tenant1:application1:instance1", + "application": "tenant1:application1:my-user", "zone": "prod.us-central-1", "system": "main", "isCI": false, "endpoints": { "prod.us-central-1": [ - "http://old-endpoint.vespa.yahooapis.com:4080" + "https://us-central-1.prod.default" ] }, "zoneEndpoints": { "prod.us-central-1": { - "default": "http://old-endpoint.vespa.yahooapis.com:4080" + "default": "https://us-central-1.prod.default" } }, "clusters": { |