Search in sources :

Example 46 with Agent

use of com.thoughtworks.go.config.Agent in project gocd by gocd.

the class RegisterAgentCommand method registerAgent.

private Optional<String> registerAgent() {
    InetAddress localHost = getInetAddress();
    Agent agent = new Agent("Perf-Test-Agent-" + UUID.randomUUID(), localHost.getHostName(), localHost.getHostAddress(), UUID.randomUUID().toString());
    AgentRuntimeInfo agentRuntimeInfo = AgentRuntimeInfo.fromServer(agent, false, "location", 233232L, "osx");
    agentService.requestRegistration(agentRuntimeInfo);
    return Optional.ofNullable(agent.getUuid());
}
Also used : Agent(com.thoughtworks.go.config.Agent) AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) InetAddress(java.net.InetAddress)

Example 47 with Agent

use of com.thoughtworks.go.config.Agent in project gocd by gocd.

the class StageIntegrationTest method setUp.

@BeforeEach
public void setUp(@TempDir Path tempDir) throws Exception {
    dbHelper.onSetUp();
    CONFIG_HELPER.usingCruiseConfigDao(goConfigDao);
    CONFIG_HELPER.onSetUp();
    TestRepo svnTestRepo = new SvnTestRepo(tempDir);
    svnRepo = new SvnCommand(null, svnTestRepo.projectRepositoryUrl());
    CONFIG_HELPER.addPipeline(PIPELINE_NAME, DEV_STAGE, svnRepo, "foo");
    mingle = CONFIG_HELPER.addStageToPipeline(PIPELINE_NAME, FT_STAGE, "bar");
    agentService.saveOrUpdate(new Agent(AGENT_UUID, HOSTNAME, "127.0.0.1", "cookie1"));
}
Also used : Agent(com.thoughtworks.go.config.Agent) SvnTestRepo(com.thoughtworks.go.helper.SvnTestRepo) SvnTestRepo(com.thoughtworks.go.helper.SvnTestRepo) TestRepo(com.thoughtworks.go.helper.TestRepo) SvnCommand(com.thoughtworks.go.domain.materials.svn.SvnCommand) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 48 with Agent

use of com.thoughtworks.go.config.Agent in project gocd by gocd.

the class AgentInstances method syncAgentInstancesFrom.

public void syncAgentInstancesFrom(Agents agentsFromDB) {
    for (Agent agentFromDB : agentsFromDB) {
        String uuid = agentFromDB.getUuid();
        if (uuidToAgentInstanceMap.containsKey(uuid)) {
            uuidToAgentInstanceMap.get(uuid).syncAgentFrom(agentFromDB);
        } else {
            AgentInstance newAgent = createFromAgent(agentFromDB, new SystemEnvironment(), agentStatusChangeListener);
            uuidToAgentInstanceMap.put(uuid, newAgent);
        }
    }
    synchronized (uuidToAgentInstanceMap) {
        List<String> uuids = new ArrayList<>();
        for (String uuid : uuidToAgentInstanceMap.keySet()) {
            AgentInstance instance = uuidToAgentInstanceMap.get(uuid);
            if (!(instance.getStatus() == AgentStatus.Pending)) {
                if (!agentsFromDB.hasAgent(uuid)) {
                    uuids.add(uuid);
                }
            }
        }
        uuids.forEach(uuidToAgentInstanceMap::remove);
    }
}
Also used : AgentInstance(com.thoughtworks.go.domain.AgentInstance) NullAgentInstance(com.thoughtworks.go.domain.NullAgentInstance) SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) AgentInstance.createFromAgent(com.thoughtworks.go.domain.AgentInstance.createFromAgent) Agent(com.thoughtworks.go.config.Agent)

Example 49 with Agent

use of com.thoughtworks.go.config.Agent in project gocd by gocd.

the class AgentRuntimeInfoTest method shouldInitializeTheFreeSpaceAtAgentSide.

@Test
public void shouldInitializeTheFreeSpaceAtAgentSide() {
    AgentIdentifier id = new Agent("uuid", "localhost", "176.19.4.1").getAgentIdentifier();
    AgentRuntimeInfo agentRuntimeInfo = new AgentRuntimeInfo(id, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie");
    assertThat(agentRuntimeInfo.getUsableSpace(), is(not(0L)));
}
Also used : Agent(com.thoughtworks.go.config.Agent) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) Test(org.junit.jupiter.api.Test)

Example 50 with Agent

use of com.thoughtworks.go.config.Agent in project gocd by gocd.

the class AgentRuntimeInfoTest method shouldBeUnknownWhenRegistrationRequestIsFromLocalAgent.

@Test
public void shouldBeUnknownWhenRegistrationRequestIsFromLocalAgent() {
    AgentRuntimeInfo agentRuntimeInfo = AgentRuntimeInfo.fromServer(new Agent("uuid", "localhost", "176.19.4.1"), false, "/var/lib", 0L, "linux");
    assertThat(agentRuntimeInfo.getRuntimeStatus(), is(AgentRuntimeStatus.Unknown));
}
Also used : Agent(com.thoughtworks.go.config.Agent) Test(org.junit.jupiter.api.Test)

Aggregations

Agent (com.thoughtworks.go.config.Agent)100 Test (org.junit.jupiter.api.Test)52 AgentInstance.createFromLiveAgent (com.thoughtworks.go.domain.AgentInstance.createFromLiveAgent)36 AgentInstance (com.thoughtworks.go.domain.AgentInstance)20 AgentStatusChangeListener (com.thoughtworks.go.listener.AgentStatusChangeListener)19 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)16 AgentRuntimeInfo (com.thoughtworks.go.server.service.AgentRuntimeInfo)13 NullAgentInstance (com.thoughtworks.go.domain.NullAgentInstance)11 JobInstance (com.thoughtworks.go.domain.JobInstance)8 ResponseEntity (org.springframework.http.ResponseEntity)8 ServerConfig (com.thoughtworks.go.config.ServerConfig)6 AgentIdentifier (com.thoughtworks.go.remote.AgentIdentifier)6 Username (com.thoughtworks.go.server.domain.Username)5 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)5 AgentInstance.createFromAgent (com.thoughtworks.go.domain.AgentInstance.createFromAgent)4 AgentBuildingInfo (com.thoughtworks.go.server.service.AgentBuildingInfo)4 Query (org.hibernate.Query)4 TransactionCallback (org.springframework.transaction.support.TransactionCallback)4 Gson (com.google.gson.Gson)3 ResourceConfig (com.thoughtworks.go.config.ResourceConfig)3