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));
}
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"));
}
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);
}
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());
}
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;
}
Aggregations