use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.
the class AgentInstanceTest method shouldReturnTrueWhenFreeDiskOnAgentIsLow.
@Test
void shouldReturnTrueWhenFreeDiskOnAgentIsLow() {
AgentInstance original = AgentInstance.createFromAgent(agent, new SystemEnvironment() {
@Override
public long getAgentSizeLimit() {
return 100 * 1024 * 1024;
}
}, mock(AgentStatusChangeListener.class));
AgentRuntimeInfo newRuntimeInfo = new AgentRuntimeInfo(agent.getAgentIdentifier(), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie");
long is90M = 90 * 1024 * 1024;
newRuntimeInfo.setUsableSpace(is90M);
original.update(newRuntimeInfo);
assertThat(original.isLowDiskSpace()).isTrue();
}
use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.
the class AgentInstanceTest method shouldRefreshDisabledAgent.
@Test
void shouldRefreshDisabledAgent() {
agent.disable();
AgentInstance instance = AgentInstance.createFromAgent(agent, new SystemEnvironment() {
@Override
public int getAgentConnectionTimeout() {
return -1;
}
}, mock(AgentStatusChangeListener.class));
instance.update(new AgentRuntimeInfo(agent.getAgentIdentifier(), Building, currentWorkingDirectory(), "cookie"));
instance.refresh();
assertThat(instance.getRuntimeStatus()).isEqualTo(AgentRuntimeStatus.LostContact);
assertThat(instance.getStatus()).isEqualTo(AgentStatus.Disabled);
}
use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.
the class AgentInstanceTest method shouldBeLostContactWhenLastHeardTimeExeedTimeOut.
@Test
void shouldBeLostContactWhenLastHeardTimeExeedTimeOut() {
AgentInstance instance = AgentInstance.createFromAgent(agent, new SystemEnvironment() {
@Override
public int getAgentConnectionTimeout() {
return -1;
}
}, mock(AgentStatusChangeListener.class));
assertThat(instance.getStatus()).isEqualTo(AgentStatus.Missing);
instance.update(new AgentRuntimeInfo(agent.getAgentIdentifier(), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie"));
instance.refresh();
assertThat(instance.getStatus()).isEqualTo(AgentStatus.LostContact);
}
use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.
the class AgentInstanceTest method shouldReturnFalseWhenAgentHasEnoughSpace.
@Test
void shouldReturnFalseWhenAgentHasEnoughSpace() {
AgentInstance original = AgentInstance.createFromAgent(agent, new SystemEnvironment() {
@Override
public long getAgentSizeLimit() {
return 100 * 1024 * 1024;
}
}, mock(AgentStatusChangeListener.class));
AgentRuntimeInfo newRuntimeInfo = new AgentRuntimeInfo(agent.getAgentIdentifier(), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie");
long is110M = 110 * 1024 * 1024;
newRuntimeInfo.setUsableSpace(is110M);
original.update(newRuntimeInfo);
assertThat(original.isLowDiskSpace()).isFalse();
}
use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.
the class AgentInstanceTest method shouldGetAgentAndBootstrapperVersions.
@Test
void shouldGetAgentAndBootstrapperVersions() {
AgentInstance agentInstance = AgentInstanceMother.idle();
AgentRuntimeInfo newRuntimeInfo = new AgentRuntimeInfo(agentInstance.getAgentIdentifier(), agentInstance.getRuntimeStatus(), "some-location", "some-cookie");
newRuntimeInfo.updateBootstrapperVersion("20.3.0-1234").updateAgentVersion("20.5.0-2345");
agentInstance.update(newRuntimeInfo);
assertThat(agentInstance.getAgentBootstrapperVersion()).isEqualTo("20.3.0-1234");
assertThat(agentInstance.getAgentVersion()).isEqualTo("20.5.0-2345");
}
Aggregations