Search in sources :

Example 6 with Application

use of com.yahoo.vespa.hosted.controller.Application in project vespa by vespa-engine.

the class DeploymentTriggerTest method testTriggerFailing.

@Test
public void testTriggerFailing() {
    DeploymentTester tester = new DeploymentTester();
    Application app = tester.createApplication("app1", "tenant1", 1, 1L);
    ApplicationPackage applicationPackage = new ApplicationPackageBuilder().upgradePolicy("default").environment(Environment.prod).region("us-west-1").build();
    Version version = new Version(5, 1);
    tester.updateVersionStatus(version);
    tester.upgrader().maintain();
    tester.readyJobTrigger().maintain();
    // Deploy completely once
    tester.jobCompletion(component).application(app).uploadArtifact(applicationPackage).submit();
    tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.systemTest);
    tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.stagingTest);
    tester.deployAndNotify(app, applicationPackage, true, JobType.productionUsWest1);
    // New version is released
    version = new Version(5, 2);
    tester.updateVersionStatus(version);
    tester.upgrader().maintain();
    tester.readyJobTrigger().maintain();
    // system-test fails and is retried
    tester.deployAndNotify(app, applicationPackage, false, JobType.systemTest);
    assertEquals("Job is retried on failure", 1, tester.deploymentQueue().jobs().size());
    tester.deployAndNotify(app, applicationPackage, true, JobType.systemTest);
    // staging-test times out and is retried
    tester.deploymentQueue().takeJobsToRun();
    tester.clock().advance(Duration.ofHours(12).plus(Duration.ofSeconds(1)));
    tester.readyJobTrigger().maintain();
    assertEquals("Retried dead job", 1, tester.deploymentQueue().jobs().size());
    assertEquals(JobType.stagingTest.jobName(), tester.deploymentQueue().jobs().get(0).jobName());
}
Also used : Version(com.yahoo.component.Version) ApplicationVersion(com.yahoo.vespa.hosted.controller.application.ApplicationVersion) Application(com.yahoo.vespa.hosted.controller.Application) LockedApplication(com.yahoo.vespa.hosted.controller.LockedApplication) ApplicationPackage(com.yahoo.vespa.hosted.controller.application.ApplicationPackage) JobType.systemTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest) Test(org.junit.Test) JobType.stagingTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest)

Example 7 with Application

use of com.yahoo.vespa.hosted.controller.Application in project vespa by vespa-engine.

the class DeploymentTriggerTest method deploymentSpecWithParallelDeployments.

@Test
public void deploymentSpecWithParallelDeployments() {
    DeploymentTester tester = new DeploymentTester();
    Application application = tester.createApplication("app1", "tenant1", 1, 1L);
    ApplicationPackage applicationPackage = new ApplicationPackageBuilder().environment(Environment.prod).region("us-central-1").parallel("us-west-1", "us-east-3").region("eu-west-1").build();
    // Component job finishes
    tester.jobCompletion(component).application(application).uploadArtifact(applicationPackage).submit();
    // Test jobs pass
    tester.deployAndNotify(application, applicationPackage, true, JobType.systemTest);
    tester.deployAndNotify(application, applicationPackage, true, JobType.stagingTest);
    // Deploys in first region
    assertEquals(1, tester.deploymentQueue().jobs().size());
    tester.deployAndNotify(application, applicationPackage, true, JobType.productionUsCentral1);
    // Deploys in two regions in parallel
    assertEquals(2, tester.deploymentQueue().jobs().size());
    assertEquals(JobType.productionUsEast3.jobName(), tester.deploymentQueue().jobs().get(0).jobName());
    assertEquals(JobType.productionUsWest1.jobName(), tester.deploymentQueue().jobs().get(1).jobName());
    tester.deploymentQueue().takeJobsToRun();
    tester.deploy(JobType.productionUsWest1, application, applicationPackage, false);
    tester.jobCompletion(JobType.productionUsWest1).application(application).submit();
    assertTrue("No more jobs triggered at this time", tester.deploymentQueue().jobs().isEmpty());
    tester.deploy(JobType.productionUsEast3, application, applicationPackage, false);
    tester.jobCompletion(JobType.productionUsEast3).application(application).submit();
    // Last region completes
    assertEquals(1, tester.deploymentQueue().jobs().size());
    tester.deployAndNotify(application, applicationPackage, true, JobType.productionEuWest1);
    assertTrue("All jobs consumed", tester.deploymentQueue().jobs().isEmpty());
}
Also used : Application(com.yahoo.vespa.hosted.controller.Application) LockedApplication(com.yahoo.vespa.hosted.controller.LockedApplication) ApplicationPackage(com.yahoo.vespa.hosted.controller.application.ApplicationPackage) JobType.systemTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest) Test(org.junit.Test) JobType.stagingTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest)

Example 8 with Application

use of com.yahoo.vespa.hosted.controller.Application in project vespa by vespa-engine.

the class DeploymentTriggerTest method deploymentsSpecWithDelays.

@Test
public void deploymentsSpecWithDelays() {
    DeploymentTester tester = new DeploymentTester();
    DeploymentQueue deploymentQueue = tester.deploymentQueue();
    Application application = tester.createApplication("app1", "tenant1", 1, 1L);
    ApplicationPackage applicationPackage = new ApplicationPackageBuilder().environment(Environment.prod).delay(Duration.ofSeconds(30)).region("us-west-1").delay(Duration.ofMinutes(1)).delay(// Multiple delays are summed up
    Duration.ofMinutes(2)).region("us-central-1").delay(// Delays after last region are valid, but have no effect
    Duration.ofMinutes(10)).build();
    // Component job finishes
    tester.jobCompletion(component).application(application).uploadArtifact(applicationPackage).submit();
    // Test jobs pass
    tester.deployAndNotify(application, applicationPackage, true, JobType.systemTest);
    // Make staging test sort as the last successful job
    tester.clock().advance(Duration.ofSeconds(1));
    tester.deployAndNotify(application, applicationPackage, true, JobType.stagingTest);
    assertTrue("No more jobs triggered at this time", deploymentQueue.jobs().isEmpty());
    // 30 seconds pass, us-west-1 is triggered
    tester.clock().advance(Duration.ofSeconds(30));
    tester.deploymentTrigger().triggerReadyJobs();
    // Consume us-west-1 job without reporting completion
    assertEquals(1, deploymentQueue.jobs().size());
    assertEquals(JobType.productionUsWest1.jobName(), deploymentQueue.jobs().get(0).jobName());
    deploymentQueue.takeJobsToRun();
    // 3 minutes pass, delayed trigger does nothing as us-west-1 is still in progress
    tester.clock().advance(Duration.ofMinutes(3));
    tester.deploymentTrigger().triggerReadyJobs();
    assertTrue("No more jobs triggered at this time", deploymentQueue.jobs().isEmpty());
    // us-west-1 completes
    tester.deploy(JobType.productionUsWest1, application, applicationPackage);
    tester.jobCompletion(JobType.productionUsWest1).application(application).submit();
    // Delayed trigger does nothing as not enough time has passed after us-west-1 completion
    tester.deploymentTrigger().triggerReadyJobs();
    assertTrue("No more jobs triggered at this time", deploymentQueue.jobs().isEmpty());
    // 3 minutes pass, us-central-1 is triggered
    tester.clock().advance(Duration.ofMinutes(3));
    tester.deploymentTrigger().triggerReadyJobs();
    tester.deployAndNotify(application, applicationPackage, true, JobType.productionUsCentral1);
    assertTrue("All jobs consumed", deploymentQueue.jobs().isEmpty());
    // Delayed trigger job runs again, with nothing to trigger
    tester.clock().advance(Duration.ofMinutes(10));
    tester.deploymentTrigger().triggerReadyJobs();
    assertTrue("All jobs consumed", deploymentQueue.jobs().isEmpty());
}
Also used : Application(com.yahoo.vespa.hosted.controller.Application) LockedApplication(com.yahoo.vespa.hosted.controller.LockedApplication) ApplicationPackage(com.yahoo.vespa.hosted.controller.application.ApplicationPackage) JobType.systemTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest) Test(org.junit.Test) JobType.stagingTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest)

Example 9 with Application

use of com.yahoo.vespa.hosted.controller.Application in project vespa by vespa-engine.

the class DeploymentTriggerTest method dualChangesAreNotSkippedWhenOnePartIsDeployedAlready.

@Test
public void dualChangesAreNotSkippedWhenOnePartIsDeployedAlready() {
    DeploymentTester tester = new DeploymentTester();
    Application application = tester.createApplication("app1", "tenant1", 1, 1L);
    Supplier<Application> app = () -> tester.application(application.id());
    ApplicationPackage applicationPackage = new ApplicationPackageBuilder().environment(Environment.prod).region("us-central-1").region("eu-west-1").build();
    tester.deployCompletely(application, applicationPackage);
    // Platform upgrade which doesn't succeed, allowing a dual change.
    Version version1 = new Version("7.1");
    tester.upgradeSystem(version1);
    tester.completeUpgradeWithError(application, version1, applicationPackage, productionEuWest1);
    // Deploy the new application version, even though the platform version is already deployed in us-central-1.
    // Let it fail in us-central-1 after deployment, so we can test this zone is later skipped.
    tester.jobCompletion(component).application(application).nextBuildNumber().uploadArtifact(applicationPackage).submit();
    tester.deployAndNotify(application, applicationPackage, true, false, systemTest);
    tester.deployAndNotify(application, applicationPackage, true, false, stagingTest);
    tester.jobCompletion(productionEuWest1).application(application).unsuccessful().submit();
    tester.deploy(productionUsCentral1, application, Optional.empty(), false);
    // Deploying before notifying here makes the job not re-trigger, but instead triggers the next job (because of triggerReadyJobs() in notification.)
    tester.deployAndNotify(application, applicationPackage, false, productionUsCentral1);
    assertEquals(ApplicationVersion.from(BuildJob.defaultSourceRevision, BuildJob.defaultBuildNumber + 1), app.get().deployments().get(ZoneId.from("prod.us-central-1")).applicationVersion());
    assertEquals(Collections.singletonList(new BuildService.BuildJob(1, productionEuWest1.jobName())), tester.deploymentQueue().jobs());
    tester.deploy(productionEuWest1, application, Optional.empty(), false);
    tester.deployAndNotify(application, Optional.empty(), false, true, productionEuWest1);
    assertFalse(app.get().change().isPresent());
    assertTrue(tester.deploymentQueue().jobs().isEmpty());
}
Also used : Version(com.yahoo.component.Version) ApplicationVersion(com.yahoo.vespa.hosted.controller.application.ApplicationVersion) Application(com.yahoo.vespa.hosted.controller.Application) LockedApplication(com.yahoo.vespa.hosted.controller.LockedApplication) ApplicationPackage(com.yahoo.vespa.hosted.controller.application.ApplicationPackage) JobType.systemTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest) Test(org.junit.Test) JobType.stagingTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest)

Example 10 with Application

use of com.yahoo.vespa.hosted.controller.Application in project vespa by vespa-engine.

the class DeploymentTriggerTest method parallelDeploymentCompletesOutOfOrder.

@Test
public void parallelDeploymentCompletesOutOfOrder() {
    DeploymentTester tester = new DeploymentTester();
    ApplicationPackage applicationPackage = new ApplicationPackageBuilder().environment(Environment.prod).parallel("us-east-3", "us-west-1").build();
    Application app = tester.createApplication("app1", "tenant1", 1, 11L);
    tester.jobCompletion(component).application(app).uploadArtifact(applicationPackage).submit();
    // Test environments pass
    tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.systemTest);
    tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.stagingTest);
    // Last declared job completes first
    tester.deploy(DeploymentJobs.JobType.productionUsWest1, app, applicationPackage);
    tester.jobCompletion(DeploymentJobs.JobType.productionUsWest1).application(app).submit();
    assertTrue("Change is present as not all jobs are complete", tester.applications().require(app.id()).change().isPresent());
    // All jobs complete
    tester.deploy(DeploymentJobs.JobType.productionUsEast3, app, applicationPackage);
    tester.jobCompletion(JobType.productionUsEast3).application(app).submit();
    assertFalse("Change has been deployed", tester.applications().require(app.id()).change().isPresent());
}
Also used : ApplicationPackage(com.yahoo.vespa.hosted.controller.application.ApplicationPackage) Application(com.yahoo.vespa.hosted.controller.Application) LockedApplication(com.yahoo.vespa.hosted.controller.LockedApplication) JobType.systemTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest) Test(org.junit.Test) JobType.stagingTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest)

Aggregations

Application (com.yahoo.vespa.hosted.controller.Application)75 Test (org.junit.Test)52 ApplicationPackage (com.yahoo.vespa.hosted.controller.application.ApplicationPackage)40 JobType.systemTest (com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest)34 Version (com.yahoo.component.Version)32 JobType.stagingTest (com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest)28 ApplicationPackageBuilder (com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder)26 DeploymentTester (com.yahoo.vespa.hosted.controller.deployment.DeploymentTester)25 Deployment (com.yahoo.vespa.hosted.controller.application.Deployment)15 VespaVersion (com.yahoo.vespa.hosted.controller.versions.VespaVersion)14 ApplicationId (com.yahoo.config.provision.ApplicationId)13 LockedApplication (com.yahoo.vespa.hosted.controller.LockedApplication)12 Slime (com.yahoo.slime.Slime)11 ControllerTester (com.yahoo.vespa.hosted.controller.ControllerTester)9 TenantId (com.yahoo.vespa.hosted.controller.api.identifiers.TenantId)8 ZoneId (com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId)8 ApplicationVersion (com.yahoo.vespa.hosted.controller.application.ApplicationVersion)8 SlimeJsonResponse (com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse)7 Cursor (com.yahoo.slime.Cursor)6 Controller (com.yahoo.vespa.hosted.controller.Controller)6