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