Search in sources :

Example 16 with ElasticProfile

use of com.thoughtworks.go.config.elastic.ElasticProfile in project gocd by gocd.

the class ElasticAgentProfileDeleteCommandTest method shouldRaiseExceptionInCaseProfileDoesNotExist.

@Test
public void shouldRaiseExceptionInCaseProfileDoesNotExist() throws Exception {
    ElasticProfile elasticProfile = new ElasticProfile("foo", "docker");
    assertThat(cruiseConfig.server().getElasticConfig().getProfiles(), is(empty()));
    ElasticAgentProfileDeleteCommand command = new ElasticAgentProfileDeleteCommand(null, elasticProfile, null, null, new HttpLocalizedOperationResult());
    thrown.expect(PluginProfileNotFoundException.class);
    command.update(cruiseConfig);
    assertThat(cruiseConfig.server().getElasticConfig().getProfiles(), is(empty()));
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) Test(org.junit.Test)

Example 17 with ElasticProfile

use of com.thoughtworks.go.config.elastic.ElasticProfile in project gocd by gocd.

the class ElasticAgentProfileUpdateCommandTest method shouldRaiseErrorWhenUpdatingNonExistentProfile.

@Test
public void shouldRaiseErrorWhenUpdatingNonExistentProfile() throws Exception {
    cruiseConfig.server().getElasticConfig().getProfiles().clear();
    ElasticAgentProfileUpdateCommand command = new ElasticAgentProfileUpdateCommand(null, new ElasticProfile("foo", "docker"), null, null, new HttpLocalizedOperationResult(), null, null);
    thrown.expect(PluginProfileNotFoundException.class);
    command.update(cruiseConfig);
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) Test(org.junit.Test)

Example 18 with ElasticProfile

use of com.thoughtworks.go.config.elastic.ElasticProfile in project gocd by gocd.

the class ElasticAgentProfileUpdateCommandTest method shouldNotContinueWithConfigSaveIfRequestIsNotFresh.

@Test
public void shouldNotContinueWithConfigSaveIfRequestIsNotFresh() {
    when(goConfigService.isUserAdmin(currentUser)).thenReturn(true);
    ElasticProfile oldProfile = new ElasticProfile("foo", "docker");
    ElasticProfile newProfile = new ElasticProfile("foo", "aws");
    cruiseConfig.server().getElasticConfig().getProfiles().add(oldProfile);
    EntityHashingService entityHashingService = mock(EntityHashingService.class);
    when(entityHashingService.md5ForEntity(oldProfile)).thenReturn("md5");
    HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
    ElasticAgentProfileUpdateCommand command = new ElasticAgentProfileUpdateCommand(goConfigService, newProfile, null, currentUser, result, entityHashingService, "bad-md5");
    assertThat(command.canContinue(cruiseConfig), is(false));
    assertThat(result.toString(), containsString("STALE_RESOURCE_CONFIG"));
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) EntityHashingService(com.thoughtworks.go.server.service.EntityHashingService) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) Test(org.junit.Test)

Example 19 with ElasticProfile

use of com.thoughtworks.go.config.elastic.ElasticProfile in project gocd by gocd.

the class ElasticAgentPluginServiceTest method plan.

private JobPlan plan(int jobId, String pluginId) {
    ElasticProfile elasticProfile = new ElasticProfile("id", pluginId);
    JobIdentifier identifier = new JobIdentifier("pipeline-" + jobId, 1, "1", "stage", "1", "job");
    return new DefaultJobPlan(null, new ArtifactPlans(), null, jobId, identifier, null, new EnvironmentVariablesConfig(), new EnvironmentVariablesConfig(), elasticProfile);
}
Also used : DefaultJobPlan(com.thoughtworks.go.domain.DefaultJobPlan) ArtifactPlans(com.thoughtworks.go.config.ArtifactPlans) EnvironmentVariablesConfig(com.thoughtworks.go.config.EnvironmentVariablesConfig) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) JobIdentifier(com.thoughtworks.go.domain.JobIdentifier)

Example 20 with ElasticProfile

use of com.thoughtworks.go.config.elastic.ElasticProfile in project gocd by gocd.

the class PipelineConfigSaveValidationContextTest 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 = PipelineConfigSaveValidationContext.forChain(true, "group", cruiseConfig, new PipelineConfig());
    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)

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