Search in sources :

Example 51 with AgentInstance

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;
}
Also used : AgentInstance(com.thoughtworks.go.domain.AgentInstance) NullAgentInstance(com.thoughtworks.go.domain.NullAgentInstance) AgentInstance.createFromLiveAgent(com.thoughtworks.go.domain.AgentInstance.createFromLiveAgent) Agent(com.thoughtworks.go.config.Agent)

Example 52 with AgentInstance

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;
}
Also used : AgentInstance(com.thoughtworks.go.domain.AgentInstance) NullAgentInstance(com.thoughtworks.go.domain.NullAgentInstance) AgentInstance.createFromLiveAgent(com.thoughtworks.go.domain.AgentInstance.createFromLiveAgent) Agent(com.thoughtworks.go.config.Agent) AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) AgentStatusChangeListener(com.thoughtworks.go.listener.AgentStatusChangeListener)

Example 53 with 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;
}
Also used : AgentInstance(com.thoughtworks.go.domain.AgentInstance) NullAgentInstance(com.thoughtworks.go.domain.NullAgentInstance) AgentInstance.createFromLiveAgent(com.thoughtworks.go.domain.AgentInstance.createFromLiveAgent) Agent(com.thoughtworks.go.config.Agent)

Example 54 with 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);
}
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 55 with AgentInstance

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));
}
Also used : AgentInstance(com.thoughtworks.go.domain.AgentInstance) JobInstanceService(com.thoughtworks.go.server.service.JobInstanceService) Pagination(com.thoughtworks.go.server.util.Pagination) RecordNotFoundException(com.thoughtworks.go.config.exceptions.RecordNotFoundException) SortOrder(com.thoughtworks.go.server.ui.SortOrder) JobInstancesModel(com.thoughtworks.go.server.ui.JobInstancesModel)

Aggregations

AgentInstance (com.thoughtworks.go.domain.AgentInstance)129 Test (org.junit.Test)61 NullAgentInstance (com.thoughtworks.go.domain.NullAgentInstance)32 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)32 ArrayList (java.util.ArrayList)21 Agent (com.thoughtworks.go.config.Agent)20 Test (org.junit.jupiter.api.Test)20 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)17 AgentConfig (com.thoughtworks.go.config.AgentConfig)16 AgentStatusChangeListener (com.thoughtworks.go.listener.AgentStatusChangeListener)12 AgentInstance.createFromLiveAgent (com.thoughtworks.go.domain.AgentInstance.createFromLiveAgent)10 AgentInstances (com.thoughtworks.go.server.domain.AgentInstances)10 AgentIdentifier (com.thoughtworks.go.remote.AgentIdentifier)8 AgentRuntimeInfo (com.thoughtworks.go.server.service.AgentRuntimeInfo)8 AgentInstance.createFromAgent (com.thoughtworks.go.domain.AgentInstance.createFromAgent)7 ResponseEntity (org.springframework.http.ResponseEntity)7 BuildWork (com.thoughtworks.go.remote.work.BuildWork)6 NoWork (com.thoughtworks.go.remote.work.NoWork)6 Work (com.thoughtworks.go.remote.work.Work)6 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)6