Search in sources :

Example 6 with ResourceConfig

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)));
}
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 7 with ResourceConfig

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

Example 8 with ResourceConfig

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();
}
Also used : Agents(com.thoughtworks.go.config.Agents) ResourceConfig(com.thoughtworks.go.config.ResourceConfig) Before(org.junit.Before)

Example 9 with ResourceConfig

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")));
}
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 10 with ResourceConfig

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

Aggregations

ResourceConfig (com.thoughtworks.go.config.ResourceConfig)13 Test (org.junit.Test)8 AgentConfig (com.thoughtworks.go.config.AgentConfig)6 ResourceConfigs (com.thoughtworks.go.config.ResourceConfigs)6 AgentInstance (com.thoughtworks.go.domain.AgentInstance)3 HashSet (java.util.HashSet)2 Agents (com.thoughtworks.go.config.Agents)1 AgentViewModel (com.thoughtworks.go.server.ui.AgentViewModel)1 AgentsViewModel (com.thoughtworks.go.server.ui.AgentsViewModel)1 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)1 Date (java.util.Date)1 Before (org.junit.Before)1