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));
}
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));
}
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));
}
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));
}
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));
}
Aggregations