From 91b08a230e74825d91604ecab82ccbf3ff6add86 Mon Sep 17 00:00:00 2001 From: Jon Marius Venstad Date: Wed, 6 Nov 2019 09:28:29 +0100 Subject: Really support multiple instances --- .../config/application/api/DeploymentSpecTest.java | 6 +++--- .../controller/deployment/DeploymentTrigger.java | 1 - .../restapi/application/ApplicationApiHandler.java | 2 -- .../deployment/ApplicationPackageBuilder.java | 16 ++++++++++++++++ .../deployment/DeploymentTriggerTest.java | 3 +-- .../restapi/application/ApplicationApiTest.java | 12 ++++++++++-- .../restapi/application/responses/jobs.json | 22 +++++++++++----------- .../application/responses/system-test-job.json | 4 ++-- 8 files changed, 43 insertions(+), 23 deletions(-) diff --git a/config-model-api/src/test/java/com/yahoo/config/application/api/DeploymentSpecTest.java b/config-model-api/src/test/java/com/yahoo/config/application/api/DeploymentSpecTest.java index f181b02a071..c52d432e73d 100644 --- a/config-model-api/src/test/java/com/yahoo/config/application/api/DeploymentSpecTest.java +++ b/config-model-api/src/test/java/com/yahoo/config/application/api/DeploymentSpecTest.java @@ -995,9 +995,9 @@ public class DeploymentSpecTest { " " + " " + " " + - " us-east" + - " " + - " " + + " us-east" + + " " + + " " + " " + " " + " " + diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTrigger.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTrigger.java index 73e3739a772..3f86d996ad7 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTrigger.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTrigger.java @@ -78,7 +78,6 @@ public class DeploymentTrigger { */ public static final Duration maxPause = Duration.ofDays(3); - private final static Logger log = Logger.getLogger(DeploymentTrigger.class.getName()); private final Controller controller; 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 611e099e6aa..5cb7d7a6065 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 @@ -1934,8 +1934,6 @@ public class ApplicationApiHandler extends LoggingRequestHandler { ApplicationPackage applicationPackage = new ApplicationPackage(dataParts.get(EnvironmentResource.APPLICATION_ZIP)); if (DeploymentSpec.empty.equals(applicationPackage.deploymentSpec())) throw new IllegalArgumentException("Missing required file 'deployment.xml'"); - if (applicationPackage.deploymentSpec().instances().size() != 1) - throw new IllegalArgumentException("Only single-instance deployment specs are currently supported"); controller.applications().verifyApplicationIdentityConfiguration(TenantName.from(tenant), applicationPackage, diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/ApplicationPackageBuilder.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/ApplicationPackageBuilder.java index c352fc5550f..f91f35a6b1b 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/ApplicationPackageBuilder.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/ApplicationPackageBuilder.java @@ -46,6 +46,8 @@ public class ApplicationPackageBuilder { private OptionalInt majorVersion = OptionalInt.empty(); private String instances = "default"; private String upgradePolicy = null; + private boolean explicitSystemTest = false; + private boolean explicitStagingTest = false; private Environment environment = Environment.prod; private String globalServiceId = null; private String athenzIdentityAttributes = null; @@ -61,6 +63,16 @@ public class ApplicationPackageBuilder { return this; } + public ApplicationPackageBuilder systemTest() { + this.explicitSystemTest = true; + return this; + } + + public ApplicationPackageBuilder stagingTest() { + this.explicitStagingTest = true; + return this; + } + public ApplicationPackageBuilder upgradePolicy(String upgradePolicy) { this.upgradePolicy = upgradePolicy; return this; @@ -177,6 +189,10 @@ public class ApplicationPackageBuilder { } xml.append(notifications); xml.append(blockChange); + if (explicitSystemTest) + xml.append(" \n"); + if (explicitStagingTest) + xml.append(" \n"); xml.append(" <"); xml.append(environment.value()); if (globalServiceId != null) { diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTriggerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTriggerTest.java index 52db1061655..8fb766164c2 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTriggerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTriggerTest.java @@ -862,7 +862,6 @@ public class DeploymentTriggerTest { } @Test - @Ignore public void testMultipleInstances() { ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .instances("instance1,instance2") @@ -870,7 +869,7 @@ public class DeploymentTriggerTest { .region("us-east-3") .build(); var app = tester.newDeploymentContext("tenant1", "application1", "instance1").submit(applicationPackage); // TODO jonmv: support instances in deployment context> - var otherInstance = tester.newDeploymentContext("tenant1", "application1", "instance2"); // TODO jonmv: support instances in deployment context> + var otherInstance = tester.newDeploymentContext("tenant1", "application1", "instance2"); app.runJob(systemTest).runJob(stagingTest).runJob(productionUsEast3); otherInstance.runJob(systemTest).runJob(stagingTest).runJob(productionUsEast3); assertEquals(2, app.application().instances().size()); 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 a1c9aa872fd..417842fb608 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 @@ -661,17 +661,21 @@ public class ApplicationApiTest extends ControllerContainerTest { .data(streamer), "{\"message\":\"Application package version: 1.0.3-commit1, source revision of repository 'repository1', branch 'master' with commit 'commit1', by a@b, built against 6.1 at 1970-01-01T00:00:01Z\"}"); - // Sixth attempt has a multi-instance deployment spec, and fails. + // Sixth attempt has a multi-instance deployment spec, and is accepted. ApplicationPackage multiInstanceSpec = new ApplicationPackageBuilder() .instances("instance1,instance2") + .systemTest() + .stagingTest() .environment(Environment.prod) .region("us-central-1") .parallel("us-west-1", "us-east-3") + .endpoint("default", "foo", "us-central-1", "us-west-1", "us-east-3") .build(); tester.assertResponse(request("/application/v4/tenant/tenant1/application/application1/instance/instance1/submit", POST) .screwdriverIdentity(SCREWDRIVER_ID) .data(createApplicationSubmissionData(multiInstanceSpec, 123)), - "{\"error-code\":\"BAD_REQUEST\",\"message\":\"Only single-instance deployment specs are currently supported\"}", 400); + "{\"message\":\"Application package version: 1.0.4-commit1, source revision of repository 'repository1', branch 'master' with commit 'commit1', by a@b, built against 6.1 at 1970-01-01T00:00:01Z\"}"); + // GET deployment job overview, after triggering system and staging test jobs. assertEquals(2, tester.controller().applications().deploymentTrigger().triggerReadyJobs()); @@ -730,6 +734,10 @@ public class ApplicationApiTest extends ControllerContainerTest { .userIdentity(USER_ID) .oktaAccessToken(OKTA_AT).oktaIdentityToken(OKTA_IT), "{\"message\":\"Deleted instance tenant1.application1.instance1\"}"); + tester.assertResponse(request("/application/v4/tenant/tenant1/application/application1/instance/instance2", DELETE) + .userIdentity(USER_ID) + .oktaAccessToken(OKTA_AT).oktaIdentityToken(OKTA_IT), + "{\"message\":\"Deleted instance tenant1.application1.instance2\"}"); // DELETE a tenant tester.assertResponse(request("/application/v4/tenant/tenant1", DELETE).userIdentity(USER_ID) diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/jobs.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/jobs.json index 8fe38db994d..b73c36c804b 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/jobs.json +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/jobs.json @@ -3,12 +3,12 @@ "platform": { "platform": "6.1", "at": "(ignore)", - "pending": "Waiting for application change to 1.0.3-commit1 to complete" + "pending": "Waiting for application change to 1.0.4-commit1 to complete" }, "application": { "application": { - "hash": "1.0.3-commit1", - "build": 3, + "hash": "1.0.4-commit1", + "build": 4, "source": { "gitRepository": "repository1", "gitBranch": "master", @@ -21,8 +21,8 @@ }, "deploying": { "application": { - "hash": "1.0.3-commit1", - "build": 3, + "hash": "1.0.4-commit1", + "build": 4, "source": { "gitRepository": "repository1", "gitBranch": "master", @@ -43,8 +43,8 @@ "start": "(ignore)", "wantedPlatform": "6.1", "wantedApplication": { - "hash": "1.0.3-commit1", - "build": 3, + "hash": "1.0.4-commit1", + "build": 4, "source": { "gitRepository": "repository1", "gitBranch": "master", @@ -111,8 +111,8 @@ "start": "(ignore)", "wantedPlatform": "6.1", "wantedApplication": { - "hash": "1.0.3-commit1", - "build": 3, + "hash": "1.0.4-commit1", + "build": 4, "source": { "gitRepository": "repository1", "gitBranch": "master", @@ -181,8 +181,8 @@ "status": "pending", "wantedPlatform": "6.1", "wantedApplication": { - "hash": "1.0.3-commit1", - "build": 3, + "hash": "1.0.4-commit1", + "build": 4, "source": { "gitRepository": "repository1", "gitBranch": "master", diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/system-test-job.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/system-test-job.json index df55185fde5..a572fa04781 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/system-test-job.json +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/system-test-job.json @@ -39,8 +39,8 @@ "start": "(ignore)", "wantedPlatform": "6.1", "wantedApplication": { - "hash": "1.0.3-commit1", - "build": 3, + "hash": "1.0.4-commit1", + "build": 4, "source": { "gitRepository": "repository1", "gitBranch": "master", -- cgit v1.2.3