Search in sources :

Example 6 with Agent

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

the class AgentRuntimeInfoTest method shouldUsingIdleWhenRegistrationRequestIsFromAlreadyRegisteredAgent.

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

Example 7 with Agent

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

the class AgentRuntimeInfoTest method shouldNotMatchRuntimeInfosWithDifferentOperatingSystems.

@Test
public void shouldNotMatchRuntimeInfosWithDifferentOperatingSystems() {
    AgentRuntimeInfo linux = AgentRuntimeInfo.fromServer(new Agent("uuid", "localhost", "176.19.4.1"), true, "/var/lib", 0L, "linux");
    AgentRuntimeInfo osx = AgentRuntimeInfo.fromServer(new Agent("uuid", "localhost", "176.19.4.1"), true, "/var/lib", 0L, "foo bar");
    assertThat(linux, is(not(osx)));
}
Also used : Agent(com.thoughtworks.go.config.Agent) Test(org.junit.jupiter.api.Test)

Example 8 with Agent

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

the class AgentInstancesTest method registerShouldThrowExceptionWhenMaxPendingAgentsLimitIsReached.

@Test
void registerShouldThrowExceptionWhenMaxPendingAgentsLimitIsReached() {
    Agent agent = new Agent("uuid2", "CCeDev01", "10.18.5.1");
    AgentInstances agentInstances = new AgentInstances(systemEnvironment, listener, pending());
    when(systemEnvironment.get(MAX_PENDING_AGENTS_ALLOWED)).thenReturn(1);
    MaxPendingAgentsLimitReachedException e = assertThrows(MaxPendingAgentsLimitReachedException.class, () -> agentInstances.register(fromServer(agent, false, "/var/lib", 0L, "linux")));
    assertThat(e.getMessage(), is("Max pending agents allowed 1, limit reached"));
}
Also used : AgentInstance.createFromLiveAgent(com.thoughtworks.go.domain.AgentInstance.createFromLiveAgent) AgentInstance.createFromAgent(com.thoughtworks.go.domain.AgentInstance.createFromAgent) Agent(com.thoughtworks.go.config.Agent) MaxPendingAgentsLimitReachedException(com.thoughtworks.go.domain.exception.MaxPendingAgentsLimitReachedException) Test(org.junit.jupiter.api.Test)

Example 9 with Agent

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

the class AgentInstancesTest method createElasticAgent.

private Agent createElasticAgent(String uuid, String ip, String elasticAgentId, String elasticPluginId) {
    Agent elasticAgent = new Agent(uuid);
    elasticAgent.setElasticAgentId(elasticAgentId);
    elasticAgent.setElasticPluginId(elasticPluginId);
    elasticAgent.setIpaddress(ip);
    return elasticAgent;
}
Also used : AgentInstance.createFromLiveAgent(com.thoughtworks.go.domain.AgentInstance.createFromLiveAgent) AgentInstance.createFromAgent(com.thoughtworks.go.domain.AgentInstance.createFromAgent) Agent(com.thoughtworks.go.config.Agent)

Example 10 with Agent

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

the class AgentInstancesTest method createElasticAgentInstance.

private AgentInstance createElasticAgentInstance(int counter, String elasticPluginId) {
    String uuid = UUID.randomUUID().toString();
    String ip = "127.0.0.1";
    String host = "localhost";
    String elasticAgentId = "elastic-agent-id-" + counter;
    AgentIdentifier id = new AgentIdentifier(host, ip, uuid);
    ElasticAgentRuntimeInfo elasticRuntime = new ElasticAgentRuntimeInfo(id, Idle, "/foo/one", null, elasticAgentId, elasticPluginId);
    Agent elasticAgent = createElasticAgent(uuid, ip, elasticAgentId, elasticPluginId);
    AgentInstance elasticAgentInstance = createFromAgent(elasticAgent, new SystemEnvironment(), mock(AgentStatusChangeListener.class));
    elasticAgentInstance.update(elasticRuntime);
    return elasticAgentInstance;
}
Also used : AgentInstance(com.thoughtworks.go.domain.AgentInstance) NullAgentInstance(com.thoughtworks.go.domain.NullAgentInstance) SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) AgentInstance.createFromLiveAgent(com.thoughtworks.go.domain.AgentInstance.createFromLiveAgent) AgentInstance.createFromAgent(com.thoughtworks.go.domain.AgentInstance.createFromAgent) Agent(com.thoughtworks.go.config.Agent) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) ElasticAgentRuntimeInfo(com.thoughtworks.go.server.service.ElasticAgentRuntimeInfo) AgentStatusChangeListener(com.thoughtworks.go.listener.AgentStatusChangeListener)

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