use of com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder in project vespa by vespa-engine.
the class UpgraderTest method testBlockVersionChangeHalfwayThoughThenNewVersion.
/**
* Tests the scenario where a release is deployed to 2 of 3 production zones, then blocked,
* followed by timeout of the upgrade and a new release.
* In this case, the blocked production zone should not progress with upgrading to the previous version,
* and should not upgrade to the new version until the other production zones have it
* (expected behavior; both requirements are debatable).
*/
@Test
public void testBlockVersionChangeHalfwayThoughThenNewVersion() {
// Friday, 16:00
ManualClock clock = new ManualClock(Instant.parse("2017-09-29T16:00:00.00Z"));
DeploymentTester tester = new DeploymentTester(new ControllerTester(clock));
Version version = Version.fromString("5.0");
tester.updateVersionStatus(version);
ApplicationPackage applicationPackage = new ApplicationPackageBuilder().upgradePolicy("canary").blockChange(false, true, "mon-fri", "00-09,17-23", "UTC").blockChange(false, true, "sat-sun", "00-23", "UTC").region("us-west-1").region("us-central-1").region("us-east-3").build();
Application app = tester.createAndDeploy("app1", 1, applicationPackage);
// New version is released
version = Version.fromString("5.1");
tester.updateVersionStatus(version);
// Application upgrade starts
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
tester.deployAndNotify(app, applicationPackage, true, systemTest);
tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.stagingTest);
tester.deployAndNotify(app, applicationPackage, true, productionUsWest1);
// Entering block window after prod job is triggered
clock.advance(Duration.ofHours(1));
tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.productionUsCentral1);
// Next job not triggered due to being in the block window
assertTrue(tester.deploymentQueue().jobs().isEmpty());
// A day passes and we get a new version
tester.clock().advance(Duration.ofDays(1));
version = Version.fromString("5.2");
tester.updateVersionStatus(version);
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
assertTrue("Nothing is scheduled", tester.deploymentQueue().jobs().isEmpty());
// Monday morning: We are not blocked
// Sunday, 17:00
tester.clock().advance(Duration.ofDays(1));
// Monday, 10:00
tester.clock().advance(Duration.ofHours(17));
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
// We proceed with the new version in the expected order, not starting with the previously blocked version:
// Test jobs are run with the new version, but not production as we are in the block window
tester.deployAndNotify(app, applicationPackage, true, systemTest);
tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.stagingTest);
tester.deployAndNotify(app, applicationPackage, true, productionUsWest1);
tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.productionUsCentral1);
tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.productionUsEast3);
assertTrue("All jobs consumed", tester.deploymentQueue().jobs().isEmpty());
// App is completely upgraded to the latest version
for (Deployment deployment : tester.applications().require(app.id()).deployments().values()) assertEquals(version, deployment.version());
}
use of com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder in project vespa by vespa-engine.
the class UpgraderTest method testDeploymentAlreadyInProgressForUpgrade.
@Test
public void testDeploymentAlreadyInProgressForUpgrade() {
DeploymentTester tester = new DeploymentTester();
ApplicationPackage applicationPackage = new ApplicationPackageBuilder().upgradePolicy("canary").environment(Environment.prod).region("us-east-3").build();
Version version = Version.fromString("5.0");
tester.updateVersionStatus(version);
Application app = tester.createApplication("app1", "tenant1", 1, 11L);
tester.jobCompletion(component).application(app).uploadArtifact(applicationPackage).submit();
tester.deployAndNotify(app, applicationPackage, true, systemTest);
tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.stagingTest);
tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.productionUsEast3);
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
assertEquals("Application is on expected version: Nothing to do", 0, tester.deploymentQueue().jobs().size());
// New version is released
version = Version.fromString("5.1");
tester.updateVersionStatus(version);
assertEquals(version, tester.controller().versionStatus().systemVersion().get().versionNumber());
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
// system-test completes successfully
tester.deployAndNotify(app, applicationPackage, true, systemTest);
// staging-test fails and failure is recorded
tester.deployAndNotify(app, applicationPackage, false, DeploymentJobs.JobType.stagingTest);
assertTrue("Failure is recorded", tester.application(app.id()).deploymentJobs().hasFailures());
assertTrue("Application has pending change", tester.application(app.id()).change().isPresent());
// New version is released
version = Version.fromString("5.2");
tester.updateVersionStatus(version);
assertEquals(version, tester.controller().versionStatus().systemVersion().get().versionNumber());
// Upgrade is scheduled. system-tests starts, but does not complete
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
assertTrue("Application still has failures", tester.application(app.id()).deploymentJobs().hasFailures());
assertEquals(1, tester.deploymentQueue().jobs().size());
tester.deploymentQueue().takeJobsToRun();
// Upgrader runs again, nothing happens as there's already a job in progress for this change
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
assertTrue("No more jobs triggered at this time", tester.deploymentQueue().jobs().isEmpty());
}
use of com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder in project vespa by vespa-engine.
the class DeploymentExpirerTest method testDeploymentExpiry.
@Test
public void testDeploymentExpiry() {
tester.controllerTester().zoneRegistry().setDeploymentTimeToLive(ZoneId.from(Environment.dev, RegionName.from("us-east-1")), Duration.ofDays(14));
DeploymentExpirer expirer = new DeploymentExpirer(tester.controller(), Duration.ofDays(10), tester.clock(), new JobControl(new MockCuratorDb()));
Application devApp = tester.createApplication("app1", "tenant1", 123L, 1L);
Application prodApp = tester.createApplication("app2", "tenant2", 456L, 2L);
// Deploy dev
tester.controllerTester().deploy(devApp, tester.controllerTester().toZone(Environment.dev));
// Deploy prod
ApplicationPackage prodAppPackage = new ApplicationPackageBuilder().region("us-west-1").build();
tester.deployCompletely(prodApp, prodAppPackage);
assertEquals(1, permanentDeployments(devApp).size());
assertEquals(1, permanentDeployments(prodApp).size());
// Not expired at first
expirer.maintain();
assertEquals(1, permanentDeployments(devApp).size());
assertEquals(1, permanentDeployments(prodApp).size());
// The dev application is removed
tester.clock().advance(Duration.ofDays(15));
expirer.maintain();
assertEquals(0, permanentDeployments(devApp).size());
assertEquals(1, permanentDeployments(prodApp).size());
}
use of com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder in project vespa by vespa-engine.
the class OutstandingChangeDeployerTest method testChangeDeployer.
@Test
public void testChangeDeployer() {
DeploymentTester tester = new DeploymentTester();
tester.configServer().setDefaultVersion(new Version(6, 1));
OutstandingChangeDeployer deployer = new OutstandingChangeDeployer(tester.controller(), Duration.ofMinutes(10), new JobControl(new MockCuratorDb()));
ApplicationPackage applicationPackage = new ApplicationPackageBuilder().environment(Environment.prod).region("us-west-1").build();
tester.createAndDeploy("app1", 11, applicationPackage);
tester.createAndDeploy("app2", 22, applicationPackage);
Version version = new Version(6, 2);
tester.deploymentTrigger().triggerChange(tester.application("app1").id(), Change.of(version));
tester.deploymentTrigger().triggerReadyJobs();
assertEquals(Change.of(version), tester.application("app1").change());
assertFalse(tester.application("app1").outstandingChange().isPresent());
tester.jobCompletion(DeploymentJobs.JobType.component).application(tester.application("app1")).sourceRevision(new SourceRevision("repository1", "master", "cafed00d")).nextBuildNumber().uploadArtifact(applicationPackage).submit();
Application app = tester.application("app1");
assertTrue(app.outstandingChange().isPresent());
assertEquals("1.0.43-cafed00d", app.outstandingChange().application().get().id());
assertEquals(1, tester.deploymentQueue().jobs().size());
deployer.maintain();
tester.deploymentTrigger().triggerReadyJobs();
assertEquals("No effect as job is in progress", 1, tester.deploymentQueue().jobs().size());
assertEquals("1.0.43-cafed00d", app.outstandingChange().application().get().id());
tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.systemTest);
tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.stagingTest);
tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.productionUsWest1);
assertEquals("Upgrade done", 0, tester.deploymentQueue().jobs().size());
deployer.maintain();
tester.deploymentTrigger().triggerReadyJobs();
app = tester.application("app1");
assertEquals("1.0.43-cafed00d", app.change().application().get().id());
List<BuildService.BuildJob> jobs = tester.deploymentQueue().jobs();
assertEquals(1, jobs.size());
assertEquals(11, jobs.get(0).projectId());
assertEquals(DeploymentJobs.JobType.systemTest.jobName(), jobs.get(0).jobName());
assertFalse(tester.application("app1").outstandingChange().isPresent());
}
use of com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder in project vespa by vespa-engine.
the class DeploymentApiTest method testDeploymentApi.
@Test
public void testDeploymentApi() throws IOException {
ContainerControllerTester tester = new ContainerControllerTester(container, responseFiles);
Version version = Version.fromString("5.0");
tester.containerTester().updateSystemVersion(version);
long projectId = 11;
ApplicationPackage applicationPackage = new ApplicationPackageBuilder().environment(Environment.prod).region("corp-us-east-1").build();
// 3 applications deploy on current system version
Application failingApplication = tester.createApplication("domain1", "tenant1", "application1");
Application productionApplication = tester.createApplication("domain2", "tenant2", "application2");
Application applicationWithoutDeployment = tester.createApplication("domain3", "tenant3", "application3");
deployCompletely(failingApplication, applicationPackage, projectId, true);
deployCompletely(productionApplication, applicationPackage, projectId, true);
// Deploy once so that job information is stored, then remove the deployment
deployCompletely(applicationWithoutDeployment, applicationPackage, projectId, true);
tester.controller().applications().deactivate(applicationWithoutDeployment, ZoneId.from("prod", "corp-us-east-1"));
// New version released
version = Version.fromString("5.1");
tester.containerTester().updateSystemVersion(version);
// Applications upgrade, 1/2 succeed
tester.upgrader().maintain();
tester.controller().applications().deploymentTrigger().triggerReadyJobs();
deployCompletely(failingApplication, applicationPackage, projectId, false);
deployCompletely(productionApplication, applicationPackage, projectId, true);
tester.controller().updateVersionStatus(censorConfigServers(VersionStatus.compute(tester.controller()), tester.controller()));
tester.assertResponse(authenticatedRequest("http://localhost:8080/deployment/v1/"), new File("root.json"));
}
Aggregations