use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.
the class UpdateAgentStatusTest method shouldUpdateAgentWorkingDirWhenItChanges.
@Test
public void shouldUpdateAgentWorkingDirWhenItChanges() throws Exception {
AgentIdentifier agentIdentifier1 = new AgentIdentifier("localhost", "10.18.3.95", "uuid");
AgentRuntimeInfo agentRuntimeInfo1 = new AgentRuntimeInfo(agentIdentifier1, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false);
agentRuntimeInfo1.busy(new AgentBuildingInfo("building", "buildLocator"));
agentRuntimeInfo1.setLocation("/myDirectory");
agentService.updateRuntimeInfo(agentRuntimeInfo1);
assertThat(agentService.findAgentAndRefreshStatus("uuid").getLocation(), is("/myDirectory"));
}
use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.
the class UpdateAgentStatusTest method shouldUpdateAgentIPAddressWhenItChanges_asAgent.
@Test
public void shouldUpdateAgentIPAddressWhenItChanges_asAgent() throws Exception {
CruiseConfig oldConfig = goConfigDao.load();
String oldIp = oldConfig.agents().getAgentByUuid("uuid").getIpAddress();
assertThat(oldIp, is("10.81.2.1"));
AgentIdentifier agentIdentifier1 = new AgentIdentifier("localhost", "10.18.3.95", "uuid");
AgentRuntimeInfo agentRuntimeInfo1 = new AgentRuntimeInfo(agentIdentifier1, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false);
agentRuntimeInfo1.busy(new AgentBuildingInfo("building", "buildLocator"));
agentService.updateRuntimeInfo(agentRuntimeInfo1);
CruiseConfig newConfig = goConfigDao.load();
String newIp = newConfig.agents().getAgentByUuid("uuid").getIpAddress();
assertThat(newIp, is("10.18.3.95"));
GoConfigRevision rev = configRepo.getRevision(newConfig.getMd5());
assertThat(rev.getUsername(), is("agent_uuid_10.18.3.95_CCEDev01"));
}
use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.
the class UpdateAgentStatusTest method shouldLogWarningWhenIPAddressChanges.
@Test
public void shouldLogWarningWhenIPAddressChanges() throws Exception {
AgentIdentifier agentIdentifier1 = new AgentIdentifier("localhost", "10.18.3.95", "uuid");
AgentRuntimeInfo agentRuntimeInfo1 = new AgentRuntimeInfo(agentIdentifier1, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false);
agentRuntimeInfo1.busy(new AgentBuildingInfo("building", "buildLocator"));
agentRuntimeInfo1.setLocation("/myDirectory");
try (LogFixture logging = logFixtureFor(AgentService.class, Level.DEBUG)) {
agentService.updateRuntimeInfo(agentRuntimeInfo1);
assertThat(logging.getLog(), containsString("Agent with UUID [uuid] changed IP Address from [10.81.2.1] to [10.18.3.95]"));
}
}
use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.
the class AgentHTTPClientController method ping.
@Override
public void ping() {
try {
if (sslInfrastructureService.isRegistered()) {
AgentIdentifier agent = agentIdentifier();
LOG.trace("{} is pinging server [{}]", agent, server);
getAgentRuntimeInfo().refreshUsableSpace();
agentInstruction = server.ping(getAgentRuntimeInfo());
pingSuccess();
LOG.trace("{} pinged server [{}]", agent, server);
}
} catch (Throwable e) {
LOG.error("Error occurred when agent tried to ping server: ", e);
}
}
use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.
the class AgentWebSocketClientController method updateServerAgentRuntimeInfo.
private void updateServerAgentRuntimeInfo() {
AgentIdentifier agent = agentIdentifier();
LOG.trace("{} is pinging server [{}]", agent, server);
getAgentRuntimeInfo().refreshUsableSpace();
if (webSocketSessionHandler.sendAndWaitForAcknowledgement(new Message(Action.ping, MessageEncoding.encodeData(getAgentRuntimeInfo())))) {
pingSuccess();
}
LOG.trace("{} pinged server [{}]", agent, server);
}
Aggregations