Search in sources :

Example 6 with JobInstances

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

the class StageSummaryModelTest method shouldExplainWhetherJobIsComplete.

@Test
public void shouldExplainWhetherJobIsComplete() 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).isCompleted(), is(true));
}
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 7 with JobInstances

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

the class ScheduleServiceRescheduleHungJobsTest method shouldRescheduleHungBuildForDeadAgent.

@Test
public void shouldRescheduleHungBuildForDeadAgent() {
    final JobInstance jobInstance = JobInstanceMother.assigned("dev");
    when(agentService.findRegisteredAgents()).thenReturn(activities());
    when(jobInstanceService.findHungJobs(Arrays.asList("uuid1", "uuid2"))).thenReturn(new JobInstances(jobInstance));
    scheduleService.rescheduleHungJobs();
    verify(agentService).findRegisteredAgents();
    verify(jobInstanceService).findHungJobs(Arrays.asList("uuid1", "uuid2"));
}
Also used : JobInstance(com.thoughtworks.go.domain.JobInstance) JobInstances(com.thoughtworks.go.domain.JobInstances) Test(org.junit.jupiter.api.Test)

Example 8 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 9 with JobInstances

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

the class PipelineWithTwoStages 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 10 with JobInstances

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

the class StageDetailPresentationModel method getArtifactFiles.

public DirectoryEntries getArtifactFiles() throws IllegalArtifactLocationException {
    JobInstances withNonEmptyArtifacts = stage.getJobInstances();
    DirectoryEntries artifacts = new DirectoryEntries();
    for (JobInstance instance : withNonEmptyArtifacts) {
        DirectoryReader directoryReader = new DirectoryReader(instance.getIdentifier());
        DirectoryEntries subDirectories = directoryReader.listEntries(artifactsService.findArtifact(instance.getIdentifier(), ""), "");
        artifacts.add(new FolderDirectoryEntry(instance.getName(), "", subDirectories));
    }
    return artifacts;
}
Also used : FolderDirectoryEntry(com.thoughtworks.go.domain.FolderDirectoryEntry) DirectoryEntries(com.thoughtworks.go.domain.DirectoryEntries) JobInstance(com.thoughtworks.go.domain.JobInstance) DirectoryReader(com.thoughtworks.go.util.DirectoryReader) JobInstances(com.thoughtworks.go.domain.JobInstances)

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