use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.
the class AgentInstanceTest method shouldNotifyAgentChangeListenerOnRefreshAndMarkedLostContact.
@Test
public void shouldNotifyAgentChangeListenerOnRefreshAndMarkedLostContact() throws Exception {
AgentInstance instance = AgentInstance.createFromConfig(agentConfig, new SystemEnvironment() {
public int getAgentConnectionTimeout() {
return -1;
}
}, agentStatusChangeListener);
assertThat(instance.getStatus(), is(AgentStatus.Missing));
instance.update(new AgentRuntimeInfo(agentConfig.getAgentIdentifier(), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false));
instance.refresh();
assertThat(instance.getStatus(), is(AgentStatus.LostContact));
verify(agentStatusChangeListener, times(2)).onAgentStatusChange(instance);
}
use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.
the class AgentInstanceTest method shouldNotChangePendingAgentIpAddress.
@Test
public void shouldNotChangePendingAgentIpAddress() throws Exception {
AgentInstance pending = AgentInstance.createFromLiveAgent(new AgentRuntimeInfo(agentConfig.getAgentIdentifier(), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false), systemEnvironment, mock(AgentStatusChangeListener.class));
AgentRuntimeInfo info = new AgentRuntimeInfo(new AgentIdentifier("ccedev01", "10.18.7.52", "uuid"), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false);
assertThat(pending.isIpChangeRequired(info.getIpAdress()), is(false));
}
use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.
the class AgentInstanceTest method shouldBeAbleToDenyAgentWhenItIsBuilding.
@Test
public void shouldBeAbleToDenyAgentWhenItIsBuilding() throws Exception {
AgentInstance original = AgentInstance.createFromConfig(agentConfig, systemEnvironment, mock(AgentStatusChangeListener.class));
AgentRuntimeInfo runtimeInfo = buildingRuntimeInfo();
original.update(runtimeInfo);
assertThat(original.canDisable(), is(true));
original.deny();
assertThat(agentConfig.isDisabled(), is(true));
assertThat(original.getStatus(), is(AgentStatus.Disabled));
assertThat(original.getBuildingInfo(), is(runtimeInfo.getBuildingInfo()));
}
use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.
the class AgentInstanceTest method shouldUpdateAgentBackToIdleAfterCancelledTaskFinishes.
@Test
public void shouldUpdateAgentBackToIdleAfterCancelledTaskFinishes() throws Exception {
AgentInstance cancelled = AgentInstanceMother.cancelled();
AgentRuntimeInfo fromAgent = new AgentRuntimeInfo(cancelled.agentConfig().getAgentIdentifier(), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false);
fromAgent.idle();
cancelled.update(fromAgent);
assertThat(cancelled.getStatus(), is(AgentStatus.Idle));
}
use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.
the class AgentInstanceTest method shouldBecomeIdleAfterApprove.
@Test
public void shouldBecomeIdleAfterApprove() throws Exception {
AgentInstance instance = AgentInstance.createFromLiveAgent(new AgentRuntimeInfo(agentConfig.getAgentIdentifier(), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false), systemEnvironment, mock(AgentStatusChangeListener.class));
instance.enable();
instance.update(new AgentRuntimeInfo(agentConfig.getAgentIdentifier(), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false));
assertThat(instance.getStatus(), is(AgentStatus.Idle));
}
Aggregations