use of com.thoughtworks.go.config.ResourceConfig in project gocd by gocd.
the class TriStateSelectionTest method shouldHaveActionAddIfAllAgentsHaveThatResource.
@Test
public void shouldHaveActionAddIfAllAgentsHaveThatResource() {
resourceConfigs.add(new ResourceConfig("all"));
agents.add(new AgentConfig("uuid1", "host1", "127.0.0.1", new ResourceConfigs("all")));
agents.add(new AgentConfig("uuid2", "host2", "127.0.0.2", new ResourceConfigs("all")));
List<TriStateSelection> selections = TriStateSelection.forAgentsResources(resourceConfigs, agents);
assertThat(selections, hasItem(new TriStateSelection("all", TriStateSelection.Action.add)));
}
use of com.thoughtworks.go.config.ResourceConfig in project gocd by gocd.
the class AgentViewModel method errors.
public ConfigErrors errors() {
ConfigErrors configErrors = new ConfigErrors();
configErrors.addAll(agentInstance.agentConfig().errors());
for (ResourceConfig resourceConfig : agentInstance.getResourceConfigs()) {
configErrors.addAll(resourceConfig.errors());
}
return configErrors;
}
use of com.thoughtworks.go.config.ResourceConfig in project gocd by gocd.
the class TriStateSelectionTest method before.
@Before
public void before() {
resourceConfigs = new HashSet<>();
resourceConfigs.add(new ResourceConfig("one"));
resourceConfigs.add(new ResourceConfig("two"));
agents = new Agents();
}
use of com.thoughtworks.go.config.ResourceConfig 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.ResourceConfig 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)));
}
Aggregations