Search in sources :

Example 26 with ApplicationPackageBuilder

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

the class ApplicationApiTest method testSortsDeploymentsAndJobs.

@Test
public void testSortsDeploymentsAndJobs() throws Exception {
    // Setup
    ContainerControllerTester controllerTester = new ContainerControllerTester(container, responseFiles);
    ContainerTester tester = controllerTester.containerTester();
    tester.updateSystemVersion();
    createAthenzDomainWithAdmin(ATHENZ_TENANT_DOMAIN, USER_ID);
    // Create tenant
    tester.assertResponse(request("/application/v4/tenant/tenant1", POST).userIdentity(USER_ID).data("{\"athensDomain\":\"domain1\", \"property\":\"property1\"}").nToken(N_TOKEN), new File("tenant-without-applications.json"));
    // Create application
    tester.assertResponse(request("/application/v4/tenant/tenant1/application/application1", POST).userIdentity(USER_ID).nToken(N_TOKEN), new File("application-reference.json"));
    // Give Screwdriver project deploy access
    addScrewdriverUserToDeployRole(SCREWDRIVER_ID, ATHENZ_TENANT_DOMAIN, new com.yahoo.vespa.hosted.controller.api.identifiers.ApplicationId("application1"));
    // Deploy
    ApplicationPackage applicationPackage = new ApplicationPackageBuilder().region("us-east-3").build();
    ApplicationId id = ApplicationId.from("tenant1", "application1", "default");
    long projectId = 1;
    HttpEntity deployData = createApplicationDeployData(Optional.empty(), Optional.of(projectId));
    startAndTestChange(controllerTester, id, projectId, applicationPackage, deployData, 100);
    // us-east-3
    tester.assertResponse(request("/application/v4/tenant/tenant1/application/application1/environment/prod/region/us-east-3/instance/default/deploy", POST).data(deployData).screwdriverIdentity(SCREWDRIVER_ID), new File("deploy-result.json"));
    controllerTester.jobCompletion(DeploymentJobs.JobType.productionUsEast3).application(id).projectId(projectId).submit();
    // New zone is added before us-east-3
    applicationPackage = new ApplicationPackageBuilder().globalServiceId("foo").region("us-west-1").region("us-east-3").build();
    startAndTestChange(controllerTester, id, projectId, applicationPackage, deployData, 101);
    // us-west-1
    tester.assertResponse(request("/application/v4/tenant/tenant1/application/application1/environment/prod/region/us-west-1/instance/default/deploy", POST).data(deployData).screwdriverIdentity(SCREWDRIVER_ID), new File("deploy-result.json"));
    controllerTester.jobCompletion(DeploymentJobs.JobType.productionUsWest1).application(id).projectId(projectId).submit();
    // us-east-3
    tester.assertResponse(request("/application/v4/tenant/tenant1/application/application1/environment/prod/region/us-east-3/instance/default/deploy", POST).data(deployData).screwdriverIdentity(SCREWDRIVER_ID), new File("deploy-result.json"));
    controllerTester.jobCompletion(DeploymentJobs.JobType.productionUsEast3).application(id).projectId(projectId).submit();
    setDeploymentMaintainedInfo(controllerTester);
    tester.assertResponse(request("/application/v4/tenant/tenant1/application/application1", GET).userIdentity(USER_ID), new File("application-without-change-multiple-deployments.json"));
}
Also used : HttpEntity(org.apache.http.HttpEntity) ApplicationPackageBuilder(com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder) ContainerTester(com.yahoo.vespa.hosted.controller.restapi.ContainerTester) ApplicationPackage(com.yahoo.vespa.hosted.controller.application.ApplicationPackage) ContainerControllerTester(com.yahoo.vespa.hosted.controller.restapi.ContainerControllerTester) ApplicationId(com.yahoo.config.provision.ApplicationId) File(java.io.File) ControllerContainerTest(com.yahoo.vespa.hosted.controller.restapi.ControllerContainerTest) Test(org.junit.Test)

Example 27 with ApplicationPackageBuilder

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

the class ApplicationApiTest method deployment_fails_on_illegal_domain_in_deployment_spec.

@Test
public void deployment_fails_on_illegal_domain_in_deployment_spec() throws IOException {
    ContainerControllerTester controllerTester = new ContainerControllerTester(container, responseFiles);
    ContainerTester tester = controllerTester.containerTester();
    ApplicationPackage applicationPackage = new ApplicationPackageBuilder().upgradePolicy("default").athenzIdentity(com.yahoo.config.provision.AthenzDomain.from("invalid.domain"), com.yahoo.config.provision.AthenzService.from("service")).environment(Environment.prod).region("us-west-1").build();
    long screwdriverProjectId = 123;
    createAthenzDomainWithAdmin(ATHENZ_TENANT_DOMAIN, USER_ID);
    Application application = controllerTester.createApplication(ATHENZ_TENANT_DOMAIN.getName(), "tenant1", "application1");
    ScrewdriverId screwdriverId = new ScrewdriverId(Long.toString(screwdriverProjectId));
    controllerTester.authorize(ATHENZ_TENANT_DOMAIN, screwdriverId, ApplicationAction.deploy, application);
    tester.assertResponse(request("/application/v4/tenant/tenant1/application/application1/environment/test/region/us-east-1/instance/default/", POST).data(createApplicationDeployData(applicationPackage, Optional.of(screwdriverProjectId))).screwdriverIdentity(screwdriverId), "{\"error-code\":\"FORBIDDEN\",\"message\":\"Athenz domain in deployment.xml: [invalid.domain] must match tenant domain: [domain1]\"}", 403);
}
Also used : ContainerControllerTester(com.yahoo.vespa.hosted.controller.restapi.ContainerControllerTester) ScrewdriverId(com.yahoo.vespa.hosted.controller.api.identifiers.ScrewdriverId) ApplicationPackageBuilder(com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder) ContainerTester(com.yahoo.vespa.hosted.controller.restapi.ContainerTester) ApplicationPackage(com.yahoo.vespa.hosted.controller.application.ApplicationPackage) Application(com.yahoo.vespa.hosted.controller.Application) ControllerContainerTest(com.yahoo.vespa.hosted.controller.restapi.ControllerContainerTest) Test(org.junit.Test)

Example 28 with ApplicationPackageBuilder

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

the class FailureRedeployerTest method testRetriesJobsFailingForCurrentChange.

@Test
public void testRetriesJobsFailingForCurrentChange() {
    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, DeploymentJobs.JobType.systemTest);
    tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.stagingTest);
    tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.productionUsEast3);
    // 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();
    assertEquals("Application has pending upgrade to " + version, version, tester.application(app.id()).change().platform().get());
    // system-test fails and is left with a retry
    tester.deployAndNotify(app, applicationPackage, false, DeploymentJobs.JobType.systemTest);
    // Another version is released
    version = Version.fromString("5.2");
    tester.updateVersionStatus(version);
    assertEquals(version, tester.controller().versionStatus().systemVersion().get().versionNumber());
    // Job is left "running", so needs to time out before it can be retried.
    tester.clock().advance(Duration.ofHours(13));
    tester.upgrader().maintain();
    tester.readyJobTrigger().maintain();
    assertEquals("Application has pending upgrade to " + version, version, tester.application(app.id()).change().platform().get());
    // Cancellation of outdated version and triggering on a new version is done by the upgrader.
    assertEquals(version, tester.application(app.id()).deploymentJobs().jobStatus().get(systemTest).lastTriggered().get().version());
}
Also used : Version(com.yahoo.component.Version) DeploymentTester(com.yahoo.vespa.hosted.controller.deployment.DeploymentTester) ApplicationPackageBuilder(com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder) ApplicationPackage(com.yahoo.vespa.hosted.controller.application.ApplicationPackage) Application(com.yahoo.vespa.hosted.controller.Application) Test(org.junit.Test) JobType.systemTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest)

Example 29 with ApplicationPackageBuilder

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

the class FailureRedeployerTest method testRetryingFailedJobsDuringDeployment.

@Test
public void testRetryingFailedJobsDuringDeployment() {
    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, DeploymentJobs.JobType.systemTest);
    tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.stagingTest);
    tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.productionUsEast3);
    // 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();
    // Test environments pass
    tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.systemTest);
    tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.stagingTest);
    // Production job fails and is retried
    // Advance time so that we can detect jobs in progress
    tester.clock().advance(Duration.ofSeconds(1));
    tester.deployAndNotify(app, applicationPackage, false, DeploymentJobs.JobType.productionUsEast3);
    assertEquals("Production job is retried", 1, tester.deploymentQueue().jobs().size());
    assertEquals("Application has pending upgrade to " + version, version, tester.application(app.id()).change().platform().get());
    // Another version is released, which cancels any pending upgrades to lower versions
    version = Version.fromString("5.2");
    tester.updateVersionStatus(version);
    tester.upgrader().maintain();
    tester.readyJobTrigger().maintain();
    assertEquals("Application starts upgrading to new version", 1, tester.deploymentQueue().jobs().size());
    assertEquals("Application has pending upgrade to " + version, version, tester.application(app.id()).change().platform().get());
    // Failure re-deployer does not retry failing job for prod.us-east-3, since it no longer has an available change
    tester.clock().advance(Duration.ofMinutes(1));
    tester.jobCompletion(DeploymentJobs.JobType.productionUsEast3).application(app).unsuccessful().submit();
    assertFalse("Job is not retried", tester.deploymentQueue().jobs().stream().anyMatch(j -> j.jobName().equals(DeploymentJobs.JobType.productionUsEast3.jobName())));
    // Test environments pass
    tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.systemTest);
    tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.stagingTest);
    // Production job fails again, and is retried
    tester.deployAndNotify(app, applicationPackage, false, DeploymentJobs.JobType.productionUsEast3);
    tester.readyJobTrigger().maintain();
    assertEquals("Job is retried", Collections.singletonList(new BuildService.BuildJob(app.deploymentJobs().projectId().get(), productionUsEast3.jobName())), tester.deploymentQueue().jobs());
    // Production job finally succeeds
    tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.productionUsEast3);
    assertTrue("All jobs consumed", tester.deploymentQueue().jobs().isEmpty());
    assertFalse("No failures", tester.application(app.id()).deploymentJobs().hasFailures());
}
Also used : Collection(com.yahoo.log.event.Collection) Version(com.yahoo.component.Version) Files(java.nio.file.Files) Environment(com.yahoo.config.provision.Environment) Slime(com.yahoo.slime.Slime) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) DeploymentJobs(com.yahoo.vespa.hosted.controller.application.DeploymentJobs) ApplicationPackage(com.yahoo.vespa.hosted.controller.application.ApplicationPackage) ApplicationPackageBuilder(com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder) JobType.systemTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest) ZoneId(com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId) SlimeUtils(com.yahoo.vespa.config.SlimeUtils) Paths(java.nio.file.Paths) Assert.assertFalse(org.junit.Assert.assertFalse) Duration(java.time.Duration) SystemName(com.yahoo.config.provision.SystemName) BuildService(com.yahoo.vespa.hosted.controller.api.integration.BuildService) JobType.productionUsEast3(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.productionUsEast3) Collections(java.util.Collections) JobType.component(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.component) Application(com.yahoo.vespa.hosted.controller.Application) Assert.assertEquals(org.junit.Assert.assertEquals) DeploymentTester(com.yahoo.vespa.hosted.controller.deployment.DeploymentTester) Version(com.yahoo.component.Version) DeploymentTester(com.yahoo.vespa.hosted.controller.deployment.DeploymentTester) ApplicationPackageBuilder(com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder) ApplicationPackage(com.yahoo.vespa.hosted.controller.application.ApplicationPackage) Application(com.yahoo.vespa.hosted.controller.Application) Test(org.junit.Test) JobType.systemTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest)

Example 30 with ApplicationPackageBuilder

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

the class RotationTest method application_with_only_one_non_corp_region.

@Test
public void application_with_only_one_non_corp_region() {
    ApplicationPackage applicationPackage = new ApplicationPackageBuilder().globalServiceId("foo").region("us-east-3").region("corp-us-east-1").build();
    Application application = tester.createApplication("app2", "tenant2", 22L, 2L);
    thrown.expect(RuntimeException.class);
    thrown.expectMessage("less than 2 prod zones are defined");
    tester.deployCompletely(application, applicationPackage);
}
Also used : ApplicationPackageBuilder(com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder) ApplicationPackage(com.yahoo.vespa.hosted.controller.application.ApplicationPackage) Application(com.yahoo.vespa.hosted.controller.Application) Test(org.junit.Test)

Aggregations

ApplicationPackage (com.yahoo.vespa.hosted.controller.application.ApplicationPackage)33 ApplicationPackageBuilder (com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder)33 Test (org.junit.Test)33 Application (com.yahoo.vespa.hosted.controller.Application)25 DeploymentTester (com.yahoo.vespa.hosted.controller.deployment.DeploymentTester)21 JobType.systemTest (com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest)20 Version (com.yahoo.component.Version)16 JobType.stagingTest (com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest)15 VespaVersion (com.yahoo.vespa.hosted.controller.versions.VespaVersion)10 ContainerControllerTester (com.yahoo.vespa.hosted.controller.restapi.ContainerControllerTester)6 ControllerContainerTest (com.yahoo.vespa.hosted.controller.restapi.ControllerContainerTest)6 ApplicationVersion (com.yahoo.vespa.hosted.controller.application.ApplicationVersion)4 JobStatus (com.yahoo.vespa.hosted.controller.application.JobStatus)4 ManualClock (com.yahoo.test.ManualClock)3 ControllerTester (com.yahoo.vespa.hosted.controller.ControllerTester)3 ScrewdriverId (com.yahoo.vespa.hosted.controller.api.identifiers.ScrewdriverId)3 Record (com.yahoo.vespa.hosted.controller.api.integration.dns.Record)3 ZoneId (com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId)3 ContainerTester (com.yahoo.vespa.hosted.controller.restapi.ContainerTester)3 File (java.io.File)3