use of com.thoughtworks.go.config.elastic.ClusterProfiles 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);
}
use of com.thoughtworks.go.config.elastic.ClusterProfiles in project gocd by gocd.
the class GoConfigMigratorIntegrationTest method shouldDefineNoOpClustersAsPartOfMigration119.
@Test
public void shouldDefineNoOpClustersAsPartOfMigration119() throws Exception {
String configContent = " <elastic>\n" + " <profiles>\n" + " <profile id=\"profile1\" pluginId=\"cd.go.contrib.elastic-agent.docker\">\n" + " <property>\n" + " <key>Image</key>\n" + " <value>alpine:latest</value>\n" + " </property>\n" + " </profile>" + " <profile id=\"profile2\" pluginId=\"cd.go.contrib.elasticagent.kubernetes\">\n" + " <property>\n" + " <key>Image</key>\n" + " <value>alpine:latest</value>\n" + " </property>\n" + " </profile>" + " <profile id=\"profile3\" pluginId=\"cd.go.contrib.elastic-agent.docker\">\n" + " <property>\n" + " <key>Image</key>\n" + " <value>alpine:latest</value>\n" + " </property>\n" + " </profile>" + " <profile id=\"profile4\" pluginId=\"com.thoughtworks.gocd.elastic-agent.azure\">\n" + " <property>\n" + " <key>Image</key>\n" + " <value>alpine:latest</value>\n" + " </property>\n" + " </profile>" + " <profile id=\"profile5\" pluginId=\"com.thoughtworks.gocd.elastic-agent.azure\">\n" + " <property>\n" + " <key>Image</key>\n" + " <value>alpine:latest</value>\n" + " </property>\n" + " </profile>" + " </profiles>" + " </elastic>";
String configXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<cruise schemaVersion=\"118\">\n" + configContent + "</cruise>";
ClusterProfile azureProfile = new ClusterProfile("no-op-cluster-for-com.thoughtworks.gocd.elastic-agent.azure", "com.thoughtworks.gocd.elastic-agent.azure");
ClusterProfile dockerProfile = new ClusterProfile("no-op-cluster-for-cd.go.contrib.elastic-agent.docker", "cd.go.contrib.elastic-agent.docker");
ClusterProfile kubernetesProfile = new ClusterProfile("no-op-cluster-for-cd.go.contrib.elasticagent.kubernetes", "cd.go.contrib.elasticagent.kubernetes");
CruiseConfig migratedConfig = migrateConfigAndLoadTheNewConfig(configXml);
ClusterProfiles newlyDefinedClusters = migratedConfig.getElasticConfig().getClusterProfiles();
ElasticProfiles migratedElasticAgentProfiles = migratedConfig.getElasticConfig().getProfiles();
assertThat(newlyDefinedClusters).hasSize(3);
assertThat(newlyDefinedClusters.find("no-op-cluster-for-com.thoughtworks.gocd.elastic-agent.azure")).isEqualTo(azureProfile);
assertThat(newlyDefinedClusters.find("no-op-cluster-for-cd.go.contrib.elastic-agent.docker")).isEqualTo(dockerProfile);
assertThat(newlyDefinedClusters.find("no-op-cluster-for-cd.go.contrib.elasticagent.kubernetes")).isEqualTo(kubernetesProfile);
ElasticProfile profile1 = new ElasticProfile("profile1", "no-op-cluster-for-cd.go.contrib.elastic-agent.docker", new ConfigurationProperty(new ConfigurationKey("Image"), new ConfigurationValue("alpine:latest")));
ElasticProfile profile2 = new ElasticProfile("profile2", "no-op-cluster-for-cd.go.contrib.elasticagent.kubernetes", new ConfigurationProperty(new ConfigurationKey("Image"), new ConfigurationValue("alpine:latest")));
ElasticProfile profile3 = new ElasticProfile("profile3", "no-op-cluster-for-cd.go.contrib.elastic-agent.docker", new ConfigurationProperty(new ConfigurationKey("Image"), new ConfigurationValue("alpine:latest")));
ElasticProfile profile4 = new ElasticProfile("profile4", "no-op-cluster-for-com.thoughtworks.gocd.elastic-agent.azure", new ConfigurationProperty(new ConfigurationKey("Image"), new ConfigurationValue("alpine:latest")));
ElasticProfile profile5 = new ElasticProfile("profile5", "no-op-cluster-for-com.thoughtworks.gocd.elastic-agent.azure", new ConfigurationProperty(new ConfigurationKey("Image"), new ConfigurationValue("alpine:latest")));
assertThat(migratedElasticAgentProfiles.find("profile1")).isEqualTo(profile1);
assertThat(migratedElasticAgentProfiles.find("profile2")).isEqualTo(profile2);
assertThat(migratedElasticAgentProfiles.find("profile3")).isEqualTo(profile3);
assertThat(migratedElasticAgentProfiles.find("profile4")).isEqualTo(profile4);
assertThat(migratedElasticAgentProfiles.find("profile5")).isEqualTo(profile5);
}
use of com.thoughtworks.go.config.elastic.ClusterProfiles in project gocd by gocd.
the class AddClusterProfileCommand method update.
@Override
public void update(CruiseConfig preprocessedConfig) throws Exception {
ClusterProfiles clusterProfiles = getPluginProfiles(preprocessedConfig);
clusterProfiles.add(profile);
preprocessedConfig.getElasticConfig().setClusterProfiles(clusterProfiles);
}
use of com.thoughtworks.go.config.elastic.ClusterProfiles 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.ClusterProfiles in project gocd by gocd.
the class ElasticAgentPluginServiceTest method shouldGetAPluginClusterReportWhenPluginSupportsStatusReport.
@Test
void shouldGetAPluginClusterReportWhenPluginSupportsStatusReport() {
final Capabilities capabilities = new Capabilities(false, true, false);
final GoPluginDescriptor descriptor = GoPluginDescriptor.builder().id("cd.go.example.plugin").build();
elasticAgentMetadataStore.setPluginInfo(new ElasticAgentPluginInfo(descriptor, null, null, null, null, capabilities));
ClusterProfile clusterProfile = new ClusterProfile("cluster-profile-id", "cd.go.example.plugin");
clusterProfile.addNewConfigurationWithValue("go-server-url", "server-url", false);
PluginProfiles<ClusterProfile> clusterProfiles = new ClusterProfiles(clusterProfile);
when(clusterProfilesService.getPluginProfiles()).thenReturn(clusterProfiles);
when(registry.getClusterStatusReport("cd.go.example.plugin", clusterProfile.getConfigurationAsMap(true))).thenReturn("<div>This is a cluster status report snippet.</div>");
final String clusterStatusReport = service.getClusterStatusReport("cd.go.example.plugin", "cluster-profile-id");
assertThat(clusterStatusReport).isEqualTo("<div>This is a cluster status report snippet.</div>");
}
Aggregations