Search in sources :

Example 51 with Agent

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

the class AgentRuntimeInfoTest method shouldReturnTrueIfUsableSpaceLessThanLimit.

@Test
public void shouldReturnTrueIfUsableSpaceLessThanLimit() {
    AgentRuntimeInfo agentRuntimeInfo = AgentRuntimeInfo.initialState(new Agent("uuid"));
    agentRuntimeInfo.setUsableSpace(10L);
    assertThat(agentRuntimeInfo.isLowDiskSpace(20L), is(true));
}
Also used : Agent(com.thoughtworks.go.config.Agent) Test(org.junit.jupiter.api.Test)

Example 52 with Agent

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

the class AgentInstanceTest method setUp.

@BeforeEach
void setUp() {
    systemEnvironment = new SystemEnvironment();
    agent = new Agent("uuid2", "CCeDev01", DEFAULT_IP_ADDRESS);
    defaultBuildingInfo = new AgentBuildingInfo("pipeline", "buildLocator");
    agentStatusChangeListener = mock(AgentStatusChangeListener.class);
    timeProvider = mock(TimeProvider.class);
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) AgentInstance.createFromLiveAgent(com.thoughtworks.go.domain.AgentInstance.createFromLiveAgent) Agent(com.thoughtworks.go.config.Agent) AgentBuildingInfo(com.thoughtworks.go.server.service.AgentBuildingInfo) TimeProvider(com.thoughtworks.go.util.TimeProvider) AgentStatusChangeListener(com.thoughtworks.go.listener.AgentStatusChangeListener) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 53 with Agent

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

the class AgentInstanceTest method shouldMarkAgentAsMissingWhenLastHeardTimeIsNull.

@Test
void shouldMarkAgentAsMissingWhenLastHeardTimeIsNull() {
    Agent agent = new Agent("1234", "localhost", "192.168.0.1");
    AgentInstance agentInstance = AgentInstance.createFromAgent(agent, new SystemEnvironment(), mock(AgentStatusChangeListener.class));
    agentInstance.refresh();
    assertThat(agentInstance.getRuntimeStatus()).isEqualTo(AgentRuntimeStatus.Missing);
    assertThat(agentInstance.getLastHeardTime()).isNotNull();
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) AgentInstance.createFromLiveAgent(com.thoughtworks.go.domain.AgentInstance.createFromLiveAgent) Agent(com.thoughtworks.go.config.Agent) AgentStatusChangeListener(com.thoughtworks.go.listener.AgentStatusChangeListener) Test(org.junit.jupiter.api.Test)

Example 54 with Agent

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

the class AgentInstanceTest method syncConfigShouldUpdateElasticAgentRuntimeInfo.

@Test
void syncConfigShouldUpdateElasticAgentRuntimeInfo() {
    AgentInstance agentInstance = AgentInstanceMother.idle();
    Agent agent = new Agent(agentInstance.getUuid(), agentInstance.getHostname(), agentInstance.getIpAddress());
    agent.setElasticAgentId("i-123456");
    agent.setElasticPluginId("com.example.aws");
    assertThat(agentInstance.isElastic()).isFalse();
    agentInstance.syncAgentFrom(agent);
    assertThat(agentInstance.isElastic()).isTrue();
    assertThat(agentInstance.elasticAgentMetadata().elasticAgentId()).isEqualTo("i-123456");
    assertThat(agentInstance.elasticAgentMetadata().elasticPluginId()).isEqualTo("com.example.aws");
}
Also used : AgentInstance.createFromLiveAgent(com.thoughtworks.go.domain.AgentInstance.createFromLiveAgent) Agent(com.thoughtworks.go.config.Agent) Test(org.junit.jupiter.api.Test)

Example 55 with Agent

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

the class AgentInstanceTest method shouldNotBeEqualIfUuidIsNotEqual.

@Test
void shouldNotBeEqualIfUuidIsNotEqual() {
    AgentInstance agentA = new AgentInstance(new Agent("UUID", "A", "127.0.0.1"), LOCAL, systemEnvironment, null);
    AgentInstance copyOfAgentA = new AgentInstance(new Agent("UUID", "A", "127.0.0.1"), LOCAL, systemEnvironment, null);
    AgentInstance agentB = new AgentInstance(new Agent("UUID", "B", "127.0.0.2"), LOCAL, systemEnvironment, null);
    assertThat(agentA).isNotEqualTo(agentB);
    assertThat(agentB).isNotEqualTo(agentA);
    assertThat(agentA).isEqualTo(copyOfAgentA);
}
Also used : AgentInstance.createFromLiveAgent(com.thoughtworks.go.domain.AgentInstance.createFromLiveAgent) 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