use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.
the class AgentsTest method shouldFindAgentByUuid.
@Test
public void shouldFindAgentByUuid() {
Agents agents = new Agents();
agents.add(new AgentConfig("1", "localhost", "2"));
assertThat(agents.getAgentByUuid("1").getHostname(), is("localhost"));
}
use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.
the class AgentsTest method shouldGiveAListOfUuids.
@Test
public void shouldGiveAListOfUuids() throws Exception {
Agents agents = new Agents();
agents.add(new AgentConfig("1", "localhost", "2"));
AgentConfig denied = new AgentConfig("2", "localhost", "2");
denied.setDisabled(true);
agents.add(denied);
Set<String> uuids = agents.acceptedUuids();
assertThat(uuids.size(), is(2));
assertThat(uuids, hasItem("1"));
assertThat(uuids, hasItem("2"));
}
use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.
the class UpdateResourceCommand method update.
public CruiseConfig update(CruiseConfig cruiseConfig) throws Exception {
AgentConfig agentConfig = cruiseConfig.agents().getAgentByUuid(uuid);
agentConfig.getResourceConfigs().importFromCsv(resources);
return cruiseConfig;
}
use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.
the class ScheduleServiceRescheduleHungJobsIntegrationTest method shouldRescheduleHungBuildWhenAgentTryToGetWorkWithSameUuid.
@Test
public void shouldRescheduleHungBuildWhenAgentTryToGetWorkWithSameUuid() throws Exception {
AgentConfig agentConfig = AgentMother.localAgent();
AgentInstance instance = agent(agentConfig);
BuildCause buildCause = modifySomeFiles(evolveConfig);
dbHelper.saveMaterials(buildCause.getMaterialRevisions());
Pipeline pipeline = instanceFactory.createPipelineInstance(evolveConfig, buildCause, new DefaultSchedulingContext(DEFAULT_APPROVED_BY), "md5-test", new TimeProvider());
buildAssignmentService.onTimer();
Stage stage = pipeline.getFirstStage();
JobInstance jobInstance = stage.getJobInstances().get(0);
jobInstance.setAgentUuid(agentConfig.getUuid());
jobInstance.changeState(JobState.Building);
pipelineDao.saveWithStages(pipeline);
buildAssignmentService.onTimer();
buildAssignmentService.assignWorkToAgent(instance);
buildAssignmentService.onTimer();
buildAssignmentService.assignWorkToAgent(instance);
final Stage reloadedStage = stageDao.stageById(stage.getId());
final JobInstance rescheduledJob = reloadedStage.getJobInstances().getByName(jobInstance.getName());
assertThat(rescheduledJob.getState(), is(JobState.Assigned));
}
use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.
the class ScheduleServiceRescheduleHungJobsIntegrationTest method shouldNotRescheduleCancelledBuilds.
@Test
public void shouldNotRescheduleCancelledBuilds() throws SQLException {
String agentId = "uuid";
final Pipeline pipeline = instanceFactory.createPipelineInstance(evolveConfig, modifySomeFiles(evolveConfig), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), "md5-test", new TimeProvider());
dbHelper.savePipelineWithStagesAndMaterials(pipeline);
buildAssignmentService.assignWorkToAgent(agent(new AgentConfig(agentId)));
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
public void doInTransactionWithoutResult(TransactionStatus status) {
stageService.cancelStage(stageOf(pipeline));
}
});
scheduleService.rescheduleHungJobs();
JobInstance reloaded = jobInstanceDao.buildByIdWithTransitions(buildOf(pipeline).getId());
assertThat(reloaded.getState(), is(JobState.Completed));
assertThat(reloaded.getResult(), is(JobResult.Cancelled));
}
Aggregations