use of com.thoughtworks.go.config.elastic.ElasticProfile in project gocd by gocd.
the class JobInstanceSqlMapDaoTest method shouldSaveJobAgentMetadata.
@Test
public void shouldSaveJobAgentMetadata() throws Exception {
JobInstance instance = jobInstanceDao.save(stageId, new JobInstance(JOB_NAME));
instance.setIdentifier(new JobIdentifier(savedPipeline, savedStage, instance));
ElasticProfile elasticProfile = new ElasticProfile("foo", "cd.go.elastic-agent:docker", Arrays.asList(new ConfigurationProperty(new ConfigurationKey("key"), new ConfigurationValue("value"))));
JobPlan plan = new DefaultJobPlan(new Resources("something"), new ArtifactPlans(), new ArtifactPropertiesGenerators(), instance.getId(), instance.getIdentifier(), null, new EnvironmentVariablesConfig(), new EnvironmentVariablesConfig(), elasticProfile);
jobInstanceDao.save(instance.getId(), plan);
JobPlan retrieved = jobInstanceDao.loadPlan(plan.getJobId());
assertThat(retrieved.getElasticProfile(), is(elasticProfile));
}
use of com.thoughtworks.go.config.elastic.ElasticProfile in project gocd by gocd.
the class ConfigSaveValidationContextTest method isValidProfileIdShouldBeInValidInAbsenceOfElasticProfileForTheGivenId.
@Test
public void isValidProfileIdShouldBeInValidInAbsenceOfElasticProfileForTheGivenId() {
BasicCruiseConfig cruiseConfig = new BasicCruiseConfig();
ElasticConfig elasticConfig = new ElasticConfig();
elasticConfig.setProfiles(new ElasticProfiles(new ElasticProfile("docker.unit-test", "docker")));
cruiseConfig.setServerConfig(new ServerConfig(elasticConfig));
ValidationContext context = ConfigSaveValidationContext.forChain(cruiseConfig);
assertFalse(context.isValidProfileId("invalid.profile-id"));
}
use of com.thoughtworks.go.config.elastic.ElasticProfile in project gocd by gocd.
the class ConfigSaveValidationContextTest method isValidProfileIdShouldBeValidInPresenceOfElasticProfile.
@Test
public void isValidProfileIdShouldBeValidInPresenceOfElasticProfile() {
BasicCruiseConfig cruiseConfig = new BasicCruiseConfig();
ElasticConfig elasticConfig = new ElasticConfig();
elasticConfig.setProfiles(new ElasticProfiles(new ElasticProfile("docker.unit-test", "docker")));
cruiseConfig.setServerConfig(new ServerConfig(elasticConfig));
ValidationContext context = ConfigSaveValidationContext.forChain(cruiseConfig);
assertTrue(context.isValidProfileId("docker.unit-test"));
}
use of com.thoughtworks.go.config.elastic.ElasticProfile in project gocd by gocd.
the class ElasticAgentProfileCreateCommandTest method shouldAddElasticProfile.
@Test
public void shouldAddElasticProfile() throws Exception {
BasicCruiseConfig cruiseConfig = GoConfigMother.defaultCruiseConfig();
ElasticProfile elasticProfile = new ElasticProfile("foo", "docker");
ElasticAgentProfileCreateCommand command = new ElasticAgentProfileCreateCommand(null, elasticProfile, extension, null, null);
command.update(cruiseConfig);
assertThat(cruiseConfig.server().getElasticConfig().getProfiles().find("foo"), equalTo(elasticProfile));
}
use of com.thoughtworks.go.config.elastic.ElasticProfile in project gocd by gocd.
the class ElasticAgentProfileDeleteCommandTest method shouldNotValidateIfProfileIsInUseByPipeline.
@Test
public void shouldNotValidateIfProfileIsInUseByPipeline() throws Exception {
ElasticProfile elasticProfile = new ElasticProfile("foo", "docker");
PipelineConfig pipelineConfig = PipelineConfigMother.createPipelineConfigWithJobConfigs("build-linux");
pipelineConfig.getStages().first().getJobs().first().resources().clear();
pipelineConfig.getStages().first().getJobs().first().setElasticProfileId("foo");
cruiseConfig.addPipeline("all", pipelineConfig);
assertThat(cruiseConfig.server().getElasticConfig().getProfiles(), is(empty()));
ElasticAgentProfileDeleteCommand command = new ElasticAgentProfileDeleteCommand(null, elasticProfile, null, null, new HttpLocalizedOperationResult());
thrown.expect(GoConfigInvalidException.class);
thrown.expectMessage("The elastic agent profile 'foo' is being referenced by pipeline(s): JobConfigIdentifier[build-linux:mingle:defaultJob].");
command.isValid(cruiseConfig);
}
Aggregations