use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.
the class AgentInstanceTest method setUp.
@Before
public void setUp() {
systemEnvironment = new SystemEnvironment();
agentConfig = new AgentConfig("uuid2", "CCeDev01", DEFAULT_IP_ADDRESS);
defaultBuildingInfo = new AgentBuildingInfo("pipeline", "buildLocator");
agentStatusChangeListener = mock(AgentStatusChangeListener.class);
}
use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.
the class AgentInstanceTest method shouldReturnAJobPlanWithMatchingUuidSet.
@Test
public void shouldReturnAJobPlanWithMatchingUuidSet() throws Exception {
AgentConfig config = agentConfig("linux, mercurial");
AgentInstance agentInstance = new AgentInstance(config, LOCAL, systemEnvironment, null);
final JobPlan job = jobPlan("pipeline-name", "job-name", "resource", config.getUuid());
JobPlan matchingJob = agentInstance.firstMatching(new ArrayList<JobPlan>() {
{
add(job);
}
});
assertThat(matchingJob, is(job));
}
use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.
the class AgentInstanceTest method shouldNotBeEqualIfUuidIsNotEqual.
@Test
public void shouldNotBeEqualIfUuidIsNotEqual() throws Exception {
AgentInstance agentA = new AgentInstance(new AgentConfig("UUID", "A", "127.0.0.1"), LOCAL, systemEnvironment, null);
AgentInstance copyOfAgentA = new AgentInstance(new AgentConfig("UUID", "A", "127.0.0.1"), LOCAL, systemEnvironment, null);
AgentInstance agentB = new AgentInstance(new AgentConfig("UUID", "B", "127.0.0.2"), LOCAL, systemEnvironment, null);
assertThat(agentA, is(not(agentB)));
assertThat(agentB, is(not(agentA)));
assertThat(agentA, is(copyOfAgentA));
}
use of com.thoughtworks.go.config.AgentConfig 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()));
}
use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.
the class AgentsTest method shouldValidateDuplicateElasticAgentId.
@Test
public void shouldValidateDuplicateElasticAgentId() throws Exception {
Agents agents = new Agents();
AgentConfig elasticAgent1 = new AgentConfig("1", "localhost", "1");
elasticAgent1.setElasticAgentId("elastic-agent-id");
elasticAgent1.setElasticPluginId("awesome-elastic-agent");
AgentConfig elasticAgent2 = new AgentConfig("2", "localhost", "2");
elasticAgent2.setElasticAgentId("elastic-agent-id");
elasticAgent2.setElasticPluginId("awesome-elastic-agent");
agents.add(elasticAgent1);
agents.add(elasticAgent2);
agents.validate(new ConfigSaveValidationContext(agents));
assertThat(elasticAgent1.errors().size(), is(1));
assertThat(elasticAgent1.errors().getAllOn("elasticAgentId").get(0), is("Duplicate ElasticAgentId found for agents [1, 2]"));
assertThat(elasticAgent2.errors().size(), is(1));
assertThat(elasticAgent2.errors().getAllOn("elasticAgentId").get(0), is("Duplicate ElasticAgentId found for agents [1, 2]"));
}
Aggregations