Search in sources :

Example 56 with AgentConfig

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

the class AgentInstancesTest method shouldReturnFirstMatchedAgentsWhenHostNameHasMoreThanOneMatch.

@Test
public void shouldReturnFirstMatchedAgentsWhenHostNameHasMoreThanOneMatch() throws Exception {
    AgentInstance agent = AgentInstance.createFromConfig(new AgentConfig("uuid20", "CCeDev01", "10.18.5.20"), systemEnvironment, null);
    AgentInstance duplicatedAgent = AgentInstance.createFromConfig(new AgentConfig("uuid21", "CCeDev01", "10.18.5.20"), systemEnvironment, null);
    AgentInstances agentInstances = new AgentInstances(systemEnvironment, agentStatusChangeListener, agent, duplicatedAgent);
    AgentInstance byHostname = agentInstances.findFirstByHostname("CCeDev01");
    assertThat(byHostname, is(agent));
}
Also used : AgentInstance(com.thoughtworks.go.domain.AgentInstance) NullAgentInstance(com.thoughtworks.go.domain.NullAgentInstance) AgentConfig(com.thoughtworks.go.config.AgentConfig) Test(org.junit.Test)

Example 57 with AgentConfig

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

the class AgentInstancesTest method registerShouldErrorOutIfMaxPendingAgentsLimitIsReached.

@Test(expected = MaxPendingAgentsLimitReachedException.class)
public void registerShouldErrorOutIfMaxPendingAgentsLimitIsReached() {
    AgentConfig agentConfig = new AgentConfig("uuid2", "CCeDev01", "10.18.5.1");
    AgentInstances agentInstances = new AgentInstances(systemEnvironment, agentStatusChangeListener, AgentInstanceMother.pending());
    when(systemEnvironment.get(SystemEnvironment.MAX_PENDING_AGENTS_ALLOWED)).thenReturn(1);
    agentInstances.register(AgentRuntimeInfo.fromServer(agentConfig, false, "/var/lib", 0L, "linux", false));
}
Also used : AgentConfig(com.thoughtworks.go.config.AgentConfig) Test(org.junit.Test)

Example 58 with AgentConfig

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

the class AgentInstancesTest method shouldSyncAgent.

@Test
public void shouldSyncAgent() throws Exception {
    AgentInstances agentInstances = new AgentInstances(systemEnvironment, agentStatusChangeListener, AgentInstanceMother.building(), idle);
    AgentConfig agentConfig = new AgentConfig("uuid2", "CCeDev01", "10.18.5.1");
    agentConfig.setDisabled(true);
    Agents oneAgentIsRemoved = new Agents(agentConfig);
    agentInstances.sync(oneAgentIsRemoved);
    assertThat(agentInstances.findAgentAndRefreshStatus("uuid2").getStatus(), is(AgentStatus.Disabled));
}
Also used : AgentConfig(com.thoughtworks.go.config.AgentConfig) Agents(com.thoughtworks.go.config.Agents) Test(org.junit.Test)

Example 59 with AgentConfig

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

the class AgentInstancesTest method agentHostnameShouldBeUnique.

@Test
public void agentHostnameShouldBeUnique() {
    AgentConfig agentConfig = new AgentConfig("uuid2", "CCeDev01", "10.18.5.1");
    AgentInstances agentInstances = new AgentInstances(mock(AgentStatusChangeListener.class));
    agentInstances.register(AgentRuntimeInfo.fromServer(agentConfig, false, "/var/lib", 0L, "linux", false));
    agentInstances.register(AgentRuntimeInfo.fromServer(agentConfig, false, "/var/lib", 0L, "linux", false));
}
Also used : AgentConfig(com.thoughtworks.go.config.AgentConfig) AgentStatusChangeListener(com.thoughtworks.go.listener.AgentStatusChangeListener) Test(org.junit.Test)

Example 60 with AgentConfig

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

the class AgentRuntimeInfoTest method shouldReturnTrueIfUsableSpaceLessThanLimit.

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

Aggregations

AgentConfig (com.thoughtworks.go.config.AgentConfig)90 Test (org.junit.Test)68 AgentInstance (com.thoughtworks.go.domain.AgentInstance)20 Agents (com.thoughtworks.go.config.Agents)13 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)11 AgentStatusChangeListener (com.thoughtworks.go.listener.AgentStatusChangeListener)10 Username (com.thoughtworks.go.server.domain.Username)7 ResponseEntity (org.springframework.http.ResponseEntity)7 ResourceConfig (com.thoughtworks.go.config.ResourceConfig)6 ResourceConfigs (com.thoughtworks.go.config.ResourceConfigs)5 AgentIdentifier (com.thoughtworks.go.remote.AgentIdentifier)5 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)5 GoConfigDao (com.thoughtworks.go.config.GoConfigDao)4 ServerConfig (com.thoughtworks.go.config.ServerConfig)4 UpdateConfigCommand (com.thoughtworks.go.config.UpdateConfigCommand)4 EnvironmentVariablesConfig (com.thoughtworks.go.config.EnvironmentVariablesConfig)3 ElasticProfile (com.thoughtworks.go.config.elastic.ElasticProfile)3 NullAgentInstance (com.thoughtworks.go.domain.NullAgentInstance)3 EnvironmentVariableConfig (com.thoughtworks.go.config.EnvironmentVariableConfig)2 StageConfig (com.thoughtworks.go.config.StageConfig)2