Search in sources :

Example 46 with JobInstance

use of com.thoughtworks.go.domain.JobInstance 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 47 with JobInstance

use of com.thoughtworks.go.domain.JobInstance 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 48 with JobInstance

use of com.thoughtworks.go.domain.JobInstance 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 49 with JobInstance

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

the class JobStatusCacheTest method jobInstance.

private JobInstance jobInstance(String jobConfigName) {
    JobInstance instance = JobInstanceMother.scheduled(jobConfigName);
    instance.setIdentifier(new JobIdentifier("cruise", 1, "1", "dev", "1", jobConfigName));
    return instance;
}
Also used : JobInstance(com.thoughtworks.go.domain.JobInstance) JobIdentifier(com.thoughtworks.go.domain.JobIdentifier)

Example 50 with JobInstance

use of com.thoughtworks.go.domain.JobInstance 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

JobInstance (com.thoughtworks.go.domain.JobInstance)82 Test (org.junit.Test)56 Stage (com.thoughtworks.go.domain.Stage)16 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)15 Pipeline (com.thoughtworks.go.domain.Pipeline)15 JobInstances (com.thoughtworks.go.domain.JobInstances)12 JobConfigIdentifier (com.thoughtworks.go.domain.JobConfigIdentifier)7 Agent (com.thoughtworks.go.server.domain.Agent)6 Gson (com.google.gson.Gson)5 Stages (com.thoughtworks.go.domain.Stages)5 Map (java.util.Map)5 DurationBean (com.thoughtworks.go.dto.DurationBean)4 DateTime (org.joda.time.DateTime)4 ArtifactPropertiesGenerator (com.thoughtworks.go.config.ArtifactPropertiesGenerator)3 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)3 Resource (com.thoughtworks.go.config.Resource)3 DirectoryEntries (com.thoughtworks.go.domain.DirectoryEntries)3 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)3 ProjectStatus (com.thoughtworks.go.domain.activity.ProjectStatus)3 JobInstanceModel (com.thoughtworks.go.server.ui.JobInstanceModel)3