Search in sources :

Example 11 with ElasticConfig

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);
}
Also used : ElasticAgentProfileConfigurationValidator(com.thoughtworks.go.server.service.plugins.validators.elastic.ElasticAgentProfileConfigurationValidator) ElasticConfig(com.thoughtworks.go.config.elastic.ElasticConfig) ElasticAgentExtension(com.thoughtworks.go.plugin.access.elastic.ElasticAgentExtension) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) ClusterProfile(com.thoughtworks.go.config.elastic.ClusterProfile) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 12 with ElasticConfig

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"));
}
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.jupiter.api.Test)

Example 13 with ElasticConfig

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();
}
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.jupiter.api.Test)

Example 14 with ElasticConfig

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);
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) ElasticConfig(com.thoughtworks.go.config.elastic.ElasticConfig) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) ClusterProfile(com.thoughtworks.go.config.elastic.ClusterProfile) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 15 with ElasticConfig

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

Aggregations

ElasticConfig (com.thoughtworks.go.config.elastic.ElasticConfig)15 Test (org.junit.jupiter.api.Test)13 ClusterProfile (com.thoughtworks.go.config.elastic.ClusterProfile)7 ElasticProfile (com.thoughtworks.go.config.elastic.ElasticProfile)5 BasicCruiseConfig (com.thoughtworks.go.config.BasicCruiseConfig)3 ElasticProfiles (com.thoughtworks.go.config.elastic.ElasticProfiles)2 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 ClusterProfiles (com.thoughtworks.go.config.elastic.ClusterProfiles)1 RecordNotFoundException (com.thoughtworks.go.config.exceptions.RecordNotFoundException)1 ConfigurationKey (com.thoughtworks.go.domain.config.ConfigurationKey)1 ConfigurationValue (com.thoughtworks.go.domain.config.ConfigurationValue)1 ElasticAgentExtension (com.thoughtworks.go.plugin.access.elastic.ElasticAgentExtension)1 ElasticAgentProfileConfigurationValidator (com.thoughtworks.go.server.service.plugins.validators.elastic.ElasticAgentProfileConfigurationValidator)1