Search in sources :

Example 11 with ClusterProfile

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

the class ClusterProfilesServiceIntegrationTest method shouldCreateANewClusterProfile.

@Test
public void shouldCreateANewClusterProfile() throws Exception {
    String clusterId = "cluster1";
    HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
    ClusterProfile clusterProfile = new ClusterProfile(clusterId, "pluginid");
    assertThat(clusterProfilesService.getPluginProfiles().size(), is(0));
    clusterProfilesService.create(clusterProfile, new Username("Bob"), result);
    assertThat(result.isSuccessful(), is(true));
    assertThat(clusterProfilesService.getPluginProfiles().size(), is(1));
    assertThat(clusterProfilesService.getPluginProfiles().find(clusterId), is(clusterProfile));
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) Username(com.thoughtworks.go.server.domain.Username) ClusterProfile(com.thoughtworks.go.config.elastic.ClusterProfile) Test(org.junit.jupiter.api.Test)

Example 12 with ClusterProfile

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

the class ElasticProfileServiceIntegrationTest method setUp.

@BeforeEach
public void setUp() throws Exception {
    pluginId = "aws";
    clusterProfileId = "prod-cluster";
    elasticProfileId = "id";
    username = new Username("Bob");
    configHelper = new GoConfigFileHelper();
    configHelper.onSetUp();
    goConfigService.forceNotifyListeners();
    clusterProfile = new ClusterProfile(clusterProfileId, pluginId);
    elasticProfile = new ElasticProfile(elasticProfileId, clusterProfileId);
    newElasticProfile = new ElasticProfile(elasticProfileId, clusterProfileId, new ConfigurationProperty(new ConfigurationKey("key1"), new ConfigurationValue("value1")));
    goConfigService.updateConfig(cruiseConfig -> {
        BasicCruiseConfig basicCruiseConfig = new BasicCruiseConfig();
        basicCruiseConfig.initializeServer();
        ClusterProfiles clusterProfiles = new ClusterProfiles();
        clusterProfiles.add(clusterProfile);
        basicCruiseConfig.getElasticConfig().setClusterProfiles(clusterProfiles);
        return basicCruiseConfig;
    });
    elasticProfileService.setProfileConfigurationValidator(validator);
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) Username(com.thoughtworks.go.server.domain.Username) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) ClusterProfiles(com.thoughtworks.go.config.elastic.ClusterProfiles) GoConfigFileHelper(com.thoughtworks.go.util.GoConfigFileHelper) ClusterProfile(com.thoughtworks.go.config.elastic.ClusterProfile) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 13 with ClusterProfile

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

the class AddClusterProfileCommandTest method setUp.

@BeforeEach
void setUp() {
    config = new BasicCruiseConfig();
    clusterProfile = new ClusterProfile("cluster-id", "plugin-id");
    username = new Username("Bob");
    result = new HttpLocalizedOperationResult();
    command = new AddClusterProfileCommand(extension, goConfigService, clusterProfile, username, result);
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) Username(com.thoughtworks.go.server.domain.Username) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) ClusterProfile(com.thoughtworks.go.config.elastic.ClusterProfile) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 14 with ClusterProfile

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

the class PluginProfilesServiceTest method shouldAddExceptionsThrownByPluginInfraErrorOnPluginProfile.

@Test
void shouldAddExceptionsThrownByPluginInfraErrorOnPluginProfile() {
    ClusterProfile pluginProfile = new ClusterProfile();
    String errorMessage = "Plugin is missing!";
    Mockito.when(command.validateUsingExtension(any(), anyMap())).thenThrow(new GoPluginFrameworkException(errorMessage));
    assertThat(pluginProfile.hasErrors()).isFalse();
    service.validatePluginProperties(command, pluginProfile);
    assertThat(pluginProfile.hasErrors()).isTrue();
    assertThat(pluginProfile.errors().get("pluginId")).isEqualTo(Arrays.asList(errorMessage));
}
Also used : GoPluginFrameworkException(com.thoughtworks.go.plugin.infra.GoPluginFrameworkException) ClusterProfile(com.thoughtworks.go.config.elastic.ClusterProfile) Test(org.junit.jupiter.api.Test)

Example 15 with ClusterProfile

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

the class PluginProfilesServiceTest method shouldAddNotFoundExceptionsThrownOnPluginProfile.

@Test
void shouldAddNotFoundExceptionsThrownOnPluginProfile() {
    ClusterProfile pluginProfile = new ClusterProfile("foo", "plugin-id");
    String errorMessage = "Plugin with id `plugin-id` is not found.";
    Mockito.when(command.validateUsingExtension(any(), anyMap())).thenThrow(new RecordNotFoundException("Boom!"));
    assertThat(pluginProfile.hasErrors()).isFalse();
    service.validatePluginProperties(command, pluginProfile);
    assertThat(pluginProfile.hasErrors()).isTrue();
    assertThat(pluginProfile.errors().get("pluginId")).isEqualTo(Arrays.asList(errorMessage));
}
Also used : RecordNotFoundException(com.thoughtworks.go.config.exceptions.RecordNotFoundException) ClusterProfile(com.thoughtworks.go.config.elastic.ClusterProfile) Test(org.junit.jupiter.api.Test)

Aggregations

ClusterProfile (com.thoughtworks.go.config.elastic.ClusterProfile)69 Test (org.junit.jupiter.api.Test)39 ElasticProfile (com.thoughtworks.go.config.elastic.ElasticProfile)32 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)14 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)12 ConfigurationKey (com.thoughtworks.go.domain.config.ConfigurationKey)10 ConfigurationValue (com.thoughtworks.go.domain.config.ConfigurationValue)10 ElasticAgentPluginInfo (com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo)10 ClusterProfiles (com.thoughtworks.go.config.elastic.ClusterProfiles)8 Username (com.thoughtworks.go.server.domain.Username)8 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)7 BeforeEach (org.junit.jupiter.api.BeforeEach)7 ElasticConfig (com.thoughtworks.go.config.elastic.ElasticConfig)6 Capabilities (com.thoughtworks.go.plugin.domain.elastic.Capabilities)6 BasicCruiseConfig (com.thoughtworks.go.config.BasicCruiseConfig)5 RecordNotFoundException (com.thoughtworks.go.config.exceptions.RecordNotFoundException)5 JobAgentMetadata (com.thoughtworks.go.domain.JobAgentMetadata)4 ElasticAgentInformation (com.thoughtworks.go.plugin.access.elastic.models.ElasticAgentInformation)4 PluginConfiguration (com.thoughtworks.go.plugin.domain.common.PluginConfiguration)4 GoCipher (com.thoughtworks.go.security.GoCipher)4