Search in sources :

Example 26 with ElasticProfile

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

the class ElasticAgentProfileUpdateCommand method update.

@Override
public void update(CruiseConfig preprocessedConfig) throws Exception {
    ElasticProfile existingProfile = findExistingProfile(preprocessedConfig);
    ElasticProfiles profiles = getPluginProfiles(preprocessedConfig);
    profiles.set(profiles.indexOf(existingProfile), profile);
}
Also used : ElasticProfiles(com.thoughtworks.go.config.elastic.ElasticProfiles) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile)

Example 27 with ElasticProfile

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

the class GoConfigMigrationIntegrationTest method shouldCreateProfilesFromMultipleAgentConfigsAcrossStages_asPartOfMigration86And87.

@Test
public void shouldCreateProfilesFromMultipleAgentConfigsAcrossStages_asPartOfMigration86And87() throws Exception {
    String configXml = "<cruise schemaVersion='85'>" + " <server serverId='dev-id'>" + " </server>" + " <pipelines group='first'>" + "   <pipeline name='up42'>" + "     <materials>" + "       <hg url='../manual-testing/ant_hg/dummy' />" + "     </materials>" + "  <stage name='build'>" + "    <jobs>" + "      <job name='test1'>" + "       <agentConfig pluginId='docker'>" + "         <property>" + "           <key>instance-type</key>" + "           <value>m1.small</value>" + "         </property>" + "       </agentConfig>" + "      </job>" + "      <job name='test2'>" + "       <agentConfig pluginId='aws'>" + "         <property>" + "           <key>ami</key>" + "           <value>some.ami</value>" + "         </property>" + "         <property>" + "           <key>ram</key>" + "           <value>1024</value>" + "         </property>" + "         <property>" + "           <key>diskSpace</key>" + "           <value>10G</value>" + "         </property>" + "       </agentConfig>" + "      </job>" + "    </jobs>" + "  </stage>" + "  <stage name='dist'>" + "    <jobs>" + "      <job name='package'>" + "       <agentConfig pluginId='docker'>" + "         <property>" + "           <key>instance-type</key>" + "           <value>m1.small</value>" + "         </property>" + "       </agentConfig>" + "      </job>" + "    </jobs>" + "  </stage>" + "   </pipeline>" + "  </pipelines>" + "</cruise>";
    CruiseConfig migratedConfig = migrateConfigAndLoadTheNewConfig(configXml, 85);
    PipelineConfig pipelineConfig = migratedConfig.pipelineConfigByName(new CaseInsensitiveString("up42"));
    JobConfigs buildJobs = pipelineConfig.getStages().get(0).getJobs();
    JobConfigs distJobs = pipelineConfig.getStages().get(1).getJobs();
    ElasticProfiles profiles = migratedConfig.server().getElasticConfig().getProfiles();
    assertThat(profiles.size(), is(3));
    ElasticProfile expectedDockerProfile = new ElasticProfile(buildJobs.get(0).getElasticProfileId(), "docker", new ConfigurationProperty(new ConfigurationKey("instance-type"), new ConfigurationValue("m1.small")));
    assertThat(profiles.get(0), is(expectedDockerProfile));
    ElasticProfile expectedAWSProfile = new ElasticProfile(buildJobs.get(1).getElasticProfileId(), "aws", new ConfigurationProperty(new ConfigurationKey("ami"), new ConfigurationValue("some.ami")), new ConfigurationProperty(new ConfigurationKey("ram"), new ConfigurationValue("1024")), new ConfigurationProperty(new ConfigurationKey("diskSpace"), new ConfigurationValue("10G")));
    assertThat(profiles.get(1), is(expectedAWSProfile));
    ElasticProfile expectedSecondDockerProfile = new ElasticProfile(distJobs.get(0).getElasticProfileId(), "docker", new ConfigurationProperty(new ConfigurationKey("instance-type"), new ConfigurationValue("m1.small")));
    assertThat(profiles.get(2), is(expectedSecondDockerProfile));
}
Also used : ElasticProfiles(com.thoughtworks.go.config.elastic.ElasticProfiles) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 28 with ElasticProfile

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

the class GoConfigMigrationIntegrationTest method shouldCreateProfilesFromMultipleAgentConfigs_asPartOfMigration86And87.

@Test
public void shouldCreateProfilesFromMultipleAgentConfigs_asPartOfMigration86And87() throws Exception {
    String configXml = "<cruise schemaVersion='85'>" + "  <server serverId='dev-id'>" + "  </server>" + "  <pipelines group='first'>" + "    <pipeline name='up42'>" + "      <materials>" + "        <hg url='../manual-testing/ant_hg/dummy' />" + "      </materials>" + "  <stage name='dist'>" + "    <jobs>" + "      <job name='test1'>" + "       <agentConfig pluginId='docker'>" + "         <property>" + "           <key>instance-type</key>" + "           <value>m1.small</value>" + "         </property>" + "       </agentConfig>" + "      </job>" + "      <job name='test2'>" + "       <agentConfig pluginId='aws'>" + "         <property>" + "           <key>ami</key>" + "           <value>some.ami</value>" + "         </property>" + "         <property>" + "           <key>ram</key>" + "           <value>1024</value>" + "         </property>" + "         <property>" + "           <key>diskSpace</key>" + "           <value>10G</value>" + "         </property>" + "       </agentConfig>" + "      </job>" + "    </jobs>" + "  </stage>" + "   </pipeline>" + "  </pipelines>" + "</cruise>";
    CruiseConfig migratedConfig = migrateConfigAndLoadTheNewConfig(configXml, 85);
    PipelineConfig pipelineConfig = migratedConfig.pipelineConfigByName(new CaseInsensitiveString("up42"));
    JobConfigs jobs = pipelineConfig.getStages().get(0).getJobs();
    ElasticProfiles profiles = migratedConfig.server().getElasticConfig().getProfiles();
    assertThat(profiles.size(), is(2));
    ElasticProfile expectedDockerProfile = new ElasticProfile(jobs.get(0).getElasticProfileId(), "docker", new ConfigurationProperty(new ConfigurationKey("instance-type"), new ConfigurationValue("m1.small")));
    assertThat(profiles.get(0), is(expectedDockerProfile));
    ElasticProfile expectedAWSProfile = new ElasticProfile(jobs.get(1).getElasticProfileId(), "aws", new ConfigurationProperty(new ConfigurationKey("ami"), new ConfigurationValue("some.ami")), new ConfigurationProperty(new ConfigurationKey("ram"), new ConfigurationValue("1024")), new ConfigurationProperty(new ConfigurationKey("diskSpace"), new ConfigurationValue("10G")));
    assertThat(profiles.get(1), is(expectedAWSProfile));
}
Also used : ElasticProfiles(com.thoughtworks.go.config.elastic.ElasticProfiles) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 29 with ElasticProfile

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

the class GoConfigMigrationIntegrationTest method shouldCreateProfilesFromMultipleAgentConfigsAcrossPipelines_asPartOfMigration86And87.

@Test
public void shouldCreateProfilesFromMultipleAgentConfigsAcrossPipelines_asPartOfMigration86And87() throws Exception {
    String configXml = "<cruise schemaVersion='85'>" + " <server serverId='dev-id'>" + " </server>" + " <pipelines group='first'>" + "   <pipeline name='up42'>" + "     <materials>" + "       <hg url='../manual-testing/ant_hg/dummy' />" + "     </materials>" + "  <stage name='build'>" + "    <jobs>" + "      <job name='test1'>" + "       <agentConfig pluginId='docker'>" + "         <property>" + "           <key>instance-type</key>" + "           <value>m1.small</value>" + "         </property>" + "       </agentConfig>" + "      </job>" + "    </jobs>" + "  </stage>" + "   </pipeline>" + "   <pipeline name='up43'>" + "     <materials>" + "       <hg url='../manual-testing/ant_hg/dummy' />" + "     </materials>" + "  <stage name='build'>" + "    <jobs>" + "      <job name='test2'>" + "       <agentConfig pluginId='aws'>" + "         <property>" + "           <key>ami</key>" + "           <value>some.ami</value>" + "         </property>" + "         <property>" + "           <key>ram</key>" + "           <value>1024</value>" + "         </property>" + "         <property>" + "           <key>diskSpace</key>" + "           <value>10G</value>" + "         </property>" + "       </agentConfig>" + "      </job>" + "    </jobs>" + "  </stage>" + "   </pipeline>" + "  </pipelines>" + "</cruise>";
    CruiseConfig migratedConfig = migrateConfigAndLoadTheNewConfig(configXml, 85);
    PipelineConfig up42 = migratedConfig.pipelineConfigByName(new CaseInsensitiveString("up42"));
    PipelineConfig up43 = migratedConfig.pipelineConfigByName(new CaseInsensitiveString("up43"));
    JobConfigs up42Jobs = up42.getStages().get(0).getJobs();
    JobConfigs up43Jobs = up43.getStages().get(0).getJobs();
    ElasticProfiles profiles = migratedConfig.server().getElasticConfig().getProfiles();
    assertThat(profiles.size(), is(2));
    ElasticProfile expectedDockerProfile = new ElasticProfile(up42Jobs.get(0).getElasticProfileId(), "docker", new ConfigurationProperty(new ConfigurationKey("instance-type"), new ConfigurationValue("m1.small")));
    assertThat(profiles.get(0), is(expectedDockerProfile));
    ElasticProfile expectedAWSProfile = new ElasticProfile(up43Jobs.get(0).getElasticProfileId(), "aws", new ConfigurationProperty(new ConfigurationKey("ami"), new ConfigurationValue("some.ami")), new ConfigurationProperty(new ConfigurationKey("ram"), new ConfigurationValue("1024")), new ConfigurationProperty(new ConfigurationKey("diskSpace"), new ConfigurationValue("10G")));
    assertThat(profiles.get(1), is(expectedAWSProfile));
}
Also used : ElasticProfiles(com.thoughtworks.go.config.elastic.ElasticProfiles) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Aggregations

ElasticProfile (com.thoughtworks.go.config.elastic.ElasticProfile)29 Test (org.junit.Test)23 ElasticProfiles (com.thoughtworks.go.config.elastic.ElasticProfiles)9 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)6 ElasticConfig (com.thoughtworks.go.config.elastic.ElasticConfig)4 ConfigurationKey (com.thoughtworks.go.domain.config.ConfigurationKey)4 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)4 ConfigurationValue (com.thoughtworks.go.domain.config.ConfigurationValue)4 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)4 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)3 BasicCruiseConfig (com.thoughtworks.go.config.BasicCruiseConfig)2 Gson (com.google.gson.Gson)1 Agents (com.thoughtworks.go.config.Agents)1 ArtifactPlans (com.thoughtworks.go.config.ArtifactPlans)1 EnvironmentVariablesConfig (com.thoughtworks.go.config.EnvironmentVariablesConfig)1 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)1 DefaultJobPlan (com.thoughtworks.go.domain.DefaultJobPlan)1 DefaultSchedulingContext (com.thoughtworks.go.domain.DefaultSchedulingContext)1 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)1 ValidationError (com.thoughtworks.go.plugin.api.response.validation.ValidationError)1