use of com.thoughtworks.go.domain.AgentInstance in project gocd by gocd.
the class AgentInstanceMother method disabledWith.
public static AgentInstance disabledWith(String uuid) {
final AgentInstance disabled = disabled();
disabled.syncAgentFrom(new Agent(uuid, disabled.getHostname(), disabled.getIpAddress()));
return disabled;
}
use of com.thoughtworks.go.domain.AgentInstance in project gocd by gocd.
the class AgentInstanceMother method idle.
public static AgentInstance idle(final Date lastHeardAt, final String hostname, SystemEnvironment systemEnvironment) {
Agent idleAgentConfig = new Agent("uuid2", hostname, "10.18.5.1");
AgentRuntimeInfo agentRuntimeInfo = new AgentRuntimeInfo(idleAgentConfig.getAgentIdentifier(), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie");
agentRuntimeInfo.setLocation("/var/lib/foo");
agentRuntimeInfo.idle();
agentRuntimeInfo.setUsableSpace(10 * 1024l);
AgentInstance agentInstance = createFromLiveAgent(agentRuntimeInfo, systemEnvironment, mock(AgentStatusChangeListener.class));
agentInstance.idle();
agentInstance.update(agentRuntimeInfo);
ReflectionUtil.setField(agentInstance, "lastHeardTime", lastHeardAt);
return agentInstance;
}
use of com.thoughtworks.go.domain.AgentInstance in project gocd by gocd.
the class AgentInstanceMother method idleWith.
public static AgentInstance idleWith(String uuid) {
final AgentInstance agentInstance = idle();
agentInstance.syncAgentFrom(new Agent(uuid, agentInstance.getHostname(), agentInstance.getIpAddress()));
return agentInstance;
}
use of com.thoughtworks.go.domain.AgentInstance 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.AgentInstance in project gocd by gocd.
the class AgentJobHistoryControllerV1 method index.
public String index(Request request, Response response) throws IOException {
String uuid = request.params(":uuid");
Integer offset = getOffset(request);
Integer pageSize = getPageSize(request);
JobInstanceService.JobHistoryColumns column = getSortColumn(request);
SortOrder sortOrder = getSortOrder(request);
Integer total = jobInstanceService.totalCompletedJobsCountOn(uuid);
Pagination pagination = Pagination.pageStartingAt(offset, total, pageSize);
AgentInstance agent = agentService.findAgent(uuid);
if (agent.isNullAgent()) {
throw new RecordNotFoundException(EntityType.Agent, uuid);
}
JobInstancesModel jobInstances = jobInstanceService.completedJobsOnAgent(uuid, column, sortOrder, pagination);
return writerForTopLevelObject(request, response, outputWriter -> AgentJobHistoryRepresenter.toJSON(outputWriter, uuid, jobInstances));
}
Aggregations