Search in sources :

Example 11 with JobInstances

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;
}
Also used : JobInstance(com.thoughtworks.go.domain.JobInstance) JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) JobInstances(com.thoughtworks.go.domain.JobInstances) LinkedHashMap(java.util.LinkedHashMap)

Example 12 with JobInstances

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));
}
Also used : PipelineRunIdInfo(com.thoughtworks.go.domain.PipelineRunIdInfo) JobInstances(com.thoughtworks.go.domain.JobInstances)

Example 13 with JobInstances

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);
}
Also used : Agent(com.thoughtworks.go.config.Agent) 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 14 with JobInstances

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();
}
Also used : JobInstances(com.thoughtworks.go.domain.JobInstances) Test(org.junit.jupiter.api.Test)

Example 15 with JobInstances

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"));
}
Also used : 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