Search in sources :

Example 6 with ElasticProfiles

use of com.thoughtworks.go.config.elastic.ElasticProfiles 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.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 7 with ElasticProfiles

use of com.thoughtworks.go.config.elastic.ElasticProfiles 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.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 8 with ElasticProfiles

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

the class GoConfigMigratorIntegrationTest 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'><tasks><exec command='echo'><runif status='passed' /></exec></tasks>" + "       <agentConfig pluginId='docker'>" + "         <property>" + "           <key>instance-type</key>" + "           <value>m1.small</value>" + "         </property>" + "       </agentConfig>" + "      </job>" + "      <job name='test2'><tasks><exec command='echo'><runif status='passed' /></exec></tasks>" + "       <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'><tasks><exec command='echo'><runif status='passed' /></exec></tasks>" + "       <agentConfig pluginId='docker'>" + "         <property>" + "           <key>instance-type</key>" + "           <value>m1.small</value>" + "         </property>" + "       </agentConfig>" + "      </job>" + "    </jobs>" + "  </stage>" + "   </pipeline>" + "  </pipelines>" + "</cruise>";
    CruiseConfig migratedConfig = migrateConfigAndLoadTheNewConfig(configXml);
    PipelineConfig pipelineConfig = migratedConfig.pipelineConfigByName(new CaseInsensitiveString("up42"));
    JobConfigs buildJobs = pipelineConfig.getStages().get(0).getJobs();
    JobConfigs distJobs = pipelineConfig.getStages().get(1).getJobs();
    ElasticProfiles profiles = migratedConfig.getElasticConfig().getProfiles();
    assertThat(profiles.size()).isEqualTo(3);
    ElasticProfile expectedDockerProfile = new ElasticProfile(buildJobs.get(0).getElasticProfileId(), "no-op-cluster-for-docker", new ConfigurationProperty(new ConfigurationKey("instance-type"), new ConfigurationValue("m1.small")));
    assertThat(profiles.get(0)).isEqualTo(expectedDockerProfile);
    ElasticProfile expectedAWSProfile = new ElasticProfile(buildJobs.get(1).getElasticProfileId(), "no-op-cluster-for-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)).isEqualTo(expectedAWSProfile);
    ElasticProfile expectedSecondDockerProfile = new ElasticProfile(distJobs.get(0).getElasticProfileId(), "no-op-cluster-for-docker", new ConfigurationProperty(new ConfigurationKey("instance-type"), new ConfigurationValue("m1.small")));
    assertThat(profiles.get(2)).isEqualTo(expectedSecondDockerProfile);
}
Also used : ElasticProfiles(com.thoughtworks.go.config.elastic.ElasticProfiles) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) Test(org.junit.jupiter.api.Test)

Example 9 with ElasticProfiles

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

the class GoConfigMigratorIntegrationTest 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'><tasks><exec command='echo'><runif status='passed' /></exec></tasks>" + "       <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'><tasks><exec command='echo'><runif status='passed' /></exec></tasks>" + "       <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);
    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.getElasticConfig().getProfiles();
    assertThat(profiles.size()).isEqualTo(2);
    ElasticProfile expectedDockerProfile = new ElasticProfile(up42Jobs.get(0).getElasticProfileId(), "no-op-cluster-for-docker", new ConfigurationProperty(new ConfigurationKey("instance-type"), new ConfigurationValue("m1.small")));
    assertThat(profiles.get(0)).isEqualTo(expectedDockerProfile);
    ElasticProfile expectedAWSProfile = new ElasticProfile(up43Jobs.get(0).getElasticProfileId(), "no-op-cluster-for-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)).isEqualTo(expectedAWSProfile);
}
Also used : ElasticProfiles(com.thoughtworks.go.config.elastic.ElasticProfiles) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) Test(org.junit.jupiter.api.Test)

Example 10 with ElasticProfiles

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

the class UpdateClusterProfileCommand method isValid.

@Override
public boolean isValid(CruiseConfig preprocessedConfig) {
    ElasticProfiles allElasticAgentProfiles = preprocessedConfig.getElasticConfig().getProfiles();
    allElasticAgentProfiles.validateTree(new ConfigSaveValidationContext(preprocessedConfig));
    List<ConfigErrors> allErrors = ErrorCollector.getAllErrors(allElasticAgentProfiles);
    if (!allErrors.isEmpty()) {
        throw new GoConfigInvalidException(preprocessedConfig, allErrors.get(0).firstError());
    }
    return isValidForCreateOrUpdate(preprocessedConfig);
}
Also used : ElasticProfiles(com.thoughtworks.go.config.elastic.ElasticProfiles) ConfigSaveValidationContext(com.thoughtworks.go.config.ConfigSaveValidationContext) GoConfigInvalidException(com.thoughtworks.go.config.exceptions.GoConfigInvalidException) ConfigErrors(com.thoughtworks.go.domain.ConfigErrors)

Aggregations

ElasticProfiles (com.thoughtworks.go.config.elastic.ElasticProfiles)13 ElasticProfile (com.thoughtworks.go.config.elastic.ElasticProfile)12 Test (org.junit.jupiter.api.Test)7 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)4 Test (org.junit.Test)4 ElasticConfig (com.thoughtworks.go.config.elastic.ElasticConfig)2 ConfigSaveValidationContext (com.thoughtworks.go.config.ConfigSaveValidationContext)1 ClusterProfile (com.thoughtworks.go.config.elastic.ClusterProfile)1 ClusterProfiles (com.thoughtworks.go.config.elastic.ClusterProfiles)1 GoConfigInvalidException (com.thoughtworks.go.config.exceptions.GoConfigInvalidException)1 ConfigErrors (com.thoughtworks.go.domain.ConfigErrors)1