use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.
the class ElasticAgentRuntimeInfoTest method shouldUpdateSelfForAnIdleAgent.
@Test
public void shouldUpdateSelfForAnIdleAgent() throws Exception {
ElasticAgentRuntimeInfo agentRuntimeInfo = new ElasticAgentRuntimeInfo(new AgentIdentifier("localhost", "127.0.0.1", "uuid"), AgentRuntimeStatus.Idle, "/foo/one", null, "42", "go.cd.elastic-agent-plugin.docker");
ElasticAgentRuntimeInfo newRuntimeInfo = new ElasticAgentRuntimeInfo(new AgentIdentifier("go02", "10.10.10.1", "uuid"), AgentStatus.Building.getRuntimeStatus(), "/foo/two", "cookie", "42", "go.cd.elastic-agent-plugin.docker");
agentRuntimeInfo.updateSelf(newRuntimeInfo);
assertThat(agentRuntimeInfo.getBuildingInfo(), is(newRuntimeInfo.getBuildingInfo()));
assertThat(agentRuntimeInfo.getLocation(), is(newRuntimeInfo.getLocation()));
assertThat(agentRuntimeInfo.getUsableSpace(), is(newRuntimeInfo.getUsableSpace()));
assertThat(agentRuntimeInfo.getOperatingSystem(), is(newRuntimeInfo.getOperatingSystem()));
assertThat(agentRuntimeInfo.getElasticAgentId(), is(newRuntimeInfo.getElasticAgentId()));
assertThat(agentRuntimeInfo.getElasticPluginId(), is(newRuntimeInfo.getElasticPluginId()));
}
use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.
the class ElasticAgentRuntimeInfoTest method shouldRefreshUsableSpaceOfAgent.
@Test
public void shouldRefreshUsableSpaceOfAgent() throws Exception {
AgentIdentifier identifier = new AgentIdentifier("local.in", "127.0.0.1", "uuid-1");
String workingDirectory = FileUtils.getTempDirectory().getAbsolutePath();
AgentRuntimeInfo runtimeInfo = ElasticAgentRuntimeInfo.fromAgent(identifier, AgentRuntimeStatus.Idle, workingDirectory, false);
long space = ElasticAgentRuntimeInfo.usableSpace(workingDirectory);
assertThat(runtimeInfo.getUsableSpace(), is(space));
}
use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.
the class BuildAssignmentServiceIntegrationTest method shouldRescheduleAbandonedBuild.
@Test
public void shouldRescheduleAbandonedBuild() throws SQLException {
AgentIdentifier instance = agent(AgentMother.localAgent());
Pipeline pipeline = instanceFactory.createPipelineInstance(evolveConfig, modifyNoFiles(evolveConfig), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider());
dbHelper.savePipelineWithStagesAndMaterials(pipeline);
buildAssignmentService.onConfigChange(goConfigService.getCurrentConfig());
buildAssignmentService.onTimer();
buildAssignmentService.assignWorkToAgent(instance);
long firstAssignedBuildId = buildOf(pipeline).getId();
//somehow agent abandoned its original build...
buildAssignmentService.assignWorkToAgent(instance);
JobInstance reloaded = jobInstanceDao.buildByIdWithTransitions(firstAssignedBuildId);
assertThat(reloaded.getState(), is(JobState.Rescheduled));
assertThat(reloaded.isIgnored(), is(true));
}
use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.
the class AgentServiceIntegrationTest method createDisabledAndIdleAgent.
private AgentConfig createDisabledAndIdleAgent(String uuid) {
AgentConfig agentConfig = new AgentConfig(uuid, "agentName", "127.0.0.9");
addAgent(agentConfig);
AgentIdentifier agentIdentifier = agentConfig.getAgentIdentifier();
String cookie = agentService.assignCookie(agentIdentifier);
AgentRuntimeInfo agentRuntimeInfo = new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), cookie, false);
agentRuntimeInfo.idle();
agentService.updateRuntimeInfo(agentRuntimeInfo);
assertTrue(agentService.findAgentAndRefreshStatus(uuid).isIdle());
agentService.disableAgents(USERNAME, new HttpOperationResult(), Arrays.asList(agentConfig.getUuid()));
AgentConfig updatedAgent = goConfigDao.load().agents().getAgentByUuid(agentConfig.getUuid());
assertThat(isDisabled(updatedAgent), is(true));
return updatedAgent;
}
use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.
the class AgentServiceIntegrationTest method disable.
private void disable(AgentConfig agentConfig) {
AgentIdentifier agentIdentifier = agentConfig.getAgentIdentifier();
String cookie = agentService.assignCookie(agentIdentifier);
AgentRuntimeInfo agentRuntimeInfo = new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), cookie, false);
agentRuntimeInfo.busy(new AgentBuildingInfo("path", "buildLocator"));
agentService.updateRuntimeInfo(agentRuntimeInfo);
agentService.disableAgents(USERNAME, new HttpOperationResult(), Arrays.asList(agentConfig.getUuid()));
assertThat(isDisabled(agentConfig), is(true));
}
Aggregations