Search in sources :

Example 61 with ClusterProfile

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

the class ClusterProfilesChangedPluginNotifierTest method setUp.

@BeforeEach
void setUp() {
    pluginId = "plugin-id";
    when(goConfigService.getElasticConfig()).thenReturn(new ElasticConfig());
    properties = new ArrayList<>();
    properties.add(new ConfigurationProperty(new ConfigurationKey("key1"), new ConfigurationValue("value1")));
    oldClusterProfile = new ClusterProfile("profile1", pluginId, properties);
    newClusterProfile = new ClusterProfile("profile1", pluginId, properties);
    notifier = new ClusterProfilesChangedPluginNotifier(goConfigService, registry, secretParamResolver, serverHealthService);
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) ElasticConfig(com.thoughtworks.go.config.elastic.ElasticConfig) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) ClusterProfile(com.thoughtworks.go.config.elastic.ClusterProfile) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 62 with ClusterProfile

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

the class ClusterProfilesChangedPluginNotifierTest method shouldNotifyPluginRegistryWhenAClusterProfileIsUpdated_WithAChangeInPluginId.

@Test
void shouldNotifyPluginRegistryWhenAClusterProfileIsUpdated_WithAChangeInPluginId() {
    String newPluginId = "updated-plugin-id";
    newClusterProfile = new ClusterProfile("profile1", newPluginId, properties);
    reset(goConfigService);
    ElasticConfig elasticConfig = new ElasticConfig();
    elasticConfig.getClusterProfiles().add(oldClusterProfile);
    when(goConfigService.getElasticConfig()).thenReturn(elasticConfig);
    notifier = new ClusterProfilesChangedPluginNotifier(goConfigService, registry, secretParamResolver, serverHealthService);
    notifier.onEntityConfigChange(newClusterProfile);
    verify(secretParamResolver, times(2)).resolve(any(ClusterProfile.class));
    verify(registry, times(1)).notifyPluginAboutClusterProfileChanged(this.pluginId, ClusterProfilesChangedStatus.DELETED, oldClusterProfile.getConfigurationAsMap(true), null);
    verify(registry, times(1)).notifyPluginAboutClusterProfileChanged(newPluginId, ClusterProfilesChangedStatus.CREATED, null, newClusterProfile.getConfigurationAsMap(true));
    verifyNoMoreInteractions(registry);
    verify(goConfigService, times(3)).getElasticConfig();
}
Also used : ElasticConfig(com.thoughtworks.go.config.elastic.ElasticConfig) ClusterProfile(com.thoughtworks.go.config.elastic.ClusterProfile) Test(org.junit.jupiter.api.Test)

Example 63 with ClusterProfile

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

the class JobControllerIntegrationTest method jobDetailModel_shouldHaveTheElasticPluginIdAndElasticAgentIdWhenAgentIsAssigned.

@Test
public void jobDetailModel_shouldHaveTheElasticPluginIdAndElasticAgentIdWhenAgentIsAssigned() throws Exception {
    Pipeline pipeline = fixture.createPipelineWithFirstStageAssigned();
    Stage stage = pipeline.getFirstStage();
    JobInstance job = stage.getFirstJob();
    GoPluginDescriptor.About about = GoPluginDescriptor.About.builder().name("name").version("0.1").targetGoVersion("17.3.0").description("desc").build();
    GoPluginDescriptor descriptor = GoPluginDescriptor.builder().id("plugin_id").about(about).build();
    ElasticAgentMetadataStore.instance().setPluginInfo(new ElasticAgentPluginInfo(descriptor, null, null, null, null, new Capabilities(false, true)));
    ElasticProfile profile = new ElasticProfile("profile_id", "cluster_profile_id", Collections.EMPTY_LIST);
    ClusterProfile clusterProfile = new ClusterProfile("cluster_profile_id", "plugin_id", Collections.EMPTY_LIST);
    fixture.addJobAgentMetadata(new JobAgentMetadata(job.getId(), profile, clusterProfile));
    final Agent agent = new Agent(job.getAgentUuid(), "localhost", "127.0.0.1", uuidGenerator.randomUuid());
    agent.setElasticAgentId("elastic_agent_id");
    agent.setElasticPluginId("plugin_id");
    agentService.saveOrUpdate(agent);
    ModelAndView modelAndView = controller.jobDetail(pipeline.getName(), String.valueOf(pipeline.getCounter()), stage.getName(), String.valueOf(stage.getCounter()), job.getName());
    assertThat(modelAndView.getModel().get("elasticAgentPluginId"), is("plugin_id"));
    assertThat(modelAndView.getModel().get("elasticAgentId"), is("elastic_agent_id"));
}
Also used : Agent(com.thoughtworks.go.config.Agent) ElasticAgentPluginInfo(com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo) JobAgentMetadata(com.thoughtworks.go.domain.JobAgentMetadata) JobInstance(com.thoughtworks.go.domain.JobInstance) Capabilities(com.thoughtworks.go.plugin.domain.elastic.Capabilities) ModelAndView(org.springframework.web.servlet.ModelAndView) Stage(com.thoughtworks.go.domain.Stage) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) ClusterProfile(com.thoughtworks.go.config.elastic.ClusterProfile) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.jupiter.api.Test)

Example 64 with ClusterProfile

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

the class JobAgentMetadataSqlMapDaoIntegrationTest method shouldDeleteElasticAgentPropertySetToJob.

@Test
public void shouldDeleteElasticAgentPropertySetToJob() throws Exception {
    ElasticProfile profile = new ElasticProfile("elastic", "clusterProfileId", new ConfigurationProperty());
    ClusterProfile clusterProfile = new ClusterProfile("clusterProfileId", "plugin", new ConfigurationProperty());
    JobAgentMetadata jobAgentMetadata = new JobAgentMetadata(jobId, profile, clusterProfile);
    dao.save(jobAgentMetadata);
    JobAgentMetadata metadataFromDb = dao.load(jobId);
    assertThat(metadataFromDb, is(jobAgentMetadata));
    dao.delete(metadataFromDb);
    assertThat(dao.load(jobId), is(nullValue()));
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) JobAgentMetadata(com.thoughtworks.go.domain.JobAgentMetadata) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) ClusterProfile(com.thoughtworks.go.config.elastic.ClusterProfile) Test(org.junit.jupiter.api.Test)

Example 65 with ClusterProfile

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

the class ClusterProfilesServiceIntegrationTest method shouldNotAllowCreationANewClusterProfileWithSameName.

@Test
public void shouldNotAllowCreationANewClusterProfileWithSameName() throws Exception {
    String clusterId = "cluster1";
    HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
    ClusterProfile clusterProfile = new ClusterProfile(clusterId, "pluginid");
    assertThat(clusterProfilesService.getPluginProfiles().size(), is(0));
    clusterProfilesService.create(clusterProfile, new Username("Bob"), result);
    assertThat(result.isSuccessful(), is(true));
    assertThat(clusterProfile.getAllErrors(), hasSize(0));
    assertThat(clusterProfilesService.getPluginProfiles().size(), is(1));
    assertThat(clusterProfilesService.getPluginProfiles().find(clusterId), is(clusterProfile));
    clusterProfilesService.create(clusterProfile, new Username("Bob"), result);
    assertThat(clusterProfilesService.getPluginProfiles().size(), is(1));
    assertThat(result.isSuccessful(), is(false));
    assertThat(clusterProfile.getAllErrors(), hasSize(1));
    assertThat(clusterProfile.errors().get("id").get(0), is("Cluster Profile id 'cluster1' is not unique"));
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) Username(com.thoughtworks.go.server.domain.Username) ClusterProfile(com.thoughtworks.go.config.elastic.ClusterProfile) Test(org.junit.jupiter.api.Test)

Aggregations

ClusterProfile (com.thoughtworks.go.config.elastic.ClusterProfile)69 Test (org.junit.jupiter.api.Test)39 ElasticProfile (com.thoughtworks.go.config.elastic.ElasticProfile)32 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)14 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)12 ConfigurationKey (com.thoughtworks.go.domain.config.ConfigurationKey)10 ConfigurationValue (com.thoughtworks.go.domain.config.ConfigurationValue)10 ElasticAgentPluginInfo (com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo)10 ClusterProfiles (com.thoughtworks.go.config.elastic.ClusterProfiles)8 Username (com.thoughtworks.go.server.domain.Username)8 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)7 BeforeEach (org.junit.jupiter.api.BeforeEach)7 ElasticConfig (com.thoughtworks.go.config.elastic.ElasticConfig)6 Capabilities (com.thoughtworks.go.plugin.domain.elastic.Capabilities)6 BasicCruiseConfig (com.thoughtworks.go.config.BasicCruiseConfig)5 RecordNotFoundException (com.thoughtworks.go.config.exceptions.RecordNotFoundException)5 JobAgentMetadata (com.thoughtworks.go.domain.JobAgentMetadata)4 ElasticAgentInformation (com.thoughtworks.go.plugin.access.elastic.models.ElasticAgentInformation)4 PluginConfiguration (com.thoughtworks.go.plugin.domain.common.PluginConfiguration)4 GoCipher (com.thoughtworks.go.security.GoCipher)4