use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.
the class AgentRemoteHandlerTest method shouldSetCookieIfNoCookieFoundWhenAgentPingsServer.
@Test
public void shouldSetCookieIfNoCookieFoundWhenAgentPingsServer() throws Exception {
AgentIdentifier identifier = new AgentIdentifier("HostName", "ipAddress", "uuid");
AgentRuntimeInfo info = new AgentRuntimeInfo(identifier, AgentRuntimeStatus.Idle, null, null, false);
when(remote.getCookie(identifier, info.getLocation())).thenReturn("new cookie");
when(remote.ping(any(AgentRuntimeInfo.class))).thenReturn(new AgentInstruction(false));
handler.process(agent, new Message(Action.ping, MessageEncoding.encodeData(info)));
verify(remote).ping(withCookie(info, "new cookie"));
assertEquals(1, agent.messages.size());
assertEquals(agent.messages.get(0).getAction(), Action.setCookie);
assertEquals(MessageEncoding.decodeData(agent.messages.get(0).getData(), String.class), "new cookie");
}
use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.
the class AgentRemoteHandlerTest method shouldCancelBuildIfAgentRuntimeStatusIsCanceledOnSeverSideWhenClientWithBuildCommandSupportPingsServer.
@Test
public void shouldCancelBuildIfAgentRuntimeStatusIsCanceledOnSeverSideWhenClientWithBuildCommandSupportPingsServer() throws Exception {
AgentRuntimeInfo info = new AgentRuntimeInfo(new AgentIdentifier("HostName", "ipAddress", "uuid"), AgentRuntimeStatus.Idle, null, null, true);
info.setCookie("cookie");
when(remote.ping(info)).thenReturn(new AgentInstruction(true));
handler.process(agent, new Message(Action.ping, MessageEncoding.encodeData(info)));
verify(remote).ping(info);
assertEquals(1, handler.connectedAgents().size());
assertEquals(agent, handler.connectedAgents().get("uuid"));
assertEquals(1, agent.messages.size());
assertEquals(agent.messages.get(0).getAction(), Action.cancelBuild);
}
use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.
the class AgentStatusReportingIntegrationTest method before.
@Before
public void before() {
agentIdentifier = new AgentIdentifier("localhost", "127.0.0.1", "uuid");
environmentVariableContext = new EnvironmentVariableContext();
artifactManipulator = new GoArtifactsManipulatorStub();
buildRepository = new com.thoughtworks.go.remote.work.BuildRepositoryRemoteStub();
this.agentRuntimeInfo = new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false);
}
Aggregations