use of com.thoughtworks.go.config.elastic.ElasticProfile in project gocd by gocd.
the class ElasticAgentProfileDeleteCommandTest method shouldDeleteAProfile.
@Test
public void shouldDeleteAProfile() throws Exception {
ElasticProfile elasticProfile = new ElasticProfile("foo", "docker");
cruiseConfig.server().getElasticConfig().getProfiles().add(elasticProfile);
ElasticAgentProfileDeleteCommand command = new ElasticAgentProfileDeleteCommand(null, elasticProfile, null, null, null);
command.update(cruiseConfig);
assertThat(cruiseConfig.server().getElasticConfig().getProfiles(), is(empty()));
}
use of com.thoughtworks.go.config.elastic.ElasticProfile in project gocd by gocd.
the class ElasticAgentProfileUpdateCommandTest method shouldUpdateExistingProfile.
@Test
public void shouldUpdateExistingProfile() throws Exception {
ElasticProfile oldProfile = new ElasticProfile("foo", "docker");
ElasticProfile newProfile = new ElasticProfile("foo", "aws");
cruiseConfig.server().getElasticConfig().getProfiles().add(oldProfile);
ElasticAgentProfileUpdateCommand command = new ElasticAgentProfileUpdateCommand(null, newProfile, null, null, null, null, null);
command.update(cruiseConfig);
assertThat(cruiseConfig.server().getElasticConfig().getProfiles().find("foo"), is(equalTo(newProfile)));
}
use of com.thoughtworks.go.config.elastic.ElasticProfile in project gocd by gocd.
the class BuildAssignmentServiceTest method setUp.
@Before
public void setUp() throws Exception {
initMocks(this);
buildAssignmentService = new BuildAssignmentService(goConfigService, jobInstanceService, scheduleService, agentService, environmentConfigService, transactionTemplate, scheduledPipelineLoader, pipelineService, builderFactory, agentRemoteHandler, elasticAgentPluginService, timeProvider);
elasticProfileId1 = "elastic.profile.id.1";
elasticProfileId2 = "elastic.profile.id.2";
elasticAgent = AgentMother.elasticAgent();
elasticAgentInstance = AgentInstance.createFromConfig(elasticAgent, new SystemEnvironment());
regularAgentInstance = AgentInstance.createFromConfig(AgentMother.approvedAgent(), new SystemEnvironment());
elasticProfile1 = new ElasticProfile(elasticProfileId1, elasticAgent.getElasticPluginId());
elasticProfile2 = new ElasticProfile(elasticProfileId2, elasticAgent.getElasticPluginId());
jobPlans = new ArrayList<>();
HashMap<String, ElasticProfile> profiles = new HashMap<>();
profiles.put(elasticProfile1.getId(), elasticProfile1);
profiles.put(elasticProfile2.getId(), elasticProfile2);
schedulingContext = new DefaultSchedulingContext("me", new Agents(elasticAgent), profiles);
when(jobInstanceService.orderedScheduledBuilds()).thenReturn(jobPlans);
when(environmentConfigService.filterJobsByAgent(Matchers.eq(jobPlans), Matchers.any(String.class))).thenReturn(jobPlans);
when(environmentConfigService.envForPipeline(Matchers.any(String.class))).thenReturn("");
}
use of com.thoughtworks.go.config.elastic.ElasticProfile in project gocd by gocd.
the class MagicalGoConfigXmlLoaderTest method shouldSerializeElasticAgentProfiles.
@Test
public void shouldSerializeElasticAgentProfiles() throws Exception {
String configWithElasticProfile = "<cruise schemaVersion='" + CONFIG_SCHEMA_VERSION + "'>\n" + "<server artifactsdir='artifacts'>\n" + " <elastic jobStarvationTimeout=\"2\">\n" + " <profiles>\n" + " <profile id=\"foo\" pluginId=\"docker\">\n" + " <property>\n" + " <key>USERNAME</key>\n" + " <value>bob</value>\n" + " </property>\n" + " </profile>\n" + " </profiles>\n" + " </elastic>\n" + "</server>\n" + "</cruise>\n";
CruiseConfig cruiseConfig = ConfigMigrator.loadWithMigration(configWithElasticProfile).configForEdit;
assertThat(cruiseConfig.server().getElasticConfig().getJobStarvationTimeout(), is(120000L));
assertThat(cruiseConfig.server().getElasticConfig().getProfiles().size(), is(1));
ElasticProfile elasticProfile = cruiseConfig.server().getElasticConfig().getProfiles().find("foo");
assertThat(elasticProfile, is(notNullValue()));
assertThat(elasticProfile.getPluginId(), is("docker"));
assertThat(elasticProfile.size(), is(1));
assertThat(elasticProfile.getProperty("USERNAME").getValue(), is("bob"));
}
use of com.thoughtworks.go.config.elastic.ElasticProfile in project gocd by gocd.
the class JobInstanceSqlMapDaoTest method shouldNotThrowUpWhenJobAgentMetadataIsNull.
@Test
public void shouldNotThrowUpWhenJobAgentMetadataIsNull() throws Exception {
JobInstance instance = jobInstanceDao.save(stageId, new JobInstance(JOB_NAME));
instance.setIdentifier(new JobIdentifier(savedPipeline, savedStage, instance));
ElasticProfile elasticProfile = null;
JobPlan plan = new DefaultJobPlan(new Resources("something"), new ArtifactPlans(), new ArtifactPropertiesGenerators(), instance.getId(), instance.getIdentifier(), null, new EnvironmentVariablesConfig(), new EnvironmentVariablesConfig(), elasticProfile);
jobInstanceDao.save(instance.getId(), plan);
JobPlan retrieved = jobInstanceDao.loadPlan(plan.getJobId());
assertThat(retrieved.getElasticProfile(), is(elasticProfile));
}
Aggregations