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);
}
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);
}
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);
}
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>");
}
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();
}
Aggregations