Search in sources :

Example 1 with JobInstances

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

the class PipelineWithRunOnAllJob method createPipelineWithFirstStageAssigned.

public Pipeline createPipelineWithFirstStageAssigned(String agentId) {
    Pipeline pipeline = createPipelineWithFirstStageScheduled();
    JobInstances instances = pipeline.getStages().byName(devStage).getJobInstances();
    for (JobInstance instance : instances) {
        dbHelper.assignToAgent(instance, agentId);
    }
    return dbHelper.getPipelineDao().loadPipeline(pipeline.getId());
}
Also used : JobInstance(com.thoughtworks.go.domain.JobInstance) Pipeline(com.thoughtworks.go.domain.Pipeline) JobInstances(com.thoughtworks.go.domain.JobInstances)

Example 2 with JobInstances

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

the class BackgroundStageLoaderTest method setup.

@Before
public void setup() {
    stageFeedsReader = mock(StageAtomFeedsReader.class);
    pipelineInstanceLoader = mock(PipelineInstanceLoader.class);
    systemEnvironment = mock(SystemEnvironment.class);
    backgroundStageLoader = new BackgroundStageLoader(stageFeedsReader, mock(StageResourceImporter.class), mock(StageStorage.class), pipelineInstanceLoader, mock(StageService.class), systemEnvironment);
    listener = new BackgroundStageLoaderStageStatusListener(backgroundStageLoader, systemEnvironment);
    stage = new Stage();
    jobInstances = mock(JobInstances.class);
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) StageAtomFeedsReader(com.thoughtworks.studios.shine.cruise.stage.feeds.StageAtomFeedsReader) PipelineInstanceLoader(com.thoughtworks.go.server.service.PipelineInstanceLoader) Stage(com.thoughtworks.go.domain.Stage) JobInstances(com.thoughtworks.go.domain.JobInstances) Before(org.junit.Before)

Example 3 with JobInstances

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

the class JobPresentationServiceTest method shouldReturnJobModel.

@Test
public void shouldReturnJobModel() {
    JobInstance dev = assignedWithAgentId("dev", "agent1");
    JobInstance DEv = assignedWithAgentId("DEv", "agent1");
    JobInstance bev = assignedWithAgentId("bev", "agent2");
    JobInstance tev = scheduled("tev");
    JobInstance lev = assignAgent(passed("lev"), "agent3");
    JobInstance kev = assignAgent(failed("kev"), "agent3");
    AgentInstance agentInstance = building();
    when(agentService.findAgentAndRefreshStatus(any(String.class))).thenReturn(agentInstance);
    List<JobInstanceModel> models = new JobPresentationService(jobDurationStrategy, agentService).jobInstanceModelFor(new JobInstances(dev, bev, tev, lev, kev, DEv));
    assertThat(models.size(), is(6));
    // failed
    assertThat(models.get(0), is(new JobInstanceModel(kev, jobDurationStrategy, agentInstance)));
    // in progress. sort by name (case insensitive)
    assertThat(models.get(1), is(new JobInstanceModel(bev, jobDurationStrategy, agentInstance)));
    assertThat(models.get(2), is(new JobInstanceModel(dev, jobDurationStrategy, agentInstance)));
    assertThat(models.get(3), is(new JobInstanceModel(DEv, jobDurationStrategy, agentInstance)));
    assertThat(models.get(4), is(new JobInstanceModel(tev, jobDurationStrategy)));
    // passed
    assertThat(models.get(5), is(new JobInstanceModel(lev, jobDurationStrategy, agentInstance)));
    // assert agent info
    verify(agentService, times(2)).findAgentAndRefreshStatus("agent1");
    verify(agentService).findAgentAndRefreshStatus("agent2");
    verify(agentService, times(2)).findAgentAndRefreshStatus("agent3");
    verifyNoMoreInteractions(agentService);
}
Also used : AgentInstance(com.thoughtworks.go.domain.AgentInstance) JobInstance(com.thoughtworks.go.domain.JobInstance) JobInstanceModel(com.thoughtworks.go.server.ui.JobInstanceModel) JobInstances(com.thoughtworks.go.domain.JobInstances) Test(org.junit.jupiter.api.Test)

Example 4 with JobInstances

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

the class StageSummaryModelTest method shouldRetriveShowElapsedTime.

@Test
public void shouldRetriveShowElapsedTime() throws Exception {
    JobInstance first = JobInstanceMother.completed("first", JobResult.Failed);
    Stage stage = StageMother.custom("pipeline", "stage", new JobInstances(first));
    StageSummaryModel model = new StageSummaryModel(stage, new Stages(stage), JOB_DURATION_STRATEGY, null);
    assertThat(model.nonPassedJobs().get(0).getElapsedTime(), is(first.getElapsedTime()));
}
Also used : JobInstance(com.thoughtworks.go.domain.JobInstance) Stages(com.thoughtworks.go.domain.Stages) Stage(com.thoughtworks.go.domain.Stage) JobInstances(com.thoughtworks.go.domain.JobInstances) Test(org.junit.jupiter.api.Test)

Example 5 with JobInstances

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

the class StageSummaryModelTest method shouldReturnJobsForAGivenResult.

@Test
public void shouldReturnJobsForAGivenResult() throws Exception {
    JobInstance first = JobInstanceMother.completed("first", JobResult.Failed);
    JobInstance second = JobInstanceMother.completed("bsecond", JobResult.Passed);
    JobInstance third = JobInstanceMother.completed("athird", JobResult.Passed);
    JobInstance fourth = JobInstanceMother.building("fourth");
    JobInstance fifth = JobInstanceMother.completed("fifth", JobResult.Cancelled);
    Stage stage = StageMother.custom("pipeline", "stage", new JobInstances(first, second, third, fourth, fifth));
    StageSummaryModel model = new StageSummaryModel(stage, new Stages(stage), JOB_DURATION_STRATEGY, null);
    assertThat(model.passedJobs().size(), is(2));
    assertThat(model.passedJobs().get(0).getName(), is(third.getName()));
    assertThat(model.passedJobs().get(1).getName(), is(second.getName()));
    assertThat(model.nonPassedJobs().size(), is(2));
    assertThat(model.nonPassedJobs().get(0).getName(), is(fifth.getName()));
    assertThat(model.nonPassedJobs().get(1).getName(), is(first.getName()));
    assertThat(model.inProgressJobs().size(), is(1));
    assertThat(model.inProgressJobs().get(0).getName(), is(fourth.getName()));
}
Also used : JobInstance(com.thoughtworks.go.domain.JobInstance) Stages(com.thoughtworks.go.domain.Stages) Stage(com.thoughtworks.go.domain.Stage) JobInstances(com.thoughtworks.go.domain.JobInstances) Test(org.junit.jupiter.api.Test)

Aggregations

JobInstances (com.thoughtworks.go.domain.JobInstances)17 JobInstance (com.thoughtworks.go.domain.JobInstance)12 Test (org.junit.jupiter.api.Test)10 Stage (com.thoughtworks.go.domain.Stage)6 Stages (com.thoughtworks.go.domain.Stages)5 Pipeline (com.thoughtworks.go.domain.Pipeline)3 JobInstanceModel (com.thoughtworks.go.server.ui.JobInstanceModel)2 Agent (com.thoughtworks.go.config.Agent)1 TrackingTool (com.thoughtworks.go.config.TrackingTool)1 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)1 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)1 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)1 AgentInstance (com.thoughtworks.go.domain.AgentInstance)1 DirectoryEntries (com.thoughtworks.go.domain.DirectoryEntries)1 FolderDirectoryEntry (com.thoughtworks.go.domain.FolderDirectoryEntry)1 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)1 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)1 PipelineRunIdInfo (com.thoughtworks.go.domain.PipelineRunIdInfo)1 Modification (com.thoughtworks.go.domain.materials.Modification)1 JobDurationStrategy (com.thoughtworks.go.server.domain.JobDurationStrategy)1