Search in sources :

Example 21 with AgentConfig

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;
}
Also used : AgentConfig(com.thoughtworks.go.config.AgentConfig) Username(com.thoughtworks.go.server.domain.Username) Date(java.util.Date)

Example 22 with AgentConfig

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;
}
Also used : AgentInstance(com.thoughtworks.go.domain.AgentInstance) AgentConfig(com.thoughtworks.go.config.AgentConfig)

Example 23 with AgentConfig

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));
}
Also used : AgentInstance(com.thoughtworks.go.domain.AgentInstance) AgentConfig(com.thoughtworks.go.config.AgentConfig) Test(org.junit.Test)

Example 24 with AgentConfig

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;
}
Also used : AgentInstance(com.thoughtworks.go.domain.AgentInstance) AgentConfig(com.thoughtworks.go.config.AgentConfig)

Example 25 with AgentConfig

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));
}
Also used : AgentConfig(com.thoughtworks.go.config.AgentConfig) Resource(com.thoughtworks.go.config.Resource) Resources(com.thoughtworks.go.config.Resources) Test(org.junit.Test)

Aggregations

AgentConfig (com.thoughtworks.go.config.AgentConfig)65 Test (org.junit.Test)45 AgentInstance (com.thoughtworks.go.domain.AgentInstance)15 Agents (com.thoughtworks.go.config.Agents)13 Username (com.thoughtworks.go.server.domain.Username)7 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)6 Resource (com.thoughtworks.go.config.Resource)5 Resources (com.thoughtworks.go.config.Resources)5 GoConfigDao (com.thoughtworks.go.config.GoConfigDao)4 SecurityConfig (com.thoughtworks.go.config.SecurityConfig)4 ServerConfig (com.thoughtworks.go.config.ServerConfig)4 UpdateConfigCommand (com.thoughtworks.go.config.UpdateConfigCommand)4 JobInstance (com.thoughtworks.go.domain.JobInstance)4 EnvironmentVariablesConfig (com.thoughtworks.go.config.EnvironmentVariablesConfig)3 NullAgentInstance (com.thoughtworks.go.domain.NullAgentInstance)3 AgentIdentifier (com.thoughtworks.go.remote.AgentIdentifier)3 HttpOperationResult (com.thoughtworks.go.server.service.result.HttpOperationResult)3 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)2 EnvironmentVariableConfig (com.thoughtworks.go.config.EnvironmentVariableConfig)2 StageConfig (com.thoughtworks.go.config.StageConfig)2