use of com.thoughtworks.go.remote.AgentInstruction in project gocd by gocd.
the class JobRunnerTest method shouldDoNothingWhenJobIsNotCancelled.
@Test
public void shouldDoNothingWhenJobIsNotCancelled() {
runner.setWork(work);
runner.handleInstruction(new AgentInstruction(false), new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false));
assertThat(work.getCallCount(), is(0));
}
use of com.thoughtworks.go.remote.AgentInstruction in project gocd by gocd.
the class AgentRemoteHandlerTest method removeRegisteredAgent.
@Test
public void removeRegisteredAgent() throws Exception {
AgentInstance instance = AgentInstanceMother.idle();
AgentRuntimeInfo info = new AgentRuntimeInfo(instance.getAgentIdentifier(), AgentRuntimeStatus.Idle, null, null, false);
when(remote.ping(any(AgentRuntimeInfo.class))).thenReturn(new AgentInstruction(false));
when(remote.getCookie(instance.getAgentIdentifier(), info.getLocation())).thenReturn("new cookie");
when(agentService.findAgent(instance.getUuid())).thenReturn(instance);
handler.process(agent, new Message(Action.ping, MessageEncoding.encodeData(info)));
handler.remove(agent);
assertEquals(0, handler.connectedAgents().size());
assertEquals(AgentStatus.LostContact, instance.getStatus());
}
use of com.thoughtworks.go.remote.AgentInstruction in project gocd by gocd.
the class AgentRemoteHandlerTest method shouldNotSetDupCookieForSameAgent.
@Test
public void shouldNotSetDupCookieForSameAgent() throws Exception {
AgentInstance instance = AgentInstanceMother.idle();
AgentRuntimeInfo info = new AgentRuntimeInfo(instance.getAgentIdentifier(), AgentRuntimeStatus.Idle, null, null, false);
when(remote.ping(any(AgentRuntimeInfo.class))).thenReturn(new AgentInstruction(false));
when(remote.getCookie(instance.getAgentIdentifier(), info.getLocation())).thenReturn("cookie");
when(agentService.findAgent(instance.getUuid())).thenReturn(instance);
handler.process(agent, new Message(Action.ping, MessageEncoding.encodeData(info)));
info.setCookie(null);
reset(remote);
when(remote.ping(any(AgentRuntimeInfo.class))).thenReturn(new AgentInstruction(false));
when(remote.getCookie(instance.getAgentIdentifier(), info.getLocation())).thenReturn("new cookie");
handler.process(agent, new Message(Action.ping, MessageEncoding.encodeData(info)));
verify(remote).ping(withCookie(info, "cookie"));
info.setCookie(null);
handler.remove(agent);
reset(remote);
when(remote.ping(any(AgentRuntimeInfo.class))).thenReturn(new AgentInstruction(false));
when(remote.getCookie(instance.getAgentIdentifier(), info.getLocation())).thenReturn("new cookie");
handler.process(agent, new Message(Action.ping, MessageEncoding.encodeData(info)));
verify(remote).ping(withCookie(info, "new cookie"));
}
use of com.thoughtworks.go.remote.AgentInstruction in project gocd by gocd.
the class JobRunnerTest method shouldReturnTrueOnGetJobIsCancelledWhenJobIsCancelled.
@Test
public void shouldReturnTrueOnGetJobIsCancelledWhenJobIsCancelled() {
assertThat(runner.isJobCancelled(), is(false));
runner.handleInstruction(new AgentInstruction(true), new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false));
assertThat(runner.isJobCancelled(), is(true));
}
use of com.thoughtworks.go.remote.AgentInstruction in project gocd by gocd.
the class JobRunnerTest method shouldCancelOncePerJob.
@Test
public void shouldCancelOncePerJob() {
runner.setWork(work);
runner.handleInstruction(new AgentInstruction(true), new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false));
assertThat(work.getCallCount(), is(1));
runner.handleInstruction(new AgentInstruction(true), new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false));
assertThat(work.getCallCount(), is(1));
}
Aggregations