diff options
author | Jon Marius Venstad <venstad@gmail.com> | 2019-10-09 11:31:03 +0200 |
---|---|---|
committer | Jon Marius Venstad <venstad@gmail.com> | 2019-10-09 13:42:32 +0200 |
commit | b8ede085e24ebb386e490966ceb89d6ce3203cbd (patch) | |
tree | 23a33f63630330d65f9ba079251152a9c30717c4 /controller-server | |
parent | 107cd3e50151f10c1fa20050d6d04255324f5e61 (diff) |
Support arbitrary application in InternalDeploymentTester
Diffstat (limited to 'controller-server')
2 files changed, 49 insertions, 24 deletions
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalDeploymentTester.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalDeploymentTester.java index 5b5eaa60ce9..912b75b9e36 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalDeploymentTester.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalDeploymentTester.java @@ -122,12 +122,22 @@ public class InternalDeploymentTester { domain.services.put(ATHENZ_SERVICE, new AthenzDbMock.Service(true)); } + /** Submits a new application, and returns the version of the new submission. */ + public ApplicationVersion newSubmission(TenantAndApplicationId id, ApplicationPackage applicationPackage, + SourceRevision revision, String authorEmail, long projectId) { + return jobs.submit(id, revision, authorEmail, projectId, applicationPackage, new byte[0]); + } + + /** Submits a new application, and returns the version of the new submission. */ + public ApplicationVersion newSubmission(TenantAndApplicationId id, ApplicationPackage applicationPackage) { + return newSubmission(id, applicationPackage, BuildJob.defaultSourceRevision, "a@b", 2); + } + /** * Submits a new application, and returns the version of the new submission. */ public ApplicationVersion newSubmission() { - return jobs.submit(appId, BuildJob.defaultSourceRevision, "a@b", 2, - tester.controller().system().isPublic() ? publicCdApplicationPackage : applicationPackage, new byte[0]); + return newSubmission(appId, tester.controller().system().isPublic() ? publicCdApplicationPackage : applicationPackage); } /** @@ -151,11 +161,11 @@ public class InternalDeploymentTester { } /** Runs and returns all remaining jobs for the application, at most once, and asserts the current change is rolled out. */ - public List<JobType> completeRollout() { + public List<JobType> completeRollout(TenantAndApplicationId id) { tester.readyJobTrigger().run(); Set<JobType> jobs = new HashSet<>(); List<Run> activeRuns; - while ( ! (activeRuns = jobs().active(appId)).isEmpty()) + while ( ! (activeRuns = jobs().active(id)).isEmpty()) for (Run run : activeRuns) if (jobs.add(run.id().type())) { runJob(run.id().type()); @@ -170,34 +180,45 @@ public class InternalDeploymentTester { /** Completely deploys the given application version, assuming it is the last to be submitted. */ public void deployNewSubmission(ApplicationVersion version) { - assertFalse(instance().deployments().values().stream() - .anyMatch(deployment -> deployment.applicationVersion().equals(version))); - assertEquals(version, application().change().application().get()); - assertFalse(application().change().platform().isPresent()); - completeRollout(); + deployNewSubmission(appId, version); } - /** - * Completely deploys the given, new platform. - */ + /** Completely deploys the given application version, assuming it is the last to be submitted. */ + public void deployNewSubmission(TenantAndApplicationId id, ApplicationVersion version) { + assertFalse(tester.application(id).instances().values().stream() + .anyMatch(instance -> instance.deployments().values().stream() + .anyMatch(deployment -> deployment.applicationVersion().equals(version)))); + assertEquals(version, tester.application(id).change().application().get()); + assertFalse(tester.application(id).change().platform().isPresent()); + completeRollout(id); + } + + /** Completely deploys the given, new platform. */ public void deployNewPlatform(Version version) { - tester.upgradeSystem(version); - assertFalse(instance().deployments().values().stream() - .anyMatch(deployment -> deployment.version().equals(version))); - assertEquals(version, application().change().platform().get()); - assertFalse(application().change().application().isPresent()); + deployNewPlatform(appId, version); + } + + /** Completely deploys the given, new platform. */ + public void deployNewPlatform(TenantAndApplicationId id, Version version) { + assertEquals(tester.controller().systemVersion(), version); + assertFalse(tester.application(id).instances().values().stream() + .anyMatch(instance -> instance.deployments().values().stream() + .anyMatch(deployment -> deployment.version().equals(version)))); + assertEquals(version, tester.application(id).change().platform().get()); + assertFalse(tester.application(id).change().application().isPresent()); - completeRollout(); + completeRollout(id); - assertTrue(instance().productionDeployments().values().stream() - .allMatch(deployment -> deployment.version().equals(version))); + assertTrue(tester.application(id).productionDeployments().values().stream() + .allMatch(deployments -> deployments.stream() + .allMatch(deployment -> deployment.version().equals(version)))); for (JobType type : new DeploymentSteps(application().deploymentSpec(), tester.controller()::system).productionJobs()) assertTrue(tester.configServer().nodeRepository() - .list(type.zone(tester.controller().system()), instanceId).stream() + .list(type.zone(tester.controller().system()), id.defaultInstance()).stream() // TODO jonmv: support more .allMatch(node -> node.currentVersion().equals(version))); - assertFalse(application().change().hasTargets()); + assertFalse(tester.application(id).change().hasTargets()); } /** diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunnerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunnerTest.java index eed685cc20a..0188bb0e5ae 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunnerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunnerTest.java @@ -85,7 +85,9 @@ public class InternalStepRunnerTest { public void canRegisterAndRunDirectly() { tester.deployNewSubmission(tester.newSubmission()); - tester.deployNewPlatform(new Version("7.1")); + Version version = new Version("7.1"); + tester.tester().upgradeSystem(version); + tester.deployNewPlatform(version); } @Test @@ -103,7 +105,9 @@ public class InternalStepRunnerTest { tester.deployNewSubmission(tester.newSubmission()); tester.deployNewSubmission(tester.newSubmission()); - tester.deployNewPlatform(new Version("7.2")); + Version version = new Version("7.2"); + tester.tester().upgradeSystem(version); + tester.deployNewPlatform(version); tester.jobs().unregister(appId); try { |