Search in sources :

Example 11 with ElasticProfile

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));
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) Test(org.junit.Test)

Example 12 with 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"));
}
Also used : ElasticConfig(com.thoughtworks.go.config.elastic.ElasticConfig) ElasticProfiles(com.thoughtworks.go.config.elastic.ElasticProfiles) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) Test(org.junit.Test)

Example 13 with ElasticProfile

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"));
}
Also used : ElasticConfig(com.thoughtworks.go.config.elastic.ElasticConfig) ElasticProfiles(com.thoughtworks.go.config.elastic.ElasticProfiles) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) Test(org.junit.Test)

Example 14 with ElasticProfile

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));
}
Also used : BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) Test(org.junit.Test)

Example 15 with 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);
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) Test(org.junit.Test)

Aggregations

ElasticProfile (com.thoughtworks.go.config.elastic.ElasticProfile)29 Test (org.junit.Test)23 ElasticProfiles (com.thoughtworks.go.config.elastic.ElasticProfiles)9 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)6 ElasticConfig (com.thoughtworks.go.config.elastic.ElasticConfig)4 ConfigurationKey (com.thoughtworks.go.domain.config.ConfigurationKey)4 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)4 ConfigurationValue (com.thoughtworks.go.domain.config.ConfigurationValue)4 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)4 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)3 BasicCruiseConfig (com.thoughtworks.go.config.BasicCruiseConfig)2 Gson (com.google.gson.Gson)1 Agents (com.thoughtworks.go.config.Agents)1 ArtifactPlans (com.thoughtworks.go.config.ArtifactPlans)1 EnvironmentVariablesConfig (com.thoughtworks.go.config.EnvironmentVariablesConfig)1 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)1 DefaultJobPlan (com.thoughtworks.go.domain.DefaultJobPlan)1 DefaultSchedulingContext (com.thoughtworks.go.domain.DefaultSchedulingContext)1 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)1 ValidationError (com.thoughtworks.go.plugin.api.response.validation.ValidationError)1