Search in sources :

Example 6 with JobConfigIdentifier

use of com.thoughtworks.go.domain.JobConfigIdentifier in project gocd by gocd.

the class JobStatusCacheTest method shouldFindAllMatchingJobsForJobsThatAreRunOnAllAgents.

@Test
public void shouldFindAllMatchingJobsForJobsThatAreRunOnAllAgents() {
    JobInstance job1 = JobInstanceMother.instanceForRunOnAllAgents("cruise", "dev", "linux-firefox", "1", 1);
    JobInstance job2 = JobInstanceMother.instanceForRunOnAllAgents("cruise", "dev", "linux-firefox", "1", 2);
    jobStatusCache.jobStatusChanged(job1);
    jobStatusCache.jobStatusChanged(job2);
    JobConfigIdentifier config = new JobConfigIdentifier("cruise", "dev", "linux-firefox");
    List<JobInstance> list = jobStatusCache.currentJobs(config);
    assertThat(list, hasItem(job1));
    assertThat(list, hasItem(job2));
    assertThat(list.size(), is(2));
}
Also used : JobInstance(com.thoughtworks.go.domain.JobInstance) JobConfigIdentifier(com.thoughtworks.go.domain.JobConfigIdentifier) Test(org.junit.Test)

Example 7 with JobConfigIdentifier

use of com.thoughtworks.go.domain.JobConfigIdentifier in project gocd by gocd.

the class JobStatusCacheTest method shouldLoadMostRecentInstanceFromDBForTheFirstTime.

@Test
public void shouldLoadMostRecentInstanceFromDBForTheFirstTime() throws SQLException {
    pipelineFixture.createdPipelineWithAllStagesPassed();
    Pipeline pipeline = pipelineFixture.createPipelineWithFirstStageScheduled();
    JobInstance expect = pipeline.getStages().byName(pipelineFixture.devStage).getJobInstances().first();
    assertThat(jobStatusCache.currentJob(new JobConfigIdentifier(pipelineFixture.pipelineName, pipelineFixture.devStage, PipelineWithTwoStages.JOB_FOR_DEV_STAGE)), is(expect));
}
Also used : JobInstance(com.thoughtworks.go.domain.JobInstance) JobConfigIdentifier(com.thoughtworks.go.domain.JobConfigIdentifier) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 8 with JobConfigIdentifier

use of com.thoughtworks.go.domain.JobConfigIdentifier in project gocd by gocd.

the class JobStatusCacheTest method shouldFindAllMatchingJobsForJobsThatAreRunMultipleInstance.

@Test
public void shouldFindAllMatchingJobsForJobsThatAreRunMultipleInstance() {
    JobInstance job1 = JobInstanceMother.instanceForRunMultipleInstance("cruise", "dev", "linux-firefox", "1", 1);
    JobInstance job2 = JobInstanceMother.instanceForRunMultipleInstance("cruise", "dev", "linux-firefox", "1", 2);
    jobStatusCache.jobStatusChanged(job1);
    jobStatusCache.jobStatusChanged(job2);
    JobConfigIdentifier config = new JobConfigIdentifier("cruise", "dev", "linux-firefox");
    List<JobInstance> list = jobStatusCache.currentJobs(config);
    assertThat(list, hasItem(job1));
    assertThat(list, hasItem(job2));
    assertThat(list.size(), is(2));
}
Also used : JobInstance(com.thoughtworks.go.domain.JobInstance) JobConfigIdentifier(com.thoughtworks.go.domain.JobConfigIdentifier) Test(org.junit.Test)

Example 9 with JobConfigIdentifier

use of com.thoughtworks.go.domain.JobConfigIdentifier in project gocd by gocd.

the class JobStatusCacheTest method shouldExcludeJobFromOtherInstancesOfThisStage.

@Test
public void shouldExcludeJobFromOtherInstancesOfThisStage() {
    JobInstance job1 = JobInstanceMother.buildingInstance("cruise", "dev", "linux-firefox", "1");
    JobInstance job2 = JobInstanceMother.instanceForRunOnAllAgents("cruise", "dev", "linux-firefox", "2", 1);
    jobStatusCache.jobStatusChanged(job1);
    jobStatusCache.jobStatusChanged(job2);
    JobConfigIdentifier config = new JobConfigIdentifier("cruise", "dev", "linux-firefox");
    List<JobInstance> list = jobStatusCache.currentJobs(config);
    assertThat(list, hasItem(job2));
    assertThat(list, not(hasItem(job1)));
}
Also used : JobInstance(com.thoughtworks.go.domain.JobInstance) JobConfigIdentifier(com.thoughtworks.go.domain.JobConfigIdentifier) Test(org.junit.Test)

Aggregations

JobConfigIdentifier (com.thoughtworks.go.domain.JobConfigIdentifier)9 JobInstance (com.thoughtworks.go.domain.JobInstance)7 Test (org.junit.Test)7 Pipeline (com.thoughtworks.go.domain.Pipeline)2 JobNotFoundException (com.thoughtworks.go.config.JobNotFoundException)1 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)1 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)1