DeploymentTrigger { private ApplicationController applications() { return controller.applications(); } DeploymentTrigger(Controller controller, Clock clock); DeploymentSteps steps(DeploymentInstanceSpec spec); void notifyOfSubmission(TenantAndApplicationId id, ApplicationVersion version, long projectId); void triggerNewRevision(TenantAndApplicationId id); void notifyOfCompletion(ApplicationId id); long triggerReadyJobs(); void trigger(Job job); JobId reTrigger(ApplicationId applicationId, JobType jobType); List<JobId> forceTrigger(ApplicationId applicationId, JobType jobType, String user, boolean requireTests); void pauseJob(ApplicationId id, JobType jobType, Instant until); void resumeJob(ApplicationId id, JobType jobType); void triggerChange(ApplicationId instanceId, Change change); void forceChange(ApplicationId instanceId, Change change); void cancelChange(ApplicationId instanceId, ChangesToCancel cancellation); boolean triggerAt(Instant instant, JobType job, JobStatus jobStatus, Versions versions, Instance instance, DeploymentSpec deploymentSpec); boolean isComplete(Change change, Change fullChange, Instance instance, JobType jobType,
                              JobStatus status); static final Duration maxPause; }
@Test public void testTriggerFailing() { ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .upgradePolicy("default") .environment(Environment.prod) .region("us-west-1") .build(); var app = tester.newDeploymentContext().submit(applicationPackage).deploy(); Version version = Version.fromString("6.3"); tester.controllerTester().upgradeSystem(version); tester.upgrader().maintain(); app.failDeployment(stagingTest); tester.triggerJobs(); assertEquals("Retried dead job", 2, tester.jobs().active().size()); app.assertRunning(stagingTest); app.runJob(stagingTest); app.assertRunning(systemTest); assertEquals(1, tester.jobs().active().size()); app.timeOutUpgrade(systemTest); tester.triggerJobs(); assertEquals("Job is retried on failure", 1, tester.jobs().active().size()); app.runJob(systemTest); tester.triggerJobs(); app.assertRunning(productionUsWest1); tester.applications().lockApplicationOrThrow(app.application().id(), locked -> tester.applications().store(locked.withProjectId(OptionalLong.empty()))); app.timeOutConvergence(productionUsWest1); tester.triggerJobs(); assertEquals("Job is not triggered when no projectId is present", 0, tester.jobs().active().size()); }
@Test public void testPlatformVersionSelection() { ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) .region("us-west-1") .build(); Version version1 = tester.controller().versionStatus().systemVersion().get().versionNumber(); var app1 = tester.newDeploymentContext(); app1.submit(applicationPackage).deploy(); assertEquals("First deployment gets system version", version1, app1.application().oldestDeployedPlatform().get()); assertEquals(version1, tester.configServer().lastPrepareVersion().get()); Version version2 = new Version(version1.getMajor(), version1.getMinor() + 1); tester.applications().deploy(app1.instanceId(), ZoneId.from("prod", "us-west-1"), Optional.empty(), new DeployOptions(false, Optional.of(version2), false, false)); assertEquals(version1, app1.deployment(ZoneId.from("prod", "us-west-1")).version()); tester.controllerTester().upgradeSystem(version2); applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) .region("us-west-1") .region("us-east-3") .build(); app1.submit(applicationPackage).deploy(); assertEquals("Application change preserves version, and new region gets oldest version too", version1, app1.application().oldestDeployedPlatform().get()); assertEquals(version1, tester.configServer().lastPrepareVersion().get()); assertFalse("Change deployed", app1.instance().change().hasTargets()); tester.upgrader().maintain(); app1.deployPlatform(version2); assertEquals("Version upgrade changes version", version2, app1.application().oldestDeployedPlatform().get()); assertEquals(version2, tester.configServer().lastPrepareVersion().get()); }
@Test public void testUserInstancesNotInDeploymentSpec() { var app = tester.newDeploymentContext(); tester.controller().applications().createInstance(app.application().id().instance("user")); app.submit().deploy(); }