Search in sources :

Example 1 with DeploymentQueue

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

the class ScrewdriverApiTest method testTriggerJobForApplication.

@Test
public void testTriggerJobForApplication() {
    ContainerControllerTester tester = new ContainerControllerTester(container, responseFiles);
    DeploymentQueue deploymentQueue = tester.controller().applications().deploymentTrigger().deploymentQueue();
    tester.containerTester().updateSystemVersion();
    Application app = tester.createApplication();
    tester.controller().applications().lockOrThrow(app.id(), application -> tester.controller().applications().store(application.withProjectId(1)));
    // Unknown application
    assertResponse(new Request("http://localhost:8080/screwdriver/v1/trigger/tenant/foo/application/bar", new byte[0], Request.Method.POST), 400, "{\"error-code\":\"BAD_REQUEST\",\"message\":\"foo.bar not found\"}");
    // Invalid job
    assertResponse(new Request("http://localhost:8080/screwdriver/v1/trigger/tenant/" + app.id().tenant().value() + "/application/" + app.id().application().value(), "invalid".getBytes(StandardCharsets.UTF_8), Request.Method.POST), 400, "{\"error-code\":\"BAD_REQUEST\",\"message\":\"Unknown job name 'invalid'\"}");
    // component is triggered if no job is specified in request body
    assertResponse(new Request("http://localhost:8080/screwdriver/v1/trigger/tenant/" + app.id().tenant().value() + "/application/" + app.id().application().value(), new byte[0], Request.Method.POST), 200, "{\"message\":\"Triggered component for tenant1.application1\"}");
    assertFalse(deploymentQueue.jobs().isEmpty());
    assertEquals(JobType.component.jobName(), deploymentQueue.jobs().get(0).jobName());
    assertEquals(1L, deploymentQueue.jobs().get(0).projectId());
    deploymentQueue.takeJobsToRun();
    // Triggers specific job when given
    assertResponse(new Request("http://localhost:8080/screwdriver/v1/trigger/tenant/" + app.id().tenant().value() + "/application/" + app.id().application().value(), "staging-test".getBytes(StandardCharsets.UTF_8), Request.Method.POST), 200, "{\"message\":\"Triggered staging-test for tenant1.application1\"}");
    assertFalse(deploymentQueue.jobs().isEmpty());
    assertEquals(JobType.stagingTest.jobName(), deploymentQueue.jobs().get(0).jobName());
    assertEquals(1L, deploymentQueue.jobs().get(0).projectId());
}
Also used : ContainerControllerTester(com.yahoo.vespa.hosted.controller.restapi.ContainerControllerTester) Request(com.yahoo.application.container.handler.Request) Application(com.yahoo.vespa.hosted.controller.Application) DeploymentQueue(com.yahoo.vespa.hosted.controller.deployment.DeploymentQueue) ControllerContainerTest(com.yahoo.vespa.hosted.controller.restapi.ControllerContainerTest) Test(org.junit.Test)

Example 2 with DeploymentQueue

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

the class ControllerTest method requeueOutOfCapacityStagingJob.

@Test
public void requeueOutOfCapacityStagingJob() {
    DeploymentTester tester = new DeploymentTester();
    long project1 = 1;
    long project2 = 2;
    long project3 = 3;
    Application app1 = tester.createApplication("app1", "tenant1", project1, 1L);
    Application app2 = tester.createApplication("app2", "tenant2", project2, 1L);
    Application app3 = tester.createApplication("app3", "tenant3", project3, 1L);
    DeploymentQueue deploymentQueue = tester.controller().applications().deploymentTrigger().deploymentQueue();
    // all applications: system-test completes successfully
    tester.jobCompletion(component).application(app1).uploadArtifact(applicationPackage).submit();
    tester.deployAndNotify(app1, applicationPackage, true, systemTest);
    tester.jobCompletion(component).application(app2).uploadArtifact(applicationPackage).submit();
    tester.deployAndNotify(app2, applicationPackage, true, systemTest);
    tester.jobCompletion(component).application(app3).uploadArtifact(applicationPackage).submit();
    tester.deployAndNotify(app3, applicationPackage, true, systemTest);
    // all applications: staging test jobs queued
    assertEquals(3, deploymentQueue.jobs().size());
    // app1: staging-test job fails with out of capacity and is added to the front of the queue
    tester.deploy(stagingTest, app1, applicationPackage);
    tester.jobCompletion(stagingTest).application(app1).error(JobError.outOfCapacity).submit();
    assertEquals(stagingTest.jobName(), deploymentQueue.jobs().get(0).jobName());
    assertEquals(project1, deploymentQueue.jobs().get(0).projectId());
    // app2 and app3: Completes deployment
    tester.deployAndNotify(app2, applicationPackage, true, stagingTest);
    tester.deployAndNotify(app2, applicationPackage, true, productionCorpUsEast1);
    tester.deployAndNotify(app3, applicationPackage, true, stagingTest);
    tester.deployAndNotify(app3, applicationPackage, true, productionCorpUsEast1);
    // app2 and app3: New change triggers system-test jobs
    // Provide a changed application package, too, or the deployment is a no-op.
    tester.jobCompletion(component).application(app2).nextBuildNumber().uploadArtifact(applicationPackage).submit();
    tester.deployAndNotify(app2, applicationPackage2, true, systemTest);
    tester.jobCompletion(component).application(app3).nextBuildNumber().uploadArtifact(applicationPackage).submit();
    tester.deployAndNotify(app3, applicationPackage2, true, systemTest);
    assertEquals(Collections.singletonList(new BuildService.BuildJob(project1, stagingTest.jobName())), deploymentQueue.takeJobsToRun());
    assertEquals(Collections.singletonList(new BuildService.BuildJob(project2, stagingTest.jobName())), deploymentQueue.takeJobsToRun());
    assertEquals(Collections.singletonList(new BuildService.BuildJob(project3, stagingTest.jobName())), deploymentQueue.takeJobsToRun());
    assertEquals(Collections.emptyList(), deploymentQueue.takeJobsToRun());
}
Also used : DeploymentTester(com.yahoo.vespa.hosted.controller.deployment.DeploymentTester) ScrewdriverBuildJob(com.yahoo.vespa.hosted.controller.api.application.v4.model.ScrewdriverBuildJob) BuildJob(com.yahoo.vespa.hosted.controller.deployment.BuildJob) DeploymentQueue(com.yahoo.vespa.hosted.controller.deployment.DeploymentQueue) 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

DeploymentQueue (com.yahoo.vespa.hosted.controller.deployment.DeploymentQueue)2 Test (org.junit.Test)2 Request (com.yahoo.application.container.handler.Request)1 Application (com.yahoo.vespa.hosted.controller.Application)1 ScrewdriverBuildJob (com.yahoo.vespa.hosted.controller.api.application.v4.model.ScrewdriverBuildJob)1 JobType.stagingTest (com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest)1 JobType.systemTest (com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest)1 BuildJob (com.yahoo.vespa.hosted.controller.deployment.BuildJob)1 DeploymentTester (com.yahoo.vespa.hosted.controller.deployment.DeploymentTester)1 ContainerControllerTester (com.yahoo.vespa.hosted.controller.restapi.ContainerControllerTester)1 ControllerContainerTest (com.yahoo.vespa.hosted.controller.restapi.ControllerContainerTest)1