Search in sources :

Example 61 with AgentIdentifier

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"));
}
Also used : AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) Test(org.junit.Test)

Example 62 with AgentIdentifier

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"));
}
Also used : AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) StringContains.containsString(org.hamcrest.core.StringContains.containsString) GoConfigRevision(com.thoughtworks.go.domain.GoConfigRevision) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) Test(org.junit.Test)

Example 63 with AgentIdentifier

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]"));
    }
}
Also used : LogFixture(com.thoughtworks.go.util.LogFixture) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) Test(org.junit.Test)

Example 64 with AgentIdentifier

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);
    }
}
Also used : AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier)

Example 65 with AgentIdentifier

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);
}
Also used : Message(com.thoughtworks.go.websocket.Message) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier)

Aggregations

AgentIdentifier (com.thoughtworks.go.remote.AgentIdentifier)81 Test (org.junit.Test)57 AgentRuntimeInfo (com.thoughtworks.go.server.service.AgentRuntimeInfo)34 FakeBuildRepositoryRemote (com.thoughtworks.go.agent.testhelpers.FakeBuildRepositoryRemote)12 Before (org.junit.Before)11 UploadEntry (com.thoughtworks.go.matchers.UploadEntry)10 ArrayList (java.util.ArrayList)10 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)9 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)9 File (java.io.File)9 AgentConfig (com.thoughtworks.go.config.AgentConfig)5 AgentInstance (com.thoughtworks.go.domain.AgentInstance)5 AgentStatusChangeListener (com.thoughtworks.go.listener.AgentStatusChangeListener)5 AgentInstruction (com.thoughtworks.go.remote.AgentInstruction)4 NoWork (com.thoughtworks.go.remote.work.NoWork)4 Work (com.thoughtworks.go.remote.work.Work)4 Agent (com.thoughtworks.go.server.domain.Agent)4 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)3 HttpOperationResult (com.thoughtworks.go.server.service.result.HttpOperationResult)3 GoConfigDao (com.thoughtworks.go.config.GoConfigDao)2