Search in sources :

Example 6 with ElasticProfile

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()));
}
Also used : ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) Test(org.junit.Test)

Example 7 with ElasticProfile

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)));
}
Also used : ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) Test(org.junit.Test)

Example 8 with ElasticProfile

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("");
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) HashMap(java.util.HashMap) Agents(com.thoughtworks.go.config.Agents) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) DefaultSchedulingContext(com.thoughtworks.go.domain.DefaultSchedulingContext) Before(org.junit.Before)

Example 9 with ElasticProfile

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"));
}
Also used : ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 10 with ElasticProfile

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));
}
Also used : ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) 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