Search in sources :

Example 11 with ResourceConfig

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

the class TriStateSelectionTest method shouldListResourceSelectionInAlhpaOrder.

@Test
public void shouldListResourceSelectionInAlhpaOrder() {
    HashSet<ResourceConfig> resourceConfigs = new HashSet<>();
    resourceConfigs.add(new ResourceConfig("B02"));
    resourceConfigs.add(new ResourceConfig("b01"));
    resourceConfigs.add(new ResourceConfig("a01"));
    List<TriStateSelection> selections = TriStateSelection.forAgentsResources(resourceConfigs, agents);
    assertThat(selections.get(0), Matchers.is(new TriStateSelection("a01", TriStateSelection.Action.remove)));
    assertThat(selections.get(1), Matchers.is(new TriStateSelection("b01", TriStateSelection.Action.remove)));
    assertThat(selections.get(2), Matchers.is(new TriStateSelection("B02", TriStateSelection.Action.remove)));
}
Also used : ResourceConfig(com.thoughtworks.go.config.ResourceConfig) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 12 with ResourceConfig

use of com.thoughtworks.go.config.ResourceConfig 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 13 with ResourceConfig

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

the class AgentInstanceTest method shouldNotMatchJobPlanIfTheAgentIsElasticAndJobHasResourcesDefined.

@Test
public void shouldNotMatchJobPlanIfTheAgentIsElasticAndJobHasResourcesDefined() {
    AgentConfig agentConfig = new AgentConfig("uuid", "hostname", "11.1.1.1", new ResourceConfigs(new ResourceConfig("r1")));
    agentConfig.setElasticAgentId("elastic-agent-id-1");
    String elasticPluginId = "elastic-plugin-id-1";
    agentConfig.setElasticPluginId(elasticPluginId);
    AgentInstance agentInstance = new AgentInstance(agentConfig, REMOTE, mock(SystemEnvironment.class), null);
    DefaultJobPlan jobPlan1 = new DefaultJobPlan();
    jobPlan1.setResources(asList(new Resource("r1")));
    List<JobPlan> jobPlans = asList(jobPlan1, new DefaultJobPlan());
    assertThat(agentInstance.firstMatching(jobPlans), is(nullValue()));
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) 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