Search in sources :

Example 66 with AgentConfig

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

the class AgentsEntityConfigUpdateCommandTest method shouldUpdateResourcesOfAgents.

@Test
public void shouldUpdateResourcesOfAgents() throws Exception {
    resourcesToAdd.add("firefox");
    resourcesToRemove.add("linux");
    AgentInstance agentInstance = AgentInstanceMother.disabled();
    AgentConfig agentConfig = agentInstance.agentConfig();
    agentConfig.addResourceConfig(new ResourceConfig("linux"));
    cruiseConfig.agents().add(agentConfig);
    assertThat(agentConfig.getResourceConfigs().resourceNames(), is(Arrays.asList("linux")));
    when(agentInstances.findAgent(agentConfig.getUuid())).thenReturn(agentInstance);
    uuids.add(agentConfig.getUuid());
    AgentsEntityConfigUpdateCommand command = new AgentsEntityConfigUpdateCommand(agentInstances, currentUser, result, uuids, environmentsToAdd, environmentsToRemove, triState, resourcesToAdd, resourcesToRemove, goConfigService);
    command.update(cruiseConfig);
    assertThat(agentConfig.getResourceConfigs().resourceNames(), is(Arrays.asList("firefox")));
}
Also used : AgentInstance(com.thoughtworks.go.domain.AgentInstance) AgentConfig(com.thoughtworks.go.config.AgentConfig) ResourceConfig(com.thoughtworks.go.config.ResourceConfig) Test(org.junit.Test)

Example 67 with AgentConfig

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

the class TriStateSelectionTest method shouldHaveActionRemoveIfNoAgentsHaveResource.

@Test
public void shouldHaveActionRemoveIfNoAgentsHaveResource() {
    resourceConfigs.add(new ResourceConfig("none"));
    agents.add(new AgentConfig("uuid1", "host1", "127.0.0.1", new ResourceConfigs("one")));
    agents.add(new AgentConfig("uuid2", "host2", "127.0.0.2", new ResourceConfigs("two")));
    List<TriStateSelection> selections = TriStateSelection.forAgentsResources(resourceConfigs, agents);
    assertThat(selections, hasItem(new TriStateSelection("none", TriStateSelection.Action.remove)));
}
Also used : AgentConfig(com.thoughtworks.go.config.AgentConfig) ResourceConfig(com.thoughtworks.go.config.ResourceConfig) ResourceConfigs(com.thoughtworks.go.config.ResourceConfigs) Test(org.junit.Test)

Example 68 with AgentConfig

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

the class TriStateSelectionTest method shouldBeNoChangeIfAllAgentsHaveThatResource.

@Test
public void shouldBeNoChangeIfAllAgentsHaveThatResource() {
    resourceConfigs.add(new ResourceConfig("some"));
    agents.add(new AgentConfig("uuid1", "host1", "127.0.0.1", new ResourceConfigs("some")));
    agents.add(new AgentConfig("uuid2", "host2", "127.0.0.2", new ResourceConfigs()));
    List<TriStateSelection> selections = TriStateSelection.forAgentsResources(resourceConfigs, agents);
    assertThat(selections, hasItem(new TriStateSelection("some", TriStateSelection.Action.nochange)));
}
Also used : AgentConfig(com.thoughtworks.go.config.AgentConfig) ResourceConfig(com.thoughtworks.go.config.ResourceConfig) ResourceConfigs(com.thoughtworks.go.config.ResourceConfigs) Test(org.junit.Test)

Example 69 with AgentConfig

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

the class AgentInstanceTest method shouldSyncIPWithConfig.

@Test
public void shouldSyncIPWithConfig() {
    AgentInstance original = AgentInstance.createFromConfig(agentConfig, systemEnvironment, mock(AgentStatusChangeListener.class));
    original.update(new AgentRuntimeInfo(new AgentIdentifier("CCeDev01", "10.18.5.2", "uuid2"), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false));
    assertThat(original.agentConfig(), is(new AgentConfig("uuid2", "CCeDev01", "10.18.5.2")));
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) AgentConfig(com.thoughtworks.go.config.AgentConfig) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) AgentStatusChangeListener(com.thoughtworks.go.listener.AgentStatusChangeListener) Test(org.junit.Test)

Example 70 with AgentConfig

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

the class AgentInstanceTest method syncConfigShouldUpdateElasticAgentRuntimeInfo.

@Test
public void syncConfigShouldUpdateElasticAgentRuntimeInfo() {
    AgentInstance agent = AgentInstanceMother.idle();
    AgentConfig agentConfig = new AgentConfig(agent.getUuid(), agent.getHostname(), agent.getIpAddress());
    agentConfig.setElasticAgentId("i-123456");
    agentConfig.setElasticPluginId("com.example.aws");
    assertFalse(agent.isElastic());
    agent.syncConfig(agentConfig);
    assertTrue(agent.isElastic());
    assertEquals("i-123456", agent.elasticAgentMetadata().elasticAgentId());
    assertEquals("com.example.aws", agent.elasticAgentMetadata().elasticPluginId());
}
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