use of com.thoughtworks.go.server.service.result.HttpOperationResult in project gocd by gocd.
the class AgentServiceIntegrationTest method shouldEnableMultipleAgents.
@Test
public void shouldEnableMultipleAgents() {
AgentConfig agentConfig1 = createDisabledAgent(UUID);
AgentConfig agentConfig2 = createDisabledAgent(UUID2);
HttpOperationResult operationResult = new HttpOperationResult();
agentService.enableAgents(USERNAME, operationResult, Arrays.asList(UUID, UUID2));
assertThat(operationResult.httpCode(), is(200));
assertThat(isDisabled(agentConfig1), is(false));
assertThat(isDisabled(agentConfig2), is(false));
assertThat(operationResult.message(), containsString("Enabled 2 agent(s)"));
}
use of com.thoughtworks.go.server.service.result.HttpOperationResult in project gocd by gocd.
the class AgentServiceIntegrationTest method shouldDenyCorrectAgentWhenTwoOnSameBox.
@Test
public void shouldDenyCorrectAgentWhenTwoOnSameBox() throws Exception {
CONFIG_HELPER.addAgent(new AgentConfig(UUID, "agentName", "127.0.0.9", new ResourceConfigs("agent1")));
CONFIG_HELPER.addAgent(new AgentConfig(UUID2, "agentName", "127.0.0.9", new ResourceConfigs("agent2")));
CruiseConfig cruiseConfig = goConfigDao.load();
assertThat(cruiseConfig.agents().getAgentByUuid(UUID).isDisabled(), is(false));
assertThat(cruiseConfig.agents().getAgentByUuid(UUID2).isDisabled(), is(false));
agentService.initialize();
agentService.disableAgents(USERNAME, new HttpOperationResult(), Arrays.asList(UUID2));
CruiseConfig newCruiseConfig = goConfigDao.load();
assertThat(newCruiseConfig.agents().getAgentByUuid(UUID).isDisabled(), is(false));
assertThat(newCruiseConfig.agents().getAgentByUuid(UUID2).isDisabled(), is(true));
}
use of com.thoughtworks.go.server.service.result.HttpOperationResult in project gocd by gocd.
the class AgentServiceIntegrationTest method updateAgentAttributesShouldUpdateAnAgentEnableState.
@Test
public void updateAgentAttributesShouldUpdateAnAgentEnableState() throws Exception {
AgentConfig agent = createDisabledAndIdleAgent(UUID);
goConfigDao.load();
assertThat(agentService.agents().size(), is(1));
assertThat(getFirstAgent().isDisabled(), is(true));
HttpOperationResult operationResult = new HttpOperationResult();
agentService.updateAgentAttributes(USERNAME, operationResult, UUID, null, null, null, TriState.TRUE);
assertThat(operationResult.httpCode(), is(200));
assertThat(operationResult.message(), is("Updated agent with uuid uuid."));
assertThat(agentService.agents().size(), is(1));
assertThat(getFirstAgent().isDisabled(), is(false));
}
use of com.thoughtworks.go.server.service.result.HttpOperationResult in project gocd by gocd.
the class AgentServiceIntegrationTest method shouldAllowEnablingOfADisabledAgent.
@Test
public void shouldAllowEnablingOfADisabledAgent() {
String agentName = "agentName";
String agentId = DatabaseAccessHelper.AGENT_UUID;
AgentConfig agentConfig = new AgentConfig(agentId, agentName, "127.0.0.9");
addAgent(agentConfig);
disable(agentConfig);
HttpOperationResult operationResult = new HttpOperationResult();
agentService.enableAgents(USERNAME, operationResult, Arrays.asList(agentId));
assertThat(operationResult.httpCode(), is(200));
assertThat(operationResult.message(), is("Enabled 1 agent(s)"));
assertThat(isDisabled(agentConfig), is(false));
}
use of com.thoughtworks.go.server.service.result.HttpOperationResult in project gocd by gocd.
the class AgentServiceIntegrationTest method testShouldUpdateAnAgentIfInputsAreValid.
@Test
public void testShouldUpdateAnAgentIfInputsAreValid() throws Exception {
String headCommitBeforeUpdate = configRepository.getCurrentRevCommit().name();
AgentConfig agent = createDisabledAndIdleAgent(UUID);
createEnvironment("a", "b");
goConfigDao.load();
assertThat(agentService.agents().size(), is(1));
assertThat(getFirstAgent().getHostname(), is(not("some-hostname")));
assertThat(getFirstAgent().isDisabled(), is(true));
HttpOperationResult operationResult = new HttpOperationResult();
agentService.updateAgentAttributes(USERNAME, operationResult, UUID, "some-hostname", "linux,java", "a,b", TriState.UNSET);
assertThat(operationResult.httpCode(), is(200));
assertThat(operationResult.message(), is("Updated agent with uuid uuid."));
assertThat(agentService.agents().size(), is(1));
assertThat(getFirstAgent().getHostname(), is("some-hostname"));
assertThat(getFirstAgent().getResourceConfigs(), is(new ResourceConfigs("linux,java")));
assertThat(getFirstAgent().isDisabled(), is(true));
assertEquals(getEnvironments(getFirstAgent().getUuid()), new HashSet<>(Arrays.asList("a", "b")));
assertThat(configRepository.getCurrentRevCommit().name(), is(not(headCommitBeforeUpdate)));
assertThat(configRepository.getCurrentRevision().getUsername(), is(USERNAME.getDisplayName()));
}
Aggregations