Search in sources :

Example 1 with ElasticConfig

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

the class UpdateClusterProfileCommandTest method shouldValidateElasticAgentProfilesAsPartOfUpdateClusterProfile.

@Test
void shouldValidateElasticAgentProfilesAsPartOfUpdateClusterProfile() {
    ElasticConfig elasticConfig = new ElasticConfig();
    elasticConfig.getClusterProfiles().add(new ClusterProfile("cluster1", "ecs"));
    elasticConfig.getProfiles().add(new ElasticProfile("profile1", "cluster1"));
    config.setElasticConfig(elasticConfig);
    RecordNotFoundException exception = assertThrows(RecordNotFoundException.class, () -> command.isValid(config));
    assertThat(exception.getMessage()).isEqualTo("Cluster profile with id 'cluster-id' was not found!");
}
Also used : RecordNotFoundException(com.thoughtworks.go.config.exceptions.RecordNotFoundException) ElasticConfig(com.thoughtworks.go.config.elastic.ElasticConfig) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) ClusterProfile(com.thoughtworks.go.config.elastic.ClusterProfile) Test(org.junit.jupiter.api.Test)

Example 2 with ElasticConfig

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

the class ClusterProfilesServiceTest method shouldFetchClustersDefinedAsPartOfElasticTag.

@Test
void shouldFetchClustersDefinedAsPartOfElasticTag() {
    ElasticConfig elasticConfig = new ElasticConfig();
    elasticConfig.setClusterProfiles(new ClusterProfiles(clusterProfile));
    when(goConfigService.getElasticConfig()).thenReturn(elasticConfig);
    PluginProfiles<ClusterProfile> actualClusterProfiles = clusterProfilesService.getPluginProfiles();
    assertThat(actualClusterProfiles).isEqualTo(elasticConfig.getClusterProfiles());
}
Also used : ElasticConfig(com.thoughtworks.go.config.elastic.ElasticConfig) ClusterProfiles(com.thoughtworks.go.config.elastic.ClusterProfiles) ClusterProfile(com.thoughtworks.go.config.elastic.ClusterProfile) Test(org.junit.jupiter.api.Test)

Example 3 with ElasticConfig

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

the class ElasticProfileServiceTest method shouldReturnAnEmptyMapIfNoElasticProfiles.

@Test
void shouldReturnAnEmptyMapIfNoElasticProfiles() {
    ElasticConfig elasticConfig = new ElasticConfig();
    when(goConfigService.getElasticConfig()).thenReturn(elasticConfig);
    assertThat(elasticProfileService.listAll()).isEmpty();
}
Also used : ElasticConfig(com.thoughtworks.go.config.elastic.ElasticConfig) Test(org.junit.jupiter.api.Test)

Example 4 with ElasticConfig

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

the class ElasticProfileServiceTest method shouldReturnElasticProfileWithGivenIdWhenPresent.

@Test
void shouldReturnElasticProfileWithGivenIdWhenPresent() {
    ElasticConfig elasticConfig = new ElasticConfig();
    ElasticProfile elasticProfile = new ElasticProfile("ecs", "prod-cluster");
    elasticConfig.getProfiles().add(elasticProfile);
    BasicCruiseConfig cruiseConfig = new BasicCruiseConfig();
    cruiseConfig.setElasticConfig(elasticConfig);
    when(goConfigService.getConfigForEditing()).thenReturn(cruiseConfig);
    assertThat(elasticProfileService.findProfile("ecs")).isEqualTo(elasticProfile);
}
Also used : ElasticConfig(com.thoughtworks.go.config.elastic.ElasticConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) Test(org.junit.jupiter.api.Test)

Example 5 with ElasticConfig

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

the class ClusterProfilesChangedPluginNotifierTest method shouldNotifyPluginRegistryWhenANewClusterProfileIsCreated.

@Test
void shouldNotifyPluginRegistryWhenANewClusterProfileIsCreated() {
    reset(goConfigService);
    ElasticConfig elasticConfig = new ElasticConfig();
    elasticConfig.getClusterProfiles().add(newClusterProfile);
    when(goConfigService.getElasticConfig()).thenReturn(elasticConfig);
    notifier.onEntityConfigChange(newClusterProfile);
    verify(secretParamResolver).resolve(newClusterProfile);
    verify(registry, times(1)).notifyPluginAboutClusterProfileChanged(pluginId, ClusterProfilesChangedStatus.CREATED, null, newClusterProfile.getConfigurationAsMap(true));
    verifyNoMoreInteractions(registry);
    verify(goConfigService, times(2)).getElasticConfig();
}
Also used : ElasticConfig(com.thoughtworks.go.config.elastic.ElasticConfig) 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