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