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;
}
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();
}
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"));
}
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);
}
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);
}
Aggregations