use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.
the class ArtifactsControllerIntegrationTest method updateHeardTime.
private Date updateHeardTime() throws Exception {
agentService.requestRegistration(new Username("bob"), AgentRuntimeInfo.fromServer(new AgentConfig("uuid", "localhost", "127.0.0.1"), false, "/var/lib", 0L, "linux", false));
agentService.approve("uuid");
artifactsController.putArtifact(pipelineName, "latest", "stage", null, "build2", null, "/foo.xml", "uuid", request);
Date olderTime = agentService.findAgentAndRefreshStatus("uuid").getLastHeardTime();
return olderTime;
}
use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.
the class AgentService method updateAgentAttributes.
public AgentInstance updateAgentAttributes(Username username, HttpOperationResult result, String uuid, String newHostname, String resources, String environments, TriState enable) {
if (!hasOperatePermission(username, result)) {
return null;
}
AgentInstance agentInstance = findAgent(uuid);
if (isUnknownAgent(agentInstance, result)) {
return null;
}
AgentConfig agentConfig = agentConfigService.updateAgentAttributes(uuid, username, newHostname, resources, environments, enable, agentInstances, result);
if (agentConfig != null) {
return AgentInstance.createFromConfig(agentConfig, systemEnvironment);
}
return null;
}
use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.
the class AgentsEntityConfigUpdateCommandTest method shouldUpdateConfigStateOfAgents.
@Test
public void shouldUpdateConfigStateOfAgents() throws Exception {
AgentInstance agentInstance = AgentInstanceMother.disabled();
AgentConfig agentConfig = agentInstance.agentConfig();
agentConfig.disable();
cruiseConfig.agents().add(agentConfig);
assertThat(agentConfig.isEnabled(), is(false));
triState = TriState.TRUE;
uuids.add(agentConfig.getUuid());
when(agentInstances.findAgent(agentConfig.getUuid())).thenReturn(agentInstance);
AgentsEntityConfigUpdateCommand command = new AgentsEntityConfigUpdateCommand(agentInstances, currentUser, result, uuids, environmentsToAdd, environmentsToRemove, triState, resourcesToAdd, resourcesToRemove, goConfigService);
command.update(cruiseConfig);
assertThat(agentConfig.isEnabled(), is(true));
}
use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.
the class JobAssignmentTest method setupRemoteAgent.
private AgentInstance setupRemoteAgent() {
AgentConfig agentConfig = AgentMother.remoteAgent();
configHelper.addAgent(agentConfig);
AgentInstance instance = AgentInstance.createFromConfig(agentConfig, systemEnvironment);
instance.enable();
return instance;
}
use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.
the class AgentViewModelTest method shouldMapErrors.
@Test
public void shouldMapErrors() {
Resource resource1 = new Resource("foo");
Resource resource2 = new Resource("bar");
AgentConfig agentConfig = new AgentConfig("uuid", "host", "IP", new Resources(resource1, resource2));
agentConfig.addError(AgentConfig.IP_ADDRESS, "bad ip");
resource1.addError(Resource.NAME, "bad name for resource1");
resource2.addError(Resource.NAME, "bad name for resource2");
AgentViewModel model = new AgentViewModel(AgentInstance.createFromConfig(agentConfig, mock(SystemEnvironment.class)));
assertThat(model.errors().isEmpty(), is(false));
assertThat(model.errors().on(AgentConfig.IP_ADDRESS), is("bad ip"));
assertThat(model.errors().getAllOn(Resource.NAME).contains("bad name for resource1"), is(true));
assertThat(model.errors().getAllOn(Resource.NAME).contains("bad name for resource2"), is(true));
}
Aggregations