Search in sources :

Example 1 with ApplicationPackageBuilder

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

the class ApplicationApiTest method deployment_succeeds_when_correct_domain_is_used.

@Test
public void deployment_succeeds_when_correct_domain_is_used() 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("domain1"), com.yahoo.config.provision.AthenzService.from("service")).environment(Environment.prod).region("us-west-1").build();
    long screwdriverProjectId = 123;
    ScrewdriverId screwdriverId = new ScrewdriverId(Long.toString(screwdriverProjectId));
    createAthenzDomainWithAdmin(ATHENZ_TENANT_DOMAIN, USER_ID);
    Application application = controllerTester.createApplication(ATHENZ_TENANT_DOMAIN.getName(), "tenant1", "application1");
    controllerTester.authorize(ATHENZ_TENANT_DOMAIN, screwdriverId, ApplicationAction.deploy, application);
    // Allow systemtest to succeed by notifying completion of system test
    controllerTester.jobCompletion(DeploymentJobs.JobType.component).application(application.id()).projectId(screwdriverProjectId).uploadArtifact(applicationPackage).submit();
    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), new File("deploy-result.json"));
}
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) File(java.io.File) ControllerContainerTest(com.yahoo.vespa.hosted.controller.restapi.ControllerContainerTest) Test(org.junit.Test)

Example 2 with ApplicationPackageBuilder

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

the class ApplicationApiTest method testJobStatusReportingOutOfCapacity.

@Test
public void testJobStatusReportingOutOfCapacity() {
    ContainerControllerTester tester = new ContainerControllerTester(container, responseFiles);
    tester.containerTester().updateSystemVersion();
    long projectId = 1;
    Application app = tester.createApplication();
    ApplicationPackage applicationPackage = new ApplicationPackageBuilder().environment(Environment.prod).region("corp-us-east-1").build();
    // Report job failing with out of capacity
    BuildJob job = new BuildJob(report -> notifyCompletion(report, tester), tester.artifactRepository()).application(app).projectId(projectId);
    job.type(DeploymentJobs.JobType.component).uploadArtifact(applicationPackage).submit();
    tester.deploy(app, applicationPackage, TEST_ZONE, projectId);
    job.type(DeploymentJobs.JobType.systemTest).submit();
    tester.deploy(app, applicationPackage, STAGING_ZONE, projectId);
    job.type(DeploymentJobs.JobType.stagingTest).error(DeploymentJobs.JobError.outOfCapacity).submit();
    // Appropriate error is recorded
    JobStatus jobStatus = tester.controller().applications().get(app.id()).get().deploymentJobs().jobStatus().get(DeploymentJobs.JobType.stagingTest);
    assertFalse(jobStatus.isSuccess());
    assertEquals(DeploymentJobs.JobError.outOfCapacity, jobStatus.jobError().get());
}
Also used : JobStatus(com.yahoo.vespa.hosted.controller.application.JobStatus) ContainerControllerTester(com.yahoo.vespa.hosted.controller.restapi.ContainerControllerTester) ApplicationPackageBuilder(com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder) BuildJob(com.yahoo.vespa.hosted.controller.deployment.BuildJob) Application(com.yahoo.vespa.hosted.controller.Application) ApplicationPackage(com.yahoo.vespa.hosted.controller.application.ApplicationPackage) ControllerContainerTest(com.yahoo.vespa.hosted.controller.restapi.ControllerContainerTest) Test(org.junit.Test)

Example 3 with ApplicationPackageBuilder

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

the class ApplicationApiTest method testJobStatusReporting.

@Test
public void testJobStatusReporting() throws Exception {
    ContainerControllerTester tester = new ContainerControllerTester(container, responseFiles);
    addUserToHostedOperatorRole(HostedAthenzIdentities.from(HOSTED_VESPA_OPERATOR));
    tester.containerTester().updateSystemVersion();
    long projectId = 1;
    Application app = tester.createApplication();
    ApplicationPackage applicationPackage = new ApplicationPackageBuilder().environment(Environment.prod).region("corp-us-east-1").build();
    // system version from mock config server client
    Version vespaVersion = new Version("6.1");
    BuildJob job = new BuildJob(report -> notifyCompletion(report, tester), tester.artifactRepository()).application(app).projectId(projectId);
    job.type(DeploymentJobs.JobType.component).uploadArtifact(applicationPackage).submit();
    tester.deploy(app, applicationPackage, TEST_ZONE, projectId);
    job.type(DeploymentJobs.JobType.systemTest).submit();
    // Notifying about unknown job fails
    Request request = request("/application/v4/tenant/tenant1/application/application1/jobreport", POST).data(asJson(job.type(DeploymentJobs.JobType.productionUsEast3).report())).userIdentity(HOSTED_VESPA_OPERATOR).get();
    tester.containerTester().assertResponse(request, new File("jobreport-unexpected-completion.json"), 400);
    // ... and assert it was recorded
    JobStatus recordedStatus = tester.controller().applications().get(app.id()).get().deploymentJobs().jobStatus().get(DeploymentJobs.JobType.component);
    assertNotNull("Status was recorded", recordedStatus);
    assertTrue(recordedStatus.isSuccess());
    assertEquals(vespaVersion, recordedStatus.lastCompleted().get().version());
    recordedStatus = tester.controller().applications().get(app.id()).get().deploymentJobs().jobStatus().get(DeploymentJobs.JobType.productionApNortheast2);
    assertNull("Status of never-triggered jobs is empty", recordedStatus);
    Response response;
    response = container.handleRequest(request("/screwdriver/v1/jobsToRun", GET).get());
    assertTrue("Response contains system-test", response.getBodyAsString().contains(DeploymentJobs.JobType.systemTest.jobName()));
    assertTrue("Response contains staging-test", response.getBodyAsString().contains(DeploymentJobs.JobType.stagingTest.jobName()));
    assertEquals("Response contains only two items", 2, SlimeUtils.jsonToSlime(response.getBody()).get().entries());
    // Check that GET didn't affect the enqueued jobs.
    response = container.handleRequest(request("/screwdriver/v1/jobsToRun", GET).get());
    assertTrue("Response contains system-test", response.getBodyAsString().contains(DeploymentJobs.JobType.systemTest.jobName()));
    assertTrue("Response contains staging-test", response.getBodyAsString().contains(DeploymentJobs.JobType.stagingTest.jobName()));
    assertEquals("Response contains only two items", 2, SlimeUtils.jsonToSlime(response.getBody()).get().entries());
}
Also used : JobStatus(com.yahoo.vespa.hosted.controller.application.JobStatus) Response(com.yahoo.application.container.handler.Response) ContainerControllerTester(com.yahoo.vespa.hosted.controller.restapi.ContainerControllerTester) Version(com.yahoo.component.Version) Request(com.yahoo.application.container.handler.Request) ApplicationPackageBuilder(com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder) BuildJob(com.yahoo.vespa.hosted.controller.deployment.BuildJob) Application(com.yahoo.vespa.hosted.controller.Application) ApplicationPackage(com.yahoo.vespa.hosted.controller.application.ApplicationPackage) File(java.io.File) ControllerContainerTest(com.yahoo.vespa.hosted.controller.restapi.ControllerContainerTest) Test(org.junit.Test)

Example 4 with ApplicationPackageBuilder

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

the class FailureRedeployerTest method testRetriesDeploymentWithStuckJobs.

@Test
public void testRetriesDeploymentWithStuckJobs() {
    DeploymentTester tester = new DeploymentTester();
    ApplicationPackage applicationPackage = new ApplicationPackageBuilder().upgradePolicy("canary").environment(Environment.prod).region("us-east-3").build();
    Application app = tester.createApplication("app1", "tenant1", 1, 11L);
    tester.jobCompletion(component).application(app).uploadArtifact(applicationPackage).submit();
    tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.systemTest);
    // staging-test starts, but does not complete
    assertEquals(DeploymentJobs.JobType.stagingTest.jobName(), tester.deploymentQueue().takeJobsToRun().get(0).jobName());
    tester.readyJobTrigger().maintain();
    assertTrue("No jobs retried", tester.deploymentQueue().jobs().isEmpty());
    // Just over 12 hours pass, job is retried
    tester.clock().advance(Duration.ofHours(12).plus(Duration.ofSeconds(1)));
    tester.readyJobTrigger().maintain();
    assertEquals(DeploymentJobs.JobType.stagingTest.jobName(), tester.deploymentQueue().takeJobsToRun().get(0).jobName());
    // Deployment completes
    tester.deploy(DeploymentJobs.JobType.stagingTest, app, applicationPackage, true);
    tester.jobCompletion(DeploymentJobs.JobType.stagingTest).application(app).submit();
    tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.productionUsEast3);
    assertTrue("All jobs consumed", tester.deploymentQueue().jobs().isEmpty());
}
Also used : 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 5 with ApplicationPackageBuilder

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

the class ControllerTest method testDeployVersion.

@Test
public void testDeployVersion() {
    // Setup system
    DeploymentTester tester = new DeploymentTester();
    ApplicationController applications = tester.controller().applications();
    ApplicationPackage applicationPackage = new ApplicationPackageBuilder().environment(Environment.prod).region("us-west-1").build();
    Version systemVersion = tester.controller().versionStatus().systemVersion().get().versionNumber();
    Application app1 = tester.createApplication("application1", "tenant1", 1, 1L);
    // First deployment: An application change
    tester.jobCompletion(component).application(app1).uploadArtifact(applicationPackage).submit();
    tester.deployAndNotify(app1, applicationPackage, true, systemTest);
    tester.deployAndNotify(app1, applicationPackage, true, stagingTest);
    tester.deployAndNotify(app1, applicationPackage, true, productionUsWest1);
    app1 = applications.require(app1.id());
    assertEquals("First deployment gets system version", systemVersion, app1.oldestDeployedVersion().get());
    assertEquals(systemVersion, tester.configServer().lastPrepareVersion().get());
    // Unexpected deployment
    tester.deploy(productionUsWest1, app1, applicationPackage);
    // applications are immutable, so any change to one, including deployment changes, would give rise to a new instance.
    assertEquals("Unexpected deployment is ignored", app1, applications.require(app1.id()));
    // Application change after a new system version, and a region added
    Version newSystemVersion = incrementSystemVersion(tester.controller());
    assertTrue(newSystemVersion.isAfter(systemVersion));
    applicationPackage = new ApplicationPackageBuilder().environment(Environment.prod).region("us-west-1").region("us-east-3").build();
    tester.jobCompletion(component).application(app1).nextBuildNumber().uploadArtifact(applicationPackage).submit();
    tester.deployAndNotify(app1, applicationPackage, true, systemTest);
    tester.deployAndNotify(app1, applicationPackage, true, stagingTest);
    tester.deployAndNotify(app1, applicationPackage, true, productionUsWest1);
    app1 = applications.require(app1.id());
    assertEquals("Application change preserves version", systemVersion, app1.oldestDeployedVersion().get());
    assertEquals(systemVersion, tester.configServer().lastPrepareVersion().get());
    // A deployment to the new region gets the same version
    tester.deployAndNotify(app1, applicationPackage, true, productionUsEast3);
    app1 = applications.require(app1.id());
    assertEquals("Application change preserves version", systemVersion, app1.oldestDeployedVersion().get());
    assertEquals(systemVersion, tester.configServer().lastPrepareVersion().get());
    assertFalse("Change deployed", app1.change().isPresent());
    // Version upgrade changes system version
    applications.deploymentTrigger().triggerChange(app1.id(), Change.of(newSystemVersion));
    tester.deploymentTrigger().triggerReadyJobs();
    tester.deployAndNotify(app1, applicationPackage, true, systemTest);
    tester.deployAndNotify(app1, applicationPackage, true, stagingTest);
    tester.deployAndNotify(app1, applicationPackage, true, productionUsWest1);
    tester.deployAndNotify(app1, applicationPackage, true, productionUsEast3);
    app1 = applications.require(app1.id());
    assertEquals("Version upgrade changes version", newSystemVersion, app1.oldestDeployedVersion().get());
    assertEquals(newSystemVersion, tester.configServer().lastPrepareVersion().get());
}
Also used : ApplicationVersion(com.yahoo.vespa.hosted.controller.application.ApplicationVersion) VespaVersion(com.yahoo.vespa.hosted.controller.versions.VespaVersion) 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) JobType.stagingTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest) JobType.systemTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest) 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