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")));
}
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)));
}
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)));
}
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")));
}
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());
}
Aggregations