use of com.thoughtworks.go.config.elastic.ElasticProfile in project gocd by gocd.
the class AgentInstanceTest method shouldNotMatchJobPlanIfJobRequiresElasticAgent_MatchingIsManagedByBuildAssignmentService.
@Test
public void shouldNotMatchJobPlanIfJobRequiresElasticAgent_MatchingIsManagedByBuildAssignmentService() {
AgentConfig agentConfig = new AgentConfig("uuid");
agentConfig.setElasticAgentId("elastic-agent-id-1");
String elasticPluginId = "elastic-plugin-id-1";
agentConfig.setElasticPluginId(elasticPluginId);
AgentInstance agentInstance = new AgentInstance(agentConfig, REMOTE, mock(SystemEnvironment.class));
DefaultJobPlan jobPlan1 = new DefaultJobPlan();
jobPlan1.setElasticProfile(new ElasticProfile("foo", elasticPluginId));
List<JobPlan> jobPlans = asList(jobPlan1, new DefaultJobPlan());
assertThat(agentInstance.firstMatching(jobPlans), is(nullValue()));
}
use of com.thoughtworks.go.config.elastic.ElasticProfile in project gocd by gocd.
the class AgentInstanceTest method shouldNotMatchJobPlanIfTheAgentWasLaunchedByADifferentPluginFromThatConfiguredForTheJob.
@Test
public void shouldNotMatchJobPlanIfTheAgentWasLaunchedByADifferentPluginFromThatConfiguredForTheJob() {
AgentConfig agentConfig = new AgentConfig("uuid");
agentConfig.setElasticAgentId("elastic-agent-id-1");
String elasticPluginId = "elastic-plugin-id-1";
agentConfig.setElasticPluginId(elasticPluginId);
AgentInstance agentInstance = new AgentInstance(agentConfig, REMOTE, mock(SystemEnvironment.class));
DefaultJobPlan jobPlan1 = new DefaultJobPlan();
jobPlan1.setElasticProfile(new ElasticProfile("foo", "elastic-plugin-id-2"));
List<JobPlan> jobPlans = asList(jobPlan1, new DefaultJobPlan());
assertThat(agentInstance.firstMatching(jobPlans), is(nullValue()));
}
use of com.thoughtworks.go.config.elastic.ElasticProfile in project gocd by gocd.
the class GoConfigMigrationIntegrationTest method shouldCreateProfilesFromAgentConfig_asPartOfMigration86And87.
@Test
public void shouldCreateProfilesFromAgentConfig_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='test'>" + " <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"));
JobConfig jobConfig = pipelineConfig.getStages().get(0).getJobs().get(0);
assertThat(migratedConfig.schemaVersion(), greaterThan(86));
ElasticProfiles profiles = migratedConfig.server().getElasticConfig().getProfiles();
assertThat(profiles.size(), is(1));
ElasticProfile expectedProfile = new ElasticProfile(jobConfig.getElasticProfileId(), "docker", new ConfigurationProperty(new ConfigurationKey("instance-type"), new ConfigurationValue("m1.small")));
ElasticProfile elasticProfile = profiles.get(0);
assertThat(elasticProfile, is(expectedProfile));
}
use of com.thoughtworks.go.config.elastic.ElasticProfile in project gocd by gocd.
the class ElasticAgentProfileCreateCommandTest method shouldInvokePluginValidationsBeforeSave.
@Test
public void shouldInvokePluginValidationsBeforeSave() throws Exception {
ValidationResult validationResult = new ValidationResult();
validationResult.addError(new ValidationError("key", "error"));
when(extension.validate(eq("aws"), Matchers.<Map<String, String>>any())).thenReturn(validationResult);
ElasticProfile newProfile = new ElasticProfile("foo", "aws", new ConfigurationProperty(new ConfigurationKey("key"), new ConfigurationValue("val")));
PluginProfileCommand command = new ElasticAgentProfileCreateCommand(mock(GoConfigService.class), newProfile, extension, null, new HttpLocalizedOperationResult());
BasicCruiseConfig cruiseConfig = new BasicCruiseConfig();
thrown.expect(PluginProfileNotFoundException.class);
thrown.expectMessage("Elastic agent profile `foo` does not exist.");
command.isValid(cruiseConfig);
command.update(cruiseConfig);
assertThat(newProfile.first().errors().size(), is(1));
assertThat(newProfile.first().errors().asString(), is("error"));
}
use of com.thoughtworks.go.config.elastic.ElasticProfile in project gocd by gocd.
the class ElasticAgentProfileDeleteCommandTest method shouldValidateIfProfileIsNotInUseByPipeline.
@Test
public void shouldValidateIfProfileIsNotInUseByPipeline() throws Exception {
ElasticProfile elasticProfile = new ElasticProfile("foo", "docker");
assertThat(cruiseConfig.server().getElasticConfig().getProfiles(), is(empty()));
ElasticAgentProfileDeleteCommand command = new ElasticAgentProfileDeleteCommand(null, elasticProfile, null, null, new HttpLocalizedOperationResult());
assertTrue(command.isValid(cruiseConfig));
}
Aggregations