use of com.thoughtworks.go.domain.JobInstances in project gocd by gocd.
the class StageDetailPresentationModel method getIndexPages.
public Map<JobInstance, String> getIndexPages() {
JobInstances nonEmptyIndexPages = stage.getJobInstances().withNonEmptyIndexPages();
Map<JobInstance, String> aggregate = new LinkedHashMap<>();
for (JobInstance job : nonEmptyIndexPages) {
JobIdentifier jobIdentifier = new JobIdentifier(pipeline.getName(), pipeline.getCounter(), pipeline.getLabel(), stage.getName(), String.valueOf(stage.getCounter()), job.getName(), job.getId());
String filePath = job.getTestIndexPage().getPath();
String path = FileUtil.normalizePath(filePath.substring(filePath.indexOf(TEST_OUTPUT_FOLDER)));
aggregate.put(job, baseArtifactUrl(jobIdentifier, path));
}
return aggregate;
}
use of com.thoughtworks.go.domain.JobInstances in project gocd by gocd.
the class JobInstanceControllerV1 method getHistoryInfo.
String getHistoryInfo(Request request, Response response) throws IOException {
String pipelineName = request.params("pipeline_name");
String stageName = request.params("stage_name");
String jobName = request.params("job_name");
Long after = getCursor(request, "after");
Long before = getCursor(request, "before");
Integer pageSize = getPageSize(request);
JobInstances jobInstances = jobInstanceService.getJobHistoryViaCursor(currentUsername(), pipelineName, stageName, jobName, after, before, pageSize);
PipelineRunIdInfo runIdInfo = jobInstanceService.getOldestAndLatestJobInstanceId(currentUsername(), pipelineName, stageName, jobName);
return writerForTopLevelObject(request, response, writer -> JobInstancesRepresenter.toJSON(writer, jobInstances, runIdInfo));
}
use of com.thoughtworks.go.domain.JobInstances in project gocd by gocd.
the class JobPresentationServiceTest method shouldReturnJobModelForAnAgentThatIsNoMoreAvailableInTheConfig.
@Test
public void shouldReturnJobModelForAnAgentThatIsNoMoreAvailableInTheConfig() {
String deletedAgentUuid = "deleted_agent";
JobInstance jobWithDeletedAgent = assignedWithAgentId("dev", deletedAgentUuid);
when(agentService.findAgentAndRefreshStatus(deletedAgentUuid)).thenReturn(null);
Agent agentFromDb = new Agent(deletedAgentUuid, "hostname", "1.2.3.4", "cookie");
when(agentService.findAgentByUUID(deletedAgentUuid)).thenReturn(agentFromDb);
List<JobInstanceModel> models = new JobPresentationService(jobDurationStrategy, agentService).jobInstanceModelFor(new JobInstances(jobWithDeletedAgent));
assertThat(models.size(), is(1));
assertThat(models.get(0), is(new JobInstanceModel(jobWithDeletedAgent, jobDurationStrategy, agentFromDb)));
verify(agentService, times(1)).findAgentAndRefreshStatus(deletedAgentUuid);
verify(agentService, times(1)).findAgentByUUID(deletedAgentUuid);
verifyNoMoreInteractions(agentService);
}
use of com.thoughtworks.go.domain.JobInstances in project gocd by gocd.
the class ScheduleServiceRescheduleHungJobsTest method shouldNotifyConsoleActivityMonitorToCancelUnresponsiveJobs.
@Test
public void shouldNotifyConsoleActivityMonitorToCancelUnresponsiveJobs() {
when(agentService.findRegisteredAgents()).thenReturn(activities());
when(jobInstanceService.findHungJobs(Arrays.asList("uuid1", "uuid2"))).thenReturn(new JobInstances());
scheduleService.rescheduleHungJobs();
}
use of com.thoughtworks.go.domain.JobInstances in project gocd by gocd.
the class ScheduleServiceRescheduleHungJobsTest method shouldNotRescheduleHungBuildsWhenNone.
@Test
public void shouldNotRescheduleHungBuildsWhenNone() {
when(agentService.findRegisteredAgents()).thenReturn(activities());
when(jobInstanceService.findHungJobs(Arrays.asList("uuid1", "uuid2"))).thenReturn(new JobInstances());
scheduleService.rescheduleHungJobs();
verify(agentService).findRegisteredAgents();
verify(jobInstanceService).findHungJobs(Arrays.asList("uuid1", "uuid2"));
}
Aggregations