use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.
the class AgentInstancesTest method shouldAddAgentIntoMemoryAfterAgentIsManuallyAddedInConfigFile.
@Test
public void shouldAddAgentIntoMemoryAfterAgentIsManuallyAddedInConfigFile() throws Exception {
AgentInstances agentInstances = new AgentInstances(null);
AgentConfig agentConfig = new AgentConfig("uuid20", "CCeDev01", "10.18.5.20");
agentInstances.sync(new Agents(agentConfig));
assertThat(agentInstances.size(), is(1));
assertThat(agentInstances.findAgentAndRefreshStatus("uuid20").agentConfig(), is(agentConfig));
}
use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.
the class AgentInstancesTest method shouldSupportConcurrentOperations.
@Test
public void shouldSupportConcurrentOperations() throws Exception {
final AgentInstances agentInstances = new AgentInstances(null);
// register 100 agents
for (int i = 0; i < 100; i++) {
AgentConfig agentConfig = new AgentConfig("uuid" + i, "CCeDev_" + i, "10.18.5." + i);
agentInstances.register(AgentRuntimeInfo.fromServer(agentConfig, false, "/var/lib", Long.MAX_VALUE, "linux", false));
}
thrown.expect(MaxPendingAgentsLimitReachedException.class);
thrown.expectMessage("Max pending agents allowed 100, limit reached");
AgentConfig agentConfig = new AgentConfig("uuid" + 200, "CCeDev_" + 200, "10.18.5." + 200);
agentInstances.register(AgentRuntimeInfo.fromServer(agentConfig, false, "/var/lib", Long.MAX_VALUE, "linux", false));
}
use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.
the class AgentRuntimeInfoTest method shouldNotMatchRuntimeInfosWithDifferentOperatingSystems.
@Test
public void shouldNotMatchRuntimeInfosWithDifferentOperatingSystems() {
AgentRuntimeInfo linux = AgentRuntimeInfo.fromServer(new AgentConfig("uuid", "localhost", "176.19.4.1"), true, "/var/lib", 0L, "linux", false);
AgentRuntimeInfo osx = AgentRuntimeInfo.fromServer(new AgentConfig("uuid", "localhost", "176.19.4.1"), true, "/var/lib", 0L, "foo bar", false);
assertThat(linux, is(not(osx)));
}
use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.
the class AgentRuntimeInfoTest method shouldUsingIdleWhenRegistrationRequestIsFromAlreadyRegisteredAgent.
@Test
public void shouldUsingIdleWhenRegistrationRequestIsFromAlreadyRegisteredAgent() {
AgentRuntimeInfo agentRuntimeInfo = AgentRuntimeInfo.fromServer(new AgentConfig("uuid", "localhost", "176.19.4.1"), true, "/var/lib", 0L, "linux", false);
assertThat(agentRuntimeInfo.getRuntimeStatus(), is(AgentRuntimeStatus.Idle));
}
use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.
the class AgentRuntimeInfoTest method shouldNotifyStatusChangeListenerOnStatusUpdate.
@Test
public void shouldNotifyStatusChangeListenerOnStatusUpdate() {
final AgentRuntimeStatus[] oldAndNewStatus = new AgentRuntimeStatus[2];
AgentRuntimeInfo agentRuntimeInfo = AgentRuntimeInfo.fromServer(new AgentConfig("uuid", "localhost", "176.19.4.1"), true, "/var/lib", 0L, "linux", false);
assertThat(agentRuntimeInfo.getRuntimeStatus(), is(AgentRuntimeStatus.Idle));
assertThat(oldAndNewStatus[OLD_IDX], is(nullValue()));
agentRuntimeInfo.setRuntimeStatus(AgentRuntimeStatus.Building, new AgentRuntimeStatus.ChangeListener() {
public void statusUpdateRequested(AgentRuntimeInfo runtimeInfo, AgentRuntimeStatus newStatus) {
oldAndNewStatus[OLD_IDX] = runtimeInfo.getRuntimeStatus();
oldAndNewStatus[NEW_IDX] = newStatus;
}
});
assertThat(oldAndNewStatus[OLD_IDX], is(AgentRuntimeStatus.Idle));
assertThat(oldAndNewStatus[NEW_IDX], is(AgentRuntimeStatus.Building));
assertThat(agentRuntimeInfo.getRuntimeStatus(), is(AgentRuntimeStatus.Building));
}
Aggregations