use of com.thoughtworks.go.config.Agent in project gocd by gocd.
the class RegisterAgentCommand method registerAgent.
private Optional<String> registerAgent() {
InetAddress localHost = getInetAddress();
Agent agent = new Agent("Perf-Test-Agent-" + UUID.randomUUID(), localHost.getHostName(), localHost.getHostAddress(), UUID.randomUUID().toString());
AgentRuntimeInfo agentRuntimeInfo = AgentRuntimeInfo.fromServer(agent, false, "location", 233232L, "osx");
agentService.requestRegistration(agentRuntimeInfo);
return Optional.ofNullable(agent.getUuid());
}
use of com.thoughtworks.go.config.Agent in project gocd by gocd.
the class StageIntegrationTest method setUp.
@BeforeEach
public void setUp(@TempDir Path tempDir) throws Exception {
dbHelper.onSetUp();
CONFIG_HELPER.usingCruiseConfigDao(goConfigDao);
CONFIG_HELPER.onSetUp();
TestRepo svnTestRepo = new SvnTestRepo(tempDir);
svnRepo = new SvnCommand(null, svnTestRepo.projectRepositoryUrl());
CONFIG_HELPER.addPipeline(PIPELINE_NAME, DEV_STAGE, svnRepo, "foo");
mingle = CONFIG_HELPER.addStageToPipeline(PIPELINE_NAME, FT_STAGE, "bar");
agentService.saveOrUpdate(new Agent(AGENT_UUID, HOSTNAME, "127.0.0.1", "cookie1"));
}
use of com.thoughtworks.go.config.Agent in project gocd by gocd.
the class AgentInstances method syncAgentInstancesFrom.
public void syncAgentInstancesFrom(Agents agentsFromDB) {
for (Agent agentFromDB : agentsFromDB) {
String uuid = agentFromDB.getUuid();
if (uuidToAgentInstanceMap.containsKey(uuid)) {
uuidToAgentInstanceMap.get(uuid).syncAgentFrom(agentFromDB);
} else {
AgentInstance newAgent = createFromAgent(agentFromDB, new SystemEnvironment(), agentStatusChangeListener);
uuidToAgentInstanceMap.put(uuid, newAgent);
}
}
synchronized (uuidToAgentInstanceMap) {
List<String> uuids = new ArrayList<>();
for (String uuid : uuidToAgentInstanceMap.keySet()) {
AgentInstance instance = uuidToAgentInstanceMap.get(uuid);
if (!(instance.getStatus() == AgentStatus.Pending)) {
if (!agentsFromDB.hasAgent(uuid)) {
uuids.add(uuid);
}
}
}
uuids.forEach(uuidToAgentInstanceMap::remove);
}
}
use of com.thoughtworks.go.config.Agent in project gocd by gocd.
the class AgentRuntimeInfoTest method shouldInitializeTheFreeSpaceAtAgentSide.
@Test
public void shouldInitializeTheFreeSpaceAtAgentSide() {
AgentIdentifier id = new Agent("uuid", "localhost", "176.19.4.1").getAgentIdentifier();
AgentRuntimeInfo agentRuntimeInfo = new AgentRuntimeInfo(id, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie");
assertThat(agentRuntimeInfo.getUsableSpace(), is(not(0L)));
}
use of com.thoughtworks.go.config.Agent in project gocd by gocd.
the class AgentRuntimeInfoTest method shouldBeUnknownWhenRegistrationRequestIsFromLocalAgent.
@Test
public void shouldBeUnknownWhenRegistrationRequestIsFromLocalAgent() {
AgentRuntimeInfo agentRuntimeInfo = AgentRuntimeInfo.fromServer(new Agent("uuid", "localhost", "176.19.4.1"), false, "/var/lib", 0L, "linux");
assertThat(agentRuntimeInfo.getRuntimeStatus(), is(AgentRuntimeStatus.Unknown));
}
Aggregations