Search in sources :

Example 11 with ClusterProfiles

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

the class ElasticAgentPluginServiceTest method shouldGetAPluginStatusReportWhenPluginSupportsStatusReport.

@Test
void shouldGetAPluginStatusReportWhenPluginSupportsStatusReport() {
    final Capabilities capabilities = new Capabilities(true);
    final GoPluginDescriptor descriptor = GoPluginDescriptor.builder().id("cd.go.example.plugin").build();
    elasticAgentMetadataStore.setPluginInfo(new ElasticAgentPluginInfo(descriptor, null, null, null, null, capabilities));
    when(clusterProfilesService.getPluginProfiles()).thenReturn(new ClusterProfiles());
    when(registry.getPluginStatusReport(eq("cd.go.example.plugin"), anyList())).thenReturn("<div>This is a plugin status report snippet.</div>");
    final String pluginStatusReport = service.getPluginStatusReport("cd.go.example.plugin");
    assertThat(pluginStatusReport).isEqualTo("<div>This is a plugin status report snippet.</div>");
}
Also used : ElasticAgentPluginInfo(com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo) Capabilities(com.thoughtworks.go.plugin.domain.elastic.Capabilities) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) ClusterProfiles(com.thoughtworks.go.config.elastic.ClusterProfiles) Test(org.junit.jupiter.api.Test)

Example 12 with ClusterProfiles

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

the class ElasticAgentPluginServiceTest method shouldSendServerHeartbeatToAllElasticPlugins.

@Test
void shouldSendServerHeartbeatToAllElasticPlugins() {
    ClusterProfiles allClusterProfiles = new ClusterProfiles();
    allClusterProfiles.add(new ClusterProfile("id1", "p1"));
    allClusterProfiles.add(new ClusterProfile("id2", "p2"));
    allClusterProfiles.add(new ClusterProfile("id3", "docker"));
    when(clusterProfilesService.getPluginProfiles()).thenReturn(allClusterProfiles);
    ClusterProfiles p1ClusterProfiles = new ClusterProfiles();
    p1ClusterProfiles.add(new ClusterProfile("id1", "p1"));
    ClusterProfiles p2ClusterProfiles = new ClusterProfiles();
    p2ClusterProfiles.add(new ClusterProfile("id2", "p2"));
    ClusterProfiles dockerClusterProfiles = new ClusterProfiles();
    dockerClusterProfiles.add(new ClusterProfile("id3", "docker"));
    service.heartbeat();
    ArgumentCaptor<ServerPingMessage> captor = ArgumentCaptor.forClass(ServerPingMessage.class);
    ArgumentCaptor<Long> ttl = ArgumentCaptor.forClass(Long.class);
    verify(serverPingQueue, times(3)).post(captor.capture(), ttl.capture());
    List<ServerPingMessage> messages = captor.getAllValues();
    assertThat(messages).hasSize(3).contains(new ServerPingMessage("p1", p1ClusterProfiles), new ServerPingMessage("p2", p2ClusterProfiles), new ServerPingMessage("docker", dockerClusterProfiles));
}
Also used : ClusterProfiles(com.thoughtworks.go.config.elastic.ClusterProfiles) ServerPingMessage(com.thoughtworks.go.server.messaging.elasticagents.ServerPingMessage) ClusterProfile(com.thoughtworks.go.config.elastic.ClusterProfile) Test(org.junit.jupiter.api.Test)

Example 13 with ClusterProfiles

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

the class ClusterProfilesChangedPluginNotifierTest method onConfigChangeItShouldUpdateLocalClusterProfilesCopy.

@Test
void onConfigChangeItShouldUpdateLocalClusterProfilesCopy() {
    BasicCruiseConfig newCruiseConfig = new BasicCruiseConfig();
    newCruiseConfig.getElasticConfig().getClusterProfiles().add(newClusterProfile);
    newCruiseConfig.getElasticConfig().getClusterProfiles().add(oldClusterProfile);
    assertThat(notifier.getExistingClusterProfiles()).isEqualTo(new ClusterProfiles());
    notifier.onConfigChange(newCruiseConfig);
    assertThat(notifier.getExistingClusterProfiles()).isEqualTo(new ClusterProfiles(newClusterProfile, oldClusterProfile));
    verifyNoMoreInteractions(registry);
}
Also used : BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) ClusterProfiles(com.thoughtworks.go.config.elastic.ClusterProfiles) Test(org.junit.jupiter.api.Test)

Example 14 with ClusterProfiles

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

the class ClusterProfilesServiceIntegrationTest method setUp.

@BeforeEach
public void setUp() throws Exception {
    configHelper.onSetUp();
    goConfigService.updateConfig(new UpdateConfigCommand() {

        @Override
        public CruiseConfig update(CruiseConfig cruiseConfig) throws Exception {
            cruiseConfig.getElasticConfig().setClusterProfiles(new ClusterProfiles());
            return cruiseConfig;
        }
    });
}
Also used : UpdateConfigCommand(com.thoughtworks.go.config.UpdateConfigCommand) ClusterProfiles(com.thoughtworks.go.config.elastic.ClusterProfiles) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) BeforeEach(org.junit.jupiter.api.BeforeEach)

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