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());
}
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());
}
Aggregations