Search in sources :

Example 1 with ClusterProfiles

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

Example 2 with ClusterProfiles

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

Example 3 with ClusterProfiles

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

Example 4 with ClusterProfiles

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.");
}
Also used : ElasticAgentPluginInfo(com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo) RecordNotFoundException(com.thoughtworks.go.config.exceptions.RecordNotFoundException) Capabilities(com.thoughtworks.go.plugin.domain.elastic.Capabilities) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) ClusterProfiles(com.thoughtworks.go.config.elastic.ClusterProfiles) ClusterProfile(com.thoughtworks.go.config.elastic.ClusterProfile) Test(org.junit.jupiter.api.Test)

Example 5 with ClusterProfiles

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);
}
Also used : ClusterProfiles(com.thoughtworks.go.config.elastic.ClusterProfiles) ServerPingMessage(com.thoughtworks.go.server.messaging.elasticagents.ServerPingMessage) Test(org.junit.jupiter.api.Test)

Aggregations

ClusterProfiles (com.thoughtworks.go.config.elastic.ClusterProfiles)14 Test (org.junit.jupiter.api.Test)9 ClusterProfile (com.thoughtworks.go.config.elastic.ClusterProfile)8 Capabilities (com.thoughtworks.go.plugin.domain.elastic.Capabilities)4 ElasticAgentPluginInfo (com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo)4 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)4 BasicCruiseConfig (com.thoughtworks.go.config.BasicCruiseConfig)2 ElasticProfile (com.thoughtworks.go.config.elastic.ElasticProfile)2 ConfigurationKey (com.thoughtworks.go.domain.config.ConfigurationKey)2 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)2 ConfigurationValue (com.thoughtworks.go.domain.config.ConfigurationValue)2 ServerPingMessage (com.thoughtworks.go.server.messaging.elasticagents.ServerPingMessage)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)1 UpdateConfigCommand (com.thoughtworks.go.config.UpdateConfigCommand)1 ElasticConfig (com.thoughtworks.go.config.elastic.ElasticConfig)1 ElasticProfiles (com.thoughtworks.go.config.elastic.ElasticProfiles)1 RecordNotFoundException (com.thoughtworks.go.config.exceptions.RecordNotFoundException)1 Username (com.thoughtworks.go.server.domain.Username)1 GoConfigFileHelper (com.thoughtworks.go.util.GoConfigFileHelper)1