Search in sources :

Example 1 with BuildJob

use of com.yahoo.vespa.hosted.controller.api.integration.BuildService.BuildJob in project vespa by vespa-engine.

the class DeploymentJobExecutorTest method testMaintenance.

@Test
public void testMaintenance() {
    DeploymentTester tester = new DeploymentTester();
    JobControl jobControl = new JobControl(tester.controller().curator());
    int project1 = 1;
    int project2 = 2;
    int project3 = 3;
    ApplicationId app1 = tester.createApplication("app1", "tenant", project1, null).id();
    ApplicationId app2 = tester.createApplication("app2", "tenant", project2, null).id();
    ApplicationId app3 = tester.createApplication("app3", "tenant", project3, null).id();
    // Create a BuildService which always rejects jobs from project2, but accepts and runs all others.
    ArrayList<BuildJob> buildJobs = new ArrayList<>();
    BuildService buildService = buildJob -> buildJob.projectId() == project2 ? false : buildJobs.add(buildJob);
    DeploymentJobExecutor triggerer = new DeploymentJobExecutor(tester.controller(), Duration.ofDays(1), jobControl, buildService, Runnable::run);
    triggerer.maintain();
    assertEquals("No jobs are triggered initially.", Collections.emptyList(), buildJobs);
    // Trigger jobs in capacity constrained environment
    tester.deploymentQueue().addJob(app1, DeploymentJobs.JobType.systemTest, false);
    tester.deploymentQueue().addJob(app2, DeploymentJobs.JobType.systemTest, false);
    tester.deploymentQueue().addJob(app3, DeploymentJobs.JobType.systemTest, false);
    // Trigger jobs in non-capacity constrained environment
    tester.deploymentQueue().addJob(app1, DeploymentJobs.JobType.productionUsWest1, false);
    tester.deploymentQueue().addJob(app2, DeploymentJobs.JobType.productionUsWest1, false);
    tester.deploymentQueue().addJob(app3, DeploymentJobs.JobType.productionUsWest1, false);
    triggerer.maintain();
    assertEquals("One system test job and all production jobs not for app2 are triggered after one maintenance run.", Arrays.asList(new BuildJob(project1, DeploymentJobs.JobType.systemTest.jobName()), new BuildJob(project1, DeploymentJobs.JobType.productionUsWest1.jobName()), new BuildJob(project3, DeploymentJobs.JobType.productionUsWest1.jobName())), buildJobs);
    buildJobs.clear();
    triggerer.maintain();
    assertEquals("Next job in line fails to trigger in the build service.", Collections.emptyList(), buildJobs);
    buildJobs.clear();
    triggerer.maintain();
    assertEquals("Next job which was waiting for capacity is triggered on next run.", Collections.singletonList(new BuildJob(project3, DeploymentJobs.JobType.systemTest.jobName())), buildJobs);
    buildJobs.clear();
    triggerer.maintain();
    assertEquals("No jobs are left.", Collections.emptyList(), tester.deploymentQueue().takeJobsToRun());
}
Also used : Arrays(java.util.Arrays) ApplicationId(com.yahoo.config.provision.ApplicationId) BuildJob(com.yahoo.vespa.hosted.controller.api.integration.BuildService.BuildJob) Duration(java.time.Duration) BuildService(com.yahoo.vespa.hosted.controller.api.integration.BuildService) Test(org.junit.Test) DeploymentJobs(com.yahoo.vespa.hosted.controller.application.DeploymentJobs) JobControl(com.yahoo.vespa.hosted.controller.maintenance.JobControl) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) ArrayList(java.util.ArrayList) BuildService(com.yahoo.vespa.hosted.controller.api.integration.BuildService) ArrayList(java.util.ArrayList) JobControl(com.yahoo.vespa.hosted.controller.maintenance.JobControl) BuildJob(com.yahoo.vespa.hosted.controller.api.integration.BuildService.BuildJob) ApplicationId(com.yahoo.config.provision.ApplicationId) Test(org.junit.Test)

Example 2 with BuildJob

use of com.yahoo.vespa.hosted.controller.api.integration.BuildService.BuildJob in project vespa by vespa-engine.

the class DeploymentQueueTest method testJobOffering.

@Test
public void testJobOffering() {
    DeploymentTester tester = new DeploymentTester();
    DeploymentQueue deploymentQueue = new DeploymentQueue(tester.controller(), tester.controller().curator());
    int project1 = 1;
    int project2 = 2;
    int project3 = 3;
    ApplicationId app1 = tester.createApplication("app1", "tenant", project1, null).id();
    ApplicationId app2 = tester.createApplication("app2", "tenant", project2, null).id();
    ApplicationId app3 = tester.createApplication("app3", "tenant", project3, null).id();
    // Trigger jobs in capacity constrained environment
    deploymentQueue.addJob(app1, JobType.systemTest, false);
    deploymentQueue.addJob(app2, JobType.systemTest, true);
    deploymentQueue.addJob(app3, JobType.stagingTest, false);
    // Trigger jobs in non-capacity constrained environment
    deploymentQueue.addJob(app1, JobType.productionUsWest1, false);
    deploymentQueue.addJob(app2, JobType.productionUsWest1, false);
    deploymentQueue.addJob(app3, JobType.productionUsWest1, false);
    assertEquals("Each offer contains a single job from each capacity constrained environment, and all other jobs.", Arrays.asList(new BuildJob(project2, JobType.systemTest.jobName()), new BuildJob(project3, JobType.stagingTest.jobName()), new BuildJob(project1, JobType.productionUsWest1.jobName()), new BuildJob(project2, JobType.productionUsWest1.jobName()), new BuildJob(project3, JobType.productionUsWest1.jobName())), deploymentQueue.takeJobsToRun());
    assertEquals("The system test job for project 1 was pushed back in the queue by that for project 2.", Collections.singletonList(new BuildJob(project1, JobType.systemTest.jobName())), deploymentQueue.takeJobsToRun());
    assertEquals("No jobs are left.", Collections.emptyList(), deploymentQueue.takeJobsToRun());
}
Also used : BuildJob(com.yahoo.vespa.hosted.controller.api.integration.BuildService.BuildJob) ApplicationId(com.yahoo.config.provision.ApplicationId) Test(org.junit.Test)

Example 3 with BuildJob

use of com.yahoo.vespa.hosted.controller.api.integration.BuildService.BuildJob in project vespa by vespa-engine.

the class ScrewdriverApiHandler method buildJobs.

private HttpResponse buildJobs(List<BuildJob> buildJobs) {
    Slime slime = new Slime();
    Cursor buildJobArray = slime.setArray();
    for (BuildJob buildJob : buildJobs) {
        Cursor buildJobObject = buildJobArray.addObject();
        buildJobObject.setLong("projectId", buildJob.projectId());
        buildJobObject.setString("jobName", buildJob.jobName());
    }
    return new SlimeJsonResponse(slime);
}
Also used : SlimeJsonResponse(com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse) BuildJob(com.yahoo.vespa.hosted.controller.api.integration.BuildService.BuildJob) Slime(com.yahoo.slime.Slime) Cursor(com.yahoo.slime.Cursor)

Aggregations

BuildJob (com.yahoo.vespa.hosted.controller.api.integration.BuildService.BuildJob)3 ApplicationId (com.yahoo.config.provision.ApplicationId)2 Test (org.junit.Test)2 Cursor (com.yahoo.slime.Cursor)1 Slime (com.yahoo.slime.Slime)1 BuildService (com.yahoo.vespa.hosted.controller.api.integration.BuildService)1 DeploymentJobs (com.yahoo.vespa.hosted.controller.application.DeploymentJobs)1 JobControl (com.yahoo.vespa.hosted.controller.maintenance.JobControl)1 SlimeJsonResponse (com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse)1 Duration (java.time.Duration)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 Assert.assertEquals (org.junit.Assert.assertEquals)1