diff options
author | Jon Marius Venstad <venstad@gmail.com> | 2020-09-07 15:23:31 +0200 |
---|---|---|
committer | Jon Marius Venstad <venstad@gmail.com> | 2020-09-07 15:23:31 +0200 |
commit | 00df3856b08614fcf9636879bb91467a83da0228 (patch) | |
tree | 37a565e690ca46f3f543d3428dce1cc7aa7ce2bd | |
parent | debdcd3c849703dcd0f3269c664319669277b527 (diff) |
Assume ongoing upgrade will succeed when computing eager test parameters
3 files changed, 61 insertions, 11 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentStatus.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentStatus.java index 2cf6c7e8670..a188ca9abc3 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentStatus.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentStatus.java @@ -140,8 +140,8 @@ public class DeploymentStatus { // Add test jobs for any outstanding change. for (InstanceName instance : application.deploymentSpec().instanceNames()) changes.put(instance, outstandingChange(instance).onTopOf(application.require(instance).change())); - var testJobs = jobsToRun(changes).entrySet().stream() - .filter(entry -> ! entry.getKey().type().isProduction()); + var testJobs = jobsToRun(changes, true).entrySet().stream() + .filter(entry -> ! entry.getKey().type().isProduction()); return Stream.concat(jobs.entrySet().stream(), testJobs) .collect(collectingAndThen(toMap(Map.Entry::getKey, @@ -151,10 +151,9 @@ public class DeploymentStatus { ImmutableMap::copyOf)); } - /** The set of jobs that need to run for the given changes to be considered complete. */ - public Map<JobId, List<Versions>> jobsToRun(Map<InstanceName, Change> changes) { + private Map<JobId, List<Versions>> jobsToRun(Map<InstanceName, Change> changes, boolean eagerTests) { Map<JobId, Versions> productionJobs = new LinkedHashMap<>(); - changes.forEach((instance, change) -> productionJobs.putAll(productionJobs(instance, change))); + changes.forEach((instance, change) -> productionJobs.putAll(productionJobs(instance, change, eagerTests))); Map<JobId, List<Versions>> testJobs = testJobs(productionJobs); Map<JobId, List<Versions>> jobs = new LinkedHashMap<>(testJobs); productionJobs.forEach((job, versions) -> jobs.put(job, List.of(versions))); @@ -174,11 +173,16 @@ public class DeploymentStatus { Versions versions = Versions.from(change, application, firstProductionJobWithDeployment.flatMap(this::deploymentFor), systemVersion); if (step.completedAt(change, firstProductionJobWithDeployment).isEmpty()) - jobs.merge(job, List.of(versions), DeploymentStatus::union); + jobs.merge(job, List.of(versions), DeploymentStatus::union); }); return ImmutableMap.copyOf(jobs); } + /** The set of jobs that need to run for the given changes to be considered complete. */ + public Map<JobId, List<Versions>> jobsToRun(Map<InstanceName, Change> changes) { + return jobsToRun(changes, false); + } + /** The step status for all steps in the deployment spec of this, which are jobs, in the same order as in the deployment spec. */ public Map<JobId, StepStatus> jobSteps() { return jobSteps; } @@ -223,18 +227,31 @@ public class DeploymentStatus { .successOn(versions).isEmpty()); } - /** The production jobs that need to run to complete roll-out of the given change to production. */ - public Map<JobId, Versions> productionJobs(InstanceName instance, Change change) { + private Map<JobId, Versions> productionJobs(InstanceName instance, Change change, boolean assumeUpgradesSucceed) { ImmutableMap.Builder<JobId, Versions> jobs = ImmutableMap.builder(); jobSteps.forEach((job, step) -> { + // When computing eager test jobs for outstanding changes, assume current upgrade completes successfully. + Optional<Deployment> deployment = deploymentFor(job) + .map(existing -> assumeUpgradesSucceed ? new Deployment(existing.zone(), + existing.applicationVersion(), + change.platform().orElse(existing.version()), + existing.at(), + existing.metrics(), + existing.activity()) + : existing); if ( job.application().instance().equals(instance) && job.type().isProduction() && step.completedAt(change).isEmpty()) - jobs.put(job, Versions.from(change, application, deploymentFor(job), systemVersion)); + jobs.put(job, Versions.from(change, application, deployment, systemVersion)); }); return jobs.build(); } + /** The production jobs that need to run to complete roll-out of the given change to production. */ + public Map<JobId, Versions> productionJobs(InstanceName instance, Change change) { + return productionJobs(instance, change, false); + } + /** The test jobs that need to run prior to the given production deployment jobs. */ public Map<JobId, List<Versions>> testJobs(Map<JobId, Versions> jobs) { Map<JobId, List<Versions>> testJobs = new LinkedHashMap<>(); 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 6417119618b..dd5e6edb5b8 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 @@ -1172,4 +1172,37 @@ public class DeploymentTriggerTest { } + @Test + public void testEagerTests() { + var app = tester.newDeploymentContext().submit().deploy(); + + // Start upgrade, then receive new submission. + Version version1 = new Version("7.8.9"); + ApplicationVersion build1 = app.lastSubmission().get(); + tester.controllerTester().upgradeSystem(version1); + tester.upgrader().maintain(); + app.runJob(stagingTest); + app.submit(); + ApplicationVersion build2 = app.lastSubmission().get(); + assertNotEquals(build1, build2); + + // App now free to start system tests eagerly, for new submission. These should run assuming upgrade succeeds. + tester.outstandingChangeDeployer().run(); + tester.triggerJobs(); + app.assertRunning(stagingTest); + assertEquals(version1, + app.instanceJobs().get(stagingTest).lastCompleted().get().versions().targetPlatform()); + assertEquals(build1, + app.instanceJobs().get(stagingTest).lastCompleted().get().versions().targetApplication()); + + assertEquals(version1, + app.instanceJobs().get(stagingTest).lastTriggered().get().versions().sourcePlatform().get()); + assertEquals(build1, + app.instanceJobs().get(stagingTest).lastTriggered().get().versions().sourceApplication().get()); + assertEquals(version1, + app.instanceJobs().get(stagingTest).lastTriggered().get().versions().targetPlatform()); + assertEquals(build2, + app.instanceJobs().get(stagingTest).lastTriggered().get().versions().targetApplication()); + } + } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/responses/root.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/responses/root.json index d0d79903da5..c5286d4a04b 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/responses/root.json +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/responses/root.json @@ -273,11 +273,11 @@ { "name": "system-test", "coolingDownUntil": "(ignore)", - "pending": "platform" + "pending": "application" }, { "name": "staging-test", - "pending": "platform" + "pending": "application" }, { "name": "production-us-west-1", |