Search in sources :

Example 6 with ClusterProfiles

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);
}
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 7 with ClusterProfiles

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);
}
Also used : ElasticProfiles(com.thoughtworks.go.config.elastic.ElasticProfiles) ClusterProfiles(com.thoughtworks.go.config.elastic.ClusterProfiles) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) ClusterProfile(com.thoughtworks.go.config.elastic.ClusterProfile) Test(org.junit.jupiter.api.Test)

Example 8 with ClusterProfiles

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);
}
Also used : ClusterProfiles(com.thoughtworks.go.config.elastic.ClusterProfiles)

Example 9 with 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>");
}
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 10 with ClusterProfiles

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>");
}
Also used : ElasticAgentPluginInfo(com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo) 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)

Aggregations

ClusterProfiles (com.thoughtworks.go.config.elastic.ClusterProfiles)14 Test (org.junit.jupiter.api.Test)9 ClusterProfile (com.thoughtworks.go.config.elastic.ClusterProfile)8 Capabilities (com.thoughtworks.go.plugin.domain.elastic.Capabilities)4 ElasticAgentPluginInfo (com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo)4 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)4 BasicCruiseConfig (com.thoughtworks.go.config.BasicCruiseConfig)2 ElasticProfile (com.thoughtworks.go.config.elastic.ElasticProfile)2 ConfigurationKey (com.thoughtworks.go.domain.config.ConfigurationKey)2 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)2 ConfigurationValue (com.thoughtworks.go.domain.config.ConfigurationValue)2 ServerPingMessage (com.thoughtworks.go.server.messaging.elasticagents.ServerPingMessage)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)1 UpdateConfigCommand (com.thoughtworks.go.config.UpdateConfigCommand)1 ElasticConfig (com.thoughtworks.go.config.elastic.ElasticConfig)1 ElasticProfiles (com.thoughtworks.go.config.elastic.ElasticProfiles)1 RecordNotFoundException (com.thoughtworks.go.config.exceptions.RecordNotFoundException)1 Username (com.thoughtworks.go.server.domain.Username)1 GoConfigFileHelper (com.thoughtworks.go.util.GoConfigFileHelper)1