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