use of com.thoughtworks.go.domain.AgentInstance in project gocd by gocd.
the class AgentConfigServiceIntegrationTest method shouldEnablePendingAgents.
@Test
public void shouldEnablePendingAgents() throws Exception {
AgentInstance pendingAgent = AgentInstanceMother.pending();
agentInstances.add(pendingAgent);
assertThat(pendingAgent.isRegistered(), is(false));
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
ArrayList<String> uuids = new ArrayList<>();
uuids.add(pendingAgent.getUuid());
agentConfigService.bulkUpdateAgentAttributes(agentInstances, Username.ANONYMOUS, result, uuids, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), TriState.TRUE);
assertTrue(result.isSuccessful());
assertTrue(result.toString(), result.toString().contains("BULK_AGENT_UPDATE_SUCESSFUL"));
CruiseConfig cruiseConfig = goConfigDao.load();
assertThat(cruiseConfig.agents().getAgentByUuid(pendingAgent.getUuid()).isEnabled(), is(true));
}
use of com.thoughtworks.go.domain.AgentInstance in project gocd by gocd.
the class AgentServiceIntegrationTest method testShouldThrowErrorOnUpdatingAgentOnInvalidInputs.
@Test
public void testShouldThrowErrorOnUpdatingAgentOnInvalidInputs() throws Exception {
AgentConfig agent = createDisabledAndIdleAgent(UUID);
String originalHostname = agent.getHostname();
List<String> originalResourceNames = agent.getResourceConfigs().resourceNames();
goConfigDao.load();
assertThat(agentService.agents().size(), is(1));
assertThat(getFirstAgent().getHostname(), is(not("some-hostname")));
HttpOperationResult operationResult = new HttpOperationResult();
AgentInstance agentInstance = agentService.updateAgentAttributes(USERNAME, operationResult, UUID, "some-hostname", "lin!ux", null, TriState.UNSET);
assertThat(operationResult.httpCode(), is(422));
assertThat(operationResult.message(), is("Updating agent failed:"));
assertThat(agentInstance.agentConfig().getResourceConfigs().first().errors().on(JobConfig.RESOURCES), is("Resource name 'lin!ux' is not valid. Valid names much match '^[-\\w\\s|.]*$'"));
assertThat(agentService.agents().size(), is(1));
assertThat(getFirstAgent().getHostname(), is(originalHostname));
assertThat(getFirstAgent().getResourceConfigs().resourceNames(), is(originalResourceNames));
}
use of com.thoughtworks.go.domain.AgentInstance in project gocd by gocd.
the class AgentServiceIntegrationTest method shouldApproveAgent.
@Test
public void shouldApproveAgent() throws Exception {
AgentInstance pending = AgentInstanceMother.pending();
agentService.requestRegistration(new Username("bob"), AgentRuntimeInfo.fromServer(pending.agentConfig(), false, "var/lib", 0L, "linux", false));
agentService.approve(pending.getUuid());
assertThat(agentService.findRegisteredAgents().size(), is(1));
assertThat(agentService.findAgentAndRefreshStatus(pending.agentConfig().getUuid()).agentConfig().isDisabled(), is(false));
CruiseConfig cruiseConfig = goConfigDao.load();
assertThat(cruiseConfig.agents().get(0).isDisabled(), is(false));
}
use of com.thoughtworks.go.domain.AgentInstance 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(new SystemEnvironment(), agentStatusChangeListener(), 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.domain.AgentInstance in project gocd by gocd.
the class AgentServiceIntegrationTest method shouldDenyAgentWhenAgentChangedToDenyInConfigFile.
@Test
public void shouldDenyAgentWhenAgentChangedToDenyInConfigFile() throws Exception {
disableAgent();
AgentInstance instance = agentService.findAgentAndRefreshStatus("uuid1");
assertThat(instance.getStatus(), is(AgentStatus.Disabled));
}
Aggregations