Search in sources :

Example 36 with AgentRuntimeInfo

use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.

the class AgentInstanceTest method buildingWithTimeProvider.

public static AgentInstance buildingWithTimeProvider(TimeProvider timeProvider) {
    Agent idleAgentConfig = new Agent("uuid2", "localhost", "10.18.5.1");
    AgentRuntimeInfo agentRuntimeInfo = new AgentRuntimeInfo(idleAgentConfig.getAgentIdentifier(), Building, currentWorkingDirectory(), "cookie");
    agentRuntimeInfo.setLocation("/var/lib/foo");
    agentRuntimeInfo.idle();
    agentRuntimeInfo.setUsableSpace(10 * 1024l);
    AgentInstance agentInstance = new AgentInstance(idleAgentConfig, LOCAL, new SystemEnvironment(), mock(AgentStatusChangeListener.class), timeProvider);
    agentInstance.enable();
    return agentInstance;
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) 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 37 with AgentRuntimeInfo

use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.

the class AgentInstanceTest method shouldInitializeTheLastHeardTimeWhenFirstPing.

@Test
void shouldInitializeTheLastHeardTimeWhenFirstPing() {
    AgentInstance agentInstance = AgentInstance.createFromAgent(agent, systemEnvironment, mock(AgentStatusChangeListener.class));
    Date time = agentInstance.getLastHeardTime();
    assertThat(time).isNull();
    agentInstance.update(new AgentRuntimeInfo(agent.getAgentIdentifier(), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie"));
    time = agentInstance.getLastHeardTime();
    assertThat(time).isNotNull();
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) AgentStatusChangeListener(com.thoughtworks.go.listener.AgentStatusChangeListener) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Example 38 with AgentRuntimeInfo

use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.

the class AgentInstanceTest method shouldUpdateSupportBuildCommandProtocolFlag.

@Test
void shouldUpdateSupportBuildCommandProtocolFlag() {
    AgentInstance agentInstance = AgentInstance.createFromAgent(agent, systemEnvironment, mock(AgentStatusChangeListener.class));
    agentInstance.update(new AgentRuntimeInfo(agent.getAgentIdentifier(), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie"));
    agentInstance.update(new AgentRuntimeInfo(agent.getAgentIdentifier(), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie"));
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) AgentStatusChangeListener(com.thoughtworks.go.listener.AgentStatusChangeListener) Test(org.junit.jupiter.api.Test)

Example 39 with AgentRuntimeInfo

use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.

the class AgentInstanceTest method shouldUpdateBuildingInfoWhenAgentIsBuilding.

@Test
void shouldUpdateBuildingInfoWhenAgentIsBuilding() {
    AgentInstance agentInstance = AgentInstance.createFromAgent(agent, systemEnvironment, mock(AgentStatusChangeListener.class));
    AgentRuntimeInfo agentRuntimeInfo = new AgentRuntimeInfo(agent.getAgentIdentifier(), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie");
    AgentBuildingInfo buildingInfo = new AgentBuildingInfo("running pipeline/stage/build", "buildLocator");
    agentRuntimeInfo.busy(buildingInfo);
    agentInstance.update(agentRuntimeInfo);
    assertThat(agentInstance.getBuildingInfo()).isEqualTo(buildingInfo);
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) AgentBuildingInfo(com.thoughtworks.go.server.service.AgentBuildingInfo) AgentStatusChangeListener(com.thoughtworks.go.listener.AgentStatusChangeListener) Test(org.junit.jupiter.api.Test)

Example 40 with AgentRuntimeInfo

use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.

the class AgentInstanceTest method shouldUpdateAgentBackToIdleAfterCancelledTaskFinishes.

@Test
void shouldUpdateAgentBackToIdleAfterCancelledTaskFinishes() {
    AgentInstance cancelledAgentInstance = cancelled();
    AgentRuntimeInfo fromAgent = new AgentRuntimeInfo(cancelledAgentInstance.getAgent().getAgentIdentifier(), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie");
    fromAgent.idle();
    cancelledAgentInstance.update(fromAgent);
    assertThat(cancelledAgentInstance.getStatus()).isEqualTo(AgentStatus.Idle);
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) Test(org.junit.jupiter.api.Test)

Aggregations

AgentRuntimeInfo (com.thoughtworks.go.server.service.AgentRuntimeInfo)150 Test (org.junit.jupiter.api.Test)70 Test (org.junit.Test)52 AgentIdentifier (com.thoughtworks.go.remote.AgentIdentifier)35 AgentStatusChangeListener (com.thoughtworks.go.listener.AgentStatusChangeListener)29 File (java.io.File)17 RemoteInvocation (org.springframework.remoting.support.RemoteInvocation)16 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)14 Agent (com.thoughtworks.go.config.Agent)13 AgentInstruction (com.thoughtworks.go.remote.AgentInstruction)13 FakeBuildRepositoryRemote (com.thoughtworks.go.agent.testhelpers.FakeBuildRepositoryRemote)12 AgentInstance.createFromLiveAgent (com.thoughtworks.go.domain.AgentInstance.createFromLiveAgent)11 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)11 AgentBuildingInfo (com.thoughtworks.go.server.service.AgentBuildingInfo)11 UploadEntry (com.thoughtworks.go.matchers.UploadEntry)10 ArrayList (java.util.ArrayList)10 StringContains.containsString (org.hamcrest.core.StringContains.containsString)9 AgentInstance (com.thoughtworks.go.domain.AgentInstance)8 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)8 NullAgentInstance (com.thoughtworks.go.domain.NullAgentInstance)7