Search in sources :

Example 31 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 32 with AgentConfig

use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.

the class UpdateAgentStatusTest method setUp.

@Before
public void setUp() throws Exception {
    dbHelper.onSetUp();
    configHelper.onSetUp();
    configHelper.usingCruiseConfigDao(goConfigDao);
    preCondition = new PipelineWithTwoStages(materialRepository, transactionTemplate, temporaryFolder);
    preCondition.usingConfigHelper(configHelper).usingDbHelper(dbHelper).onSetUp();
    agentService.clearAll();
    agentService.requestRegistration(new Username("bob"), AgentRuntimeInfo.fromServer(new AgentConfig(agentId, "CCEDev01", "10.81.2.1"), false, "/var/lib", 0L, "linux", false));
    agentService.approve(agentId);
}
Also used : AgentConfig(com.thoughtworks.go.config.AgentConfig) PipelineWithTwoStages(com.thoughtworks.go.fixture.PipelineWithTwoStages) Username(com.thoughtworks.go.server.domain.Username) Before(org.junit.Before)

Example 33 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, agentStatusChangeListener());
    instance.enable();
    return instance;
}
Also used : AgentInstance(com.thoughtworks.go.domain.AgentInstance) AgentConfig(com.thoughtworks.go.config.AgentConfig)

Example 34 with AgentConfig

use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.

the class AgentConfigsUpdateValidator method isValid.

@Override
public boolean isValid(CruiseConfig preprocessedConfig) {
    boolean isValid = true;
    for (String uuid : agentsUuids) {
        AgentConfig agentConfig = preprocessedConfig.agents().getAgentByUuid(uuid);
        isValid = agentConfig.validateTree(ConfigSaveValidationContext.forChain(preprocessedConfig)) && isValid;
        validatedAgents.add(agentConfig);
    }
    return isValid;
}
Also used : AgentConfig(com.thoughtworks.go.config.AgentConfig)

Example 35 with AgentConfig

use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.

the class AgentInstanceTest method shouldOrderByHostname.

@Test
public void shouldOrderByHostname() throws Exception {
    AgentInstance agentA = new AgentInstance(new AgentConfig("UUID", "A", "127.0.0.1"), LOCAL, systemEnvironment, null);
    AgentInstance agentB = new AgentInstance(new AgentConfig("UUID", "B", "127.0.0.2"), LOCAL, systemEnvironment, null);
    assertThat(agentA.compareTo(agentA), is(0));
    assertThat(agentA.compareTo(agentB), lessThan(0));
    assertThat(agentB.compareTo(agentA), greaterThan(0));
}
Also used : AgentConfig(com.thoughtworks.go.config.AgentConfig) Test(org.junit.Test)

Aggregations

AgentConfig (com.thoughtworks.go.config.AgentConfig)90 Test (org.junit.Test)68 AgentInstance (com.thoughtworks.go.domain.AgentInstance)20 Agents (com.thoughtworks.go.config.Agents)13 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)11 AgentStatusChangeListener (com.thoughtworks.go.listener.AgentStatusChangeListener)10 Username (com.thoughtworks.go.server.domain.Username)7 ResponseEntity (org.springframework.http.ResponseEntity)7 ResourceConfig (com.thoughtworks.go.config.ResourceConfig)6 ResourceConfigs (com.thoughtworks.go.config.ResourceConfigs)5 AgentIdentifier (com.thoughtworks.go.remote.AgentIdentifier)5 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)5 GoConfigDao (com.thoughtworks.go.config.GoConfigDao)4 ServerConfig (com.thoughtworks.go.config.ServerConfig)4 UpdateConfigCommand (com.thoughtworks.go.config.UpdateConfigCommand)4 EnvironmentVariablesConfig (com.thoughtworks.go.config.EnvironmentVariablesConfig)3 ElasticProfile (com.thoughtworks.go.config.elastic.ElasticProfile)3 NullAgentInstance (com.thoughtworks.go.domain.NullAgentInstance)3 EnvironmentVariableConfig (com.thoughtworks.go.config.EnvironmentVariableConfig)2 StageConfig (com.thoughtworks.go.config.StageConfig)2