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()));
}
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);
}
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"));
}
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);
}
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"));
}
Aggregations