Search in sources :

Example 51 with ClusterProfile

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

the class UpdateClusterProfileCommandTest method setUp.

@BeforeEach
void setUp() {
    config = new BasicCruiseConfig();
    clusterProfile = new ClusterProfile("cluster-id", "plugin-id");
    config.getElasticConfig().getClusterProfiles().add(clusterProfile);
    username = new Username("Bob");
    result = new HttpLocalizedOperationResult();
    command = new UpdateClusterProfileCommand(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 52 with ClusterProfile

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

the class CreateAgentMessageTest method shouldReturnResolvedValues.

@Test
void shouldReturnResolvedValues() {
    ConfigurationProperty k1 = ConfigurationPropertyMother.create("key", "value");
    ConfigurationProperty k2 = ConfigurationPropertyMother.create("key1", false, "{{SECRET:[config_id][lookup_key]}}");
    k2.getSecretParams().get(0).setValue("some-resolved-value");
    ElasticProfile elasticProfile = new ElasticProfile("foo", "prod-cluster", k1, k2);
    ClusterProfile clusterProfile = new ClusterProfile("foo", "plugin-id", k1, k2);
    Map<String, String> clusterProfileConfigurations = clusterProfile.getConfigurationAsMap(true, true);
    Map<String, String> configurationAsMap = elasticProfile.getConfigurationAsMap(true, true);
    CreateAgentMessage message = new CreateAgentMessage("key", "env", elasticProfile, clusterProfile, null);
    assertThat(message.pluginId()).isEqualTo(clusterProfile.getPluginId());
    assertThat(message.getClusterProfileConfiguration()).isEqualTo(clusterProfileConfigurations);
    assertThat(message.configuration()).isEqualTo(configurationAsMap);
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) ClusterProfile(com.thoughtworks.go.config.elastic.ClusterProfile) Test(org.junit.jupiter.api.Test)

Example 53 with ClusterProfile

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

the class CreateAgentMessageTest method shouldGetPluginId.

@Test
void shouldGetPluginId() {
    List<ConfigurationProperty> properties = singletonList(new ConfigurationProperty(new ConfigurationKey("key"), new ConfigurationValue("value")));
    ElasticProfile elasticProfile = new ElasticProfile("foo", "prod-cluster", properties);
    ClusterProfile clusterProfile = new ClusterProfile("foo", "plugin-id", properties);
    Map<String, String> clusterProfileConfigurations = clusterProfile.getConfigurationAsMap(true);
    Map<String, String> configurationAsMap = elasticProfile.getConfigurationAsMap(true);
    CreateAgentMessage message = new CreateAgentMessage("key", "env", elasticProfile, clusterProfile, null);
    assertThat(message.pluginId()).isEqualTo(clusterProfile.getPluginId());
    assertThat(message.getClusterProfileConfiguration()).isEqualTo(clusterProfileConfigurations);
    assertThat(message.configuration()).isEqualTo(configurationAsMap);
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) ClusterProfile(com.thoughtworks.go.config.elastic.ClusterProfile) Test(org.junit.jupiter.api.Test)

Example 54 with ClusterProfile

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

the class ElasticAgentPluginServiceTest method shouldPassAlongAllClusterProfilesBelongingToThePluginWhileGettingPluginStatusReport.

@Test
void shouldPassAlongAllClusterProfilesBelongingToThePluginWhileGettingPluginStatusReport() {
    final Capabilities capabilities = new Capabilities(true);
    final GoPluginDescriptor descriptor = GoPluginDescriptor.builder().id("cd.go.example.plugin").build();
    elasticAgentMetadataStore.setPluginInfo(new ElasticAgentPluginInfo(descriptor, null, null, null, null, capabilities));
    ClusterProfiles allClusterProfiles = new ClusterProfiles();
    ClusterProfile cluster1 = new ClusterProfile("id1", "cd.go.example.plugin", new ConfigurationProperty(new ConfigurationKey("key1"), new ConfigurationValue("value1")));
    ClusterProfile cluster2 = new ClusterProfile("id2", "cd.go.example.plugin2", new ConfigurationProperty(new ConfigurationKey("key2"), new ConfigurationValue("value2")));
    allClusterProfiles.add(cluster1);
    allClusterProfiles.add(cluster2);
    when(clusterProfilesService.getPluginProfiles()).thenReturn(allClusterProfiles);
    when(registry.getPluginStatusReport("cd.go.example.plugin", asList(cluster1.getConfigurationAsMap(true)))).thenReturn("<div>This is a plugin status report snippet.</div>");
    final String pluginStatusReport = service.getPluginStatusReport("cd.go.example.plugin");
    assertThat(pluginStatusReport).isEqualTo("<div>This is a plugin status report snippet.</div>");
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) ElasticAgentPluginInfo(com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) Capabilities(com.thoughtworks.go.plugin.domain.elastic.Capabilities) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) ClusterProfiles(com.thoughtworks.go.config.elastic.ClusterProfiles) ClusterProfile(com.thoughtworks.go.config.elastic.ClusterProfile) Test(org.junit.jupiter.api.Test)

Example 55 with ClusterProfile

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

the class ElasticAgentPluginServiceTest method shouldAssignJobToAnAgentIfThePluginMatchesForTheAgentAndJob_AndThePluginAgreesToTheAssignment.

@Test
void shouldAssignJobToAnAgentIfThePluginMatchesForTheAgentAndJob_AndThePluginAgreesToTheAssignment() {
    String uuid = randomUUID().toString();
    String elasticPluginId = "plugin-1";
    ElasticAgentMetadata agentMetadata = new ElasticAgentMetadata(uuid, uuid, elasticPluginId, AgentRuntimeStatus.Idle, AgentConfigStatus.Enabled);
    ElasticProfile elasticProfile = new ElasticProfile("1", "clusterProfileId");
    when(registry.shouldAssignWork(any(), any(), any(), any(), any(), any())).thenReturn(true);
    assertThat(service.shouldAssignWork(agentMetadata, null, elasticProfile, new ClusterProfile("clusterProfileId", elasticPluginId), null)).isTrue();
}
Also used : ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) ElasticAgentMetadata(com.thoughtworks.go.server.domain.ElasticAgentMetadata) 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