use of com.thoughtworks.go.config.elastic.ClusterProfiles in project gocd by gocd.
the class UpdateClusterProfileCommand method update.
@Override
public void update(CruiseConfig preprocessedConfig) throws Exception {
ClusterProfile existingClusterProfile = findExistingProfile(preprocessedConfig);
ClusterProfiles clusterProfiles = getPluginProfiles(preprocessedConfig);
clusterProfiles.set(clusterProfiles.indexOf(existingClusterProfile), profile);
}
use of com.thoughtworks.go.config.elastic.ClusterProfiles in project gocd by gocd.
the class DeleteClusterProfileCommand method update.
@Override
public void update(CruiseConfig preprocessedConfig) throws Exception {
ClusterProfiles clusterProfiles = getPluginProfiles(preprocessedConfig);
clusterProfiles.remove(profile);
preprocessedConfig.getElasticConfig().setClusterProfiles(clusterProfiles);
this.preprocessedProfile = profile;
}
use of com.thoughtworks.go.config.elastic.ClusterProfiles in project gocd by gocd.
the class ClusterProfilesServiceTest method shouldFetchClustersDefinedAsPartOfElasticTag.
@Test
void shouldFetchClustersDefinedAsPartOfElasticTag() {
ElasticConfig elasticConfig = new ElasticConfig();
elasticConfig.setClusterProfiles(new ClusterProfiles(clusterProfile));
when(goConfigService.getElasticConfig()).thenReturn(elasticConfig);
PluginProfiles<ClusterProfile> actualClusterProfiles = clusterProfilesService.getPluginProfiles();
assertThat(actualClusterProfiles).isEqualTo(elasticConfig.getClusterProfiles());
}
use of com.thoughtworks.go.config.elastic.ClusterProfiles in project gocd by gocd.
the class ElasticAgentPluginServiceTest method shouldErrorOutWhenClusterProfileNotFound.
@Test
void shouldErrorOutWhenClusterProfileNotFound() {
final Capabilities capabilities = new Capabilities(true, true, false);
final GoPluginDescriptor descriptor = GoPluginDescriptor.builder().id("cd.go.example.plugin").build();
elasticAgentMetadataStore.setPluginInfo(new ElasticAgentPluginInfo(descriptor, null, null, null, null, capabilities));
ClusterProfile clusterProfile = new ClusterProfile("cluster-profile-id", "cd.go.example.plugin");
clusterProfile.addNewConfigurationWithValue("go-server-url", "server-url", false);
PluginProfiles<ClusterProfile> clusterProfiles = new ClusterProfiles(clusterProfile);
when(clusterProfilesService.getPluginProfiles()).thenReturn(clusterProfiles);
final RecordNotFoundException exception = assertThrows(RecordNotFoundException.class, () -> service.getClusterStatusReport("cd.go.example.plugin", "test"));
assertThat(exception.getMessage()).isEqualTo("Cluster profile with id: 'test' is not found.");
}
use of com.thoughtworks.go.config.elastic.ClusterProfiles in project gocd by gocd.
the class ElasticAgentPluginServiceTest method shouldSendServerHeartBeatMessageWithTimeToLive.
@Test
void shouldSendServerHeartBeatMessageWithTimeToLive() {
when(clusterProfilesService.getPluginProfiles()).thenReturn(new ClusterProfiles());
service.setElasticPluginHeartBeatInterval(60000L);
ArgumentCaptor<ServerPingMessage> captor = ArgumentCaptor.forClass(ServerPingMessage.class);
ArgumentCaptor<Long> ttl = ArgumentCaptor.forClass(Long.class);
service.heartbeat();
verify(serverPingQueue, times(3)).post(captor.capture(), ttl.capture());
assertThat(ttl.getValue()).isEqualTo(50000L);
}
Aggregations