use of com.thoughtworks.go.config.Agents 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]"));
}
use of com.thoughtworks.go.config.Agents in project gocd by gocd.
the class AgentsTest method shouldFindAgentByUuid.
@Test
public void shouldFindAgentByUuid() {
Agents agents = new Agents();
agents.add(new AgentConfig("1", "localhost", "2"));
assertThat(agents.getAgentByUuid("1").getHostname(), is("localhost"));
}
use of com.thoughtworks.go.config.Agents in project gocd by gocd.
the class AgentsTest method shouldGiveAListOfUuids.
@Test
public void shouldGiveAListOfUuids() throws Exception {
Agents agents = new Agents();
agents.add(new AgentConfig("1", "localhost", "2"));
AgentConfig denied = new AgentConfig("2", "localhost", "2");
denied.setDisabled(true);
agents.add(denied);
Set<String> uuids = agents.acceptedUuids();
assertThat(uuids.size(), is(2));
assertThat(uuids, hasItem("1"));
assertThat(uuids, hasItem("2"));
}
use of com.thoughtworks.go.config.Agents in project gocd by gocd.
the class DefaultSchedulingContext method overrideEnvironmentVariables.
public SchedulingContext overrideEnvironmentVariables(EnvironmentVariablesConfig environmentVariablesConfig) {
DefaultSchedulingContext context = new DefaultSchedulingContext(approvedBy, new Agents(agents), profiles);
context.variables = variables.overrideWith(environmentVariablesConfig);
context.rerun = rerun;
return context;
}
use of com.thoughtworks.go.config.Agents in project gocd by gocd.
the class RestfulServiceTest method shouldFindOriginalWhenJobCopiedForRerun.
@Test
public void shouldFindOriginalWhenJobCopiedForRerun() throws Exception {
Pipeline pipeline = fixture.createdPipelineWithAllStagesPassed();
Stage stage = pipeline.getStages().byName(fixture.devStage);
JobInstance job = stage.findJob(PipelineWithTwoStages.JOB_FOR_DEV_STAGE);
Stage rerunStage = instanceFactory.createStageForRerunOfJobs(stage, a(PipelineWithTwoStages.DEV_STAGE_SECOND_JOB), new DefaultSchedulingContext("loser", new Agents()), fixture.pipelineConfig().getStage(new CaseInsensitiveString(fixture.devStage)), new TimeProvider(), "md5");
stageDao.saveWithJobs(pipeline, rerunStage);
dbHelper.passStage(rerunStage);
JobIdentifier result = restfulService.findJob(pipeline.getName(), String.valueOf(pipeline.getCounter()), stage.getName(), String.valueOf(rerunStage.getCounter()), job.getName());
JobIdentifier expect = new JobIdentifier(pipeline, stage, job);
assertThat(result, is(expect));
long copiedJobId = rerunStage.getJobInstances().getByName(job.getName()).getId();
// sanity check(its a copy, not the same)
assertThat(copiedJobId, is(not(job.getId())));
result = restfulService.findJob(pipeline.getName(), String.valueOf(pipeline.getCounter()), stage.getName(), String.valueOf(rerunStage.getCounter()), job.getName());
// still, the job identifier returned should be the same(because other one was a copy)
assertThat(result, is(expect));
result = restfulService.findJob(pipeline.getName(), String.valueOf(pipeline.getCounter()), stage.getName(), String.valueOf(rerunStage.getCounter()), job.getName(), copiedJobId);
// since caller knows the buildId, honor it(caller knows what she is doing)
assertThat(result, is(not(expect)));
assertThat(result, is(new JobIdentifier(rerunStage.getIdentifier(), job.getName(), copiedJobId)));
}
Aggregations