use of com.thoughtworks.go.server.domain.AgentInstances in project gocd by gocd.
the class ScheduleServiceRescheduleHungJobsTest method activities.
private AgentInstances activities() {
final AgentInstances activities = new AgentInstances(null);
SystemEnvironment systemEnvironment = new SystemEnvironment();
activities.add(AgentInstance.createFromConfig(new AgentConfig("uuid1"), systemEnvironment));
activities.add(AgentInstance.createFromConfig(new AgentConfig("uuid2"), systemEnvironment));
return activities;
}
use of com.thoughtworks.go.server.domain.AgentInstances in project gocd by gocd.
the class AgentConfigServiceIntegrationTest method setup.
@Before
public void setup() throws Exception {
agentInstances = new AgentInstances(new AgentRuntimeStatus.ChangeListener() {
@Override
public void statusUpdateRequested(AgentRuntimeInfo runtimeInfo, AgentRuntimeStatus newStatus) {
}
});
configHelper = new GoConfigFileHelper();
configHelper.usingCruiseConfigDao(goConfigDao).initializeConfigFile();
configHelper.onSetUp();
goConfigService.forceNotifyListeners();
}
use of com.thoughtworks.go.server.domain.AgentInstances in project gocd by gocd.
the class AgentServiceTest method setUp.
@Before
public void setUp() {
agentInstances = mock(AgentInstances.class);
AgentConfig config = new AgentConfig("uuid", "host", "192.168.1.1");
when(agentInstances.findAgentAndRefreshStatus("uuid")).thenReturn(AgentInstance.createFromConfig(config, new SystemEnvironment()));
agentDao = mock(AgentDao.class);
uuidGenerator = mock(UuidGenerator.class);
agentService = new AgentService(mock(AgentConfigService.class), new SystemEnvironment(), agentInstances, mock(EnvironmentConfigService.class), mock(GoConfigService.class), mock(SecurityService.class), agentDao, uuidGenerator, serverHealthService = mock(ServerHealthService.class));
agentIdentifier = config.getAgentIdentifier();
when(agentDao.cookieFor(agentIdentifier)).thenReturn("cookie");
}
use of com.thoughtworks.go.server.domain.AgentInstances in project gocd by gocd.
the class AgentsEntityConfigUpdateCommandTest method setUp.
@Before
public void setUp() throws Exception {
result = new HttpLocalizedOperationResult();
currentUser = new Username(new CaseInsensitiveString("user"));
cruiseConfig = new GoConfigMother().defaultCruiseConfig();
goConfigService = mock(GoConfigService.class);
agentInstances = mock(AgentInstances.class);
uuids = new ArrayList<>();
environmentsToAdd = new ArrayList<>();
environmentsToRemove = new ArrayList<>();
resourcesToAdd = new ArrayList<>();
resourcesToRemove = new ArrayList<>();
triState = TriState.TRUE;
when(goConfigService.getEnvironments()).thenReturn(cruiseConfig.getEnvironments());
}
use of com.thoughtworks.go.server.domain.AgentInstances in project gocd by gocd.
the class AgentServiceIntegrationTest method shouldThrowExceptionWhenADuplicateAgentTriesToUpdateStatus.
@Test
public void shouldThrowExceptionWhenADuplicateAgentTriesToUpdateStatus() throws Exception {
AgentInstance instance = AgentInstanceMother.building();
AgentService agentService = getAgentService(new AgentInstances(null, new SystemEnvironment(), instance));
AgentInstances agents = agentService.findRegisteredAgents();
String uuid = instance.agentConfig().getUuid();
assertThat(agents.findAgentAndRefreshStatus(uuid).getStatus(), is(AgentStatus.Building));
AgentIdentifier identifier = instance.agentConfig().getAgentIdentifier();
agentDao.associateCookie(identifier, "new_cookie");
AgentRuntimeInfo runtimeInfo = new AgentRuntimeInfo(identifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "old_cookie", false);
try {
agentService.updateRuntimeInfo(runtimeInfo);
fail("agent with bad cookie should not be able to update runtime info");
} catch (AgentWithDuplicateUUIDException e) {
assertThat(e.getMessage(), is(format("Agent [%s] has invalid cookie", runtimeInfo.agentInfoDebugString())));
}
agents = agentService.findRegisteredAgents();
assertThat(agents.findAgentAndRefreshStatus(uuid).getStatus(), is(AgentStatus.Building));
AgentIdentifier agentIdentifier = instance.agentConfig().getAgentIdentifier();
String cookie = agentService.assignCookie(agentIdentifier);
agentService.updateRuntimeInfo(new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), cookie, false));
}
Aggregations