use of com.thoughtworks.go.server.domain.AgentInstances in project gocd by gocd.
the class AgentServiceIntegrationTest method shouldLoadAllAgents.
@Test
public void shouldLoadAllAgents() throws Exception {
AgentInstance idle = AgentInstanceMother.idle(new Date(), "CCeDev01");
AgentInstance pending = AgentInstanceMother.pending();
AgentInstance building = AgentInstanceMother.building();
AgentInstance denied = AgentInstanceMother.disabled();
AgentService agentService = getAgentService(new AgentInstances(null, new SystemEnvironment(), idle, pending, building, denied));
assertThat(agentService.agents().size(), is(4));
assertThat(agentService.findAgentAndRefreshStatus(idle.agentConfig().getUuid()), is(idle));
assertThat(agentService.findAgentAndRefreshStatus(pending.agentConfig().getUuid()), is(pending));
assertThat(agentService.findAgentAndRefreshStatus(building.agentConfig().getUuid()), is(building));
assertThat(agentService.findAgentAndRefreshStatus(denied.agentConfig().getUuid()), is(denied));
}
use of com.thoughtworks.go.server.domain.AgentInstances in project gocd by gocd.
the class AgentServiceIntegrationTest method shouldMarkAgentAsLostContactIfAgentDidNotPingForMoreThanTimeout.
@Test
public void shouldMarkAgentAsLostContactIfAgentDidNotPingForMoreThanTimeout() throws Exception {
new SystemEnvironment().setProperty("agent.connection.timeout", "-1");
CONFIG_HELPER.addMailHost(new MailHost("ghost.name", 25, "loser", "boozer", true, false, "go@foo.mail.com", "admin@foo.mail.com"));
Date date = new Date(70, 1, 1, 1, 1, 1);
AgentInstance instance = AgentInstanceMother.idle(date, "CCeDev01");
((AgentRuntimeInfo) ReflectionUtil.getField(instance, "agentRuntimeInfo")).setOperatingSystem("Minix");
EmailSender mailSender = mock(EmailSender.class);
AgentService agentService = new AgentService(agentConfigService, new SystemEnvironment(), environmentConfigService, goConfigService, securityService, agentDao, new UuidGenerator(), serverHealthService, mailSender);
AgentInstances agentInstances = (AgentInstances) ReflectionUtil.getField(agentService, "agentInstances");
agentInstances.add(instance);
AgentInstances agents = agentService.findRegisteredAgents();
assertThat(agents.size(), is(1));
AgentInstance agentInstance = agents.findAgentAndRefreshStatus(instance.agentConfig().getUuid());
assertThat(agentInstance.getStatus(), is(AgentStatus.LostContact));
}
use of com.thoughtworks.go.server.domain.AgentInstances in project gocd by gocd.
the class ScheduleService method rescheduleHungJobs.
//Note: This is called from a Spring timer
public void rescheduleHungJobs() {
try {
//TODO 2779
AgentInstances knownAgents = agentService.findRegisteredAgents();
List<String> liveAgentIdList = getLiveAgentUuids(knownAgents);
if (!liveAgentIdList.isEmpty()) {
JobInstances jobs = jobInstanceService.findHungJobs(liveAgentIdList);
for (JobInstance buildId : jobs) {
LOGGER.warn("Found hung job[id=" + buildId + "], rescheduling it");
rescheduleJob(buildId);
}
}
} catch (Exception e) {
LOGGER.error("Error occured during reschedule hung builds: ", e);
}
}
use of com.thoughtworks.go.server.domain.AgentInstances in project gocd by gocd.
the class ScheduleServiceRescheduleHungJobsTest method shouldNotQueryForBuildWhenThereAreNoLiveAgents.
@Test
public void shouldNotQueryForBuildWhenThereAreNoLiveAgents() {
when(agentService.findRegisteredAgents()).thenReturn(new AgentInstances(null));
scheduleService.rescheduleHungJobs();
verify(agentService).findRegisteredAgents();
verify(jobInstanceService, times(0)).findHungJobs(any());
}
Aggregations