use of com.thoughtworks.go.config.elastic.ElasticConfig in project gocd by gocd.
the class ElasticProfileServiceTest method setUp.
@BeforeEach
void setUp() throws Exception {
pluginId = "cd.go.elastic.ecs";
clusterProfileId = "prod-cluster";
elasticAgentExtension = mock(ElasticAgentExtension.class);
EntityHashingService hashingService = mock(EntityHashingService.class);
goConfigService = mock(GoConfigService.class);
secretParamResolver = mock(SecretParamResolver.class);
elasticProfileService = new ElasticProfileService(goConfigService, hashingService, elasticAgentExtension, secretParamResolver);
validator = mock(ElasticAgentProfileConfigurationValidator.class);
elasticProfileService.setProfileConfigurationValidator(validator);
ElasticConfig elasticConfig = new ElasticConfig();
elasticConfig.getClusterProfiles().add(new ClusterProfile(clusterProfileId, pluginId));
when(goConfigService.getElasticConfig()).thenReturn(elasticConfig);
BasicCruiseConfig cruiseConfig = new BasicCruiseConfig();
cruiseConfig.setElasticConfig(elasticConfig);
when(goConfigService.getConfigForEditing()).thenReturn(cruiseConfig);
}
use of com.thoughtworks.go.config.elastic.ElasticConfig in project gocd by gocd.
the class PipelineConfigSaveValidationContextTest method isValidProfileIdShouldBeValidInPresenceOfElasticProfile.
@Test
void isValidProfileIdShouldBeValidInPresenceOfElasticProfile() {
BasicCruiseConfig cruiseConfig = new BasicCruiseConfig();
ElasticConfig elasticConfig = new ElasticConfig();
elasticConfig.setProfiles(new ElasticProfiles(new ElasticProfile("docker.unit-test", "prod-cluster")));
cruiseConfig.setElasticConfig(elasticConfig);
ValidationContext context = PipelineConfigSaveValidationContext.forChain(true, "group", cruiseConfig, new PipelineConfig());
assertTrue(context.isValidProfileId("docker.unit-test"));
}
use of com.thoughtworks.go.config.elastic.ElasticConfig in project gocd by gocd.
the class PipelineConfigSaveValidationContextTest method isValidProfileIdShouldBeInValidInAbsenceOfElasticProfileForTheGivenId.
@Test
void isValidProfileIdShouldBeInValidInAbsenceOfElasticProfileForTheGivenId() {
BasicCruiseConfig cruiseConfig = new BasicCruiseConfig();
ElasticConfig elasticConfig = new ElasticConfig();
elasticConfig.setProfiles(new ElasticProfiles(new ElasticProfile("docker.unit-test", "prod-cluster")));
cruiseConfig.setElasticConfig(elasticConfig);
ValidationContext context = PipelineConfigSaveValidationContext.forChain(true, "group", cruiseConfig, new PipelineConfig());
assertThat(context.isValidProfileId("invalid.profile-id")).isFalse();
}
use of com.thoughtworks.go.config.elastic.ElasticConfig in project gocd by gocd.
the class ClusterProfilesChangedPluginNotifierTest method setUp.
@BeforeEach
void setUp() {
pluginId = "plugin-id";
when(goConfigService.getElasticConfig()).thenReturn(new ElasticConfig());
properties = new ArrayList<>();
properties.add(new ConfigurationProperty(new ConfigurationKey("key1"), new ConfigurationValue("value1")));
oldClusterProfile = new ClusterProfile("profile1", pluginId, properties);
newClusterProfile = new ClusterProfile("profile1", pluginId, properties);
notifier = new ClusterProfilesChangedPluginNotifier(goConfigService, registry, secretParamResolver, serverHealthService);
}
use of com.thoughtworks.go.config.elastic.ElasticConfig in project gocd by gocd.
the class ClusterProfilesChangedPluginNotifierTest method shouldNotifyPluginRegistryWhenAClusterProfileIsUpdated_WithAChangeInPluginId.
@Test
void shouldNotifyPluginRegistryWhenAClusterProfileIsUpdated_WithAChangeInPluginId() {
String newPluginId = "updated-plugin-id";
newClusterProfile = new ClusterProfile("profile1", newPluginId, properties);
reset(goConfigService);
ElasticConfig elasticConfig = new ElasticConfig();
elasticConfig.getClusterProfiles().add(oldClusterProfile);
when(goConfigService.getElasticConfig()).thenReturn(elasticConfig);
notifier = new ClusterProfilesChangedPluginNotifier(goConfigService, registry, secretParamResolver, serverHealthService);
notifier.onEntityConfigChange(newClusterProfile);
verify(secretParamResolver, times(2)).resolve(any(ClusterProfile.class));
verify(registry, times(1)).notifyPluginAboutClusterProfileChanged(this.pluginId, ClusterProfilesChangedStatus.DELETED, oldClusterProfile.getConfigurationAsMap(true), null);
verify(registry, times(1)).notifyPluginAboutClusterProfileChanged(newPluginId, ClusterProfilesChangedStatus.CREATED, null, newClusterProfile.getConfigurationAsMap(true));
verifyNoMoreInteractions(registry);
verify(goConfigService, times(3)).getElasticConfig();
}
Aggregations