Search in sources :

Example 56 with ClusterProfile

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

the class ElasticAgentPluginServiceTest method shouldNotAssignJobToAnAgentBroughtUpByADifferentElasticPlugin.

@Test
void shouldNotAssignJobToAnAgentBroughtUpByADifferentElasticPlugin() {
    String uuid = randomUUID().toString();
    ElasticAgentMetadata agentMetadata = new ElasticAgentMetadata(uuid, uuid, "plugin-1", AgentRuntimeStatus.Idle, AgentConfigStatus.Enabled);
    ElasticProfile elasticProfile = new ElasticProfile("1", "clusterProfileId");
    assertThat(service.shouldAssignWork(agentMetadata, null, elasticProfile, new ClusterProfile("clusterProfileId", "plugin-2"), null)).isFalse();
    verifyNoMoreInteractions(registry);
}
Also used : ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) ElasticAgentMetadata(com.thoughtworks.go.server.domain.ElasticAgentMetadata) ClusterProfile(com.thoughtworks.go.config.elastic.ClusterProfile) Test(org.junit.jupiter.api.Test)

Example 57 with ClusterProfile

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

the class ElasticAgentPluginServiceTest method shouldGetAPluginClusterReportWhenPluginSupportsStatusReport.

@Test
void shouldGetAPluginClusterReportWhenPluginSupportsStatusReport() {
    final Capabilities capabilities = new Capabilities(false, 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);
    when(registry.getClusterStatusReport("cd.go.example.plugin", clusterProfile.getConfigurationAsMap(true))).thenReturn("<div>This is a cluster status report snippet.</div>");
    final String clusterStatusReport = service.getClusterStatusReport("cd.go.example.plugin", "cluster-profile-id");
    assertThat(clusterStatusReport).isEqualTo("<div>This is a cluster 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) ClusterProfile(com.thoughtworks.go.config.elastic.ClusterProfile) Test(org.junit.jupiter.api.Test)

Example 58 with ClusterProfile

use of com.thoughtworks.go.config.elastic.ClusterProfile 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 59 with ClusterProfile

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

the class ElasticAgentPluginServiceTest method shouldNotAssignJobToAnAgentIfThePluginMatchesForTheAgentAndJob_ButThePluginRefusesToTheAssignment.

@Test
void shouldNotAssignJobToAnAgentIfThePluginMatchesForTheAgentAndJob_ButThePluginRefusesToTheAssignment() {
    String uuid = randomUUID().toString();
    String elasticPluginId = "plugin-1";
    ElasticAgentMetadata agentMetadata = new ElasticAgentMetadata(uuid, uuid, elasticPluginId, AgentRuntimeStatus.Idle, AgentConfigStatus.Enabled);
    ElasticProfile elasticProfile = new ElasticProfile("1", elasticPluginId);
    when(registry.shouldAssignWork(any(), any(), any(), any(), any(), any())).thenReturn(false);
    assertThat(service.shouldAssignWork(agentMetadata, null, elasticProfile, new ClusterProfile("clusterProfileId", elasticPluginId), null)).isFalse();
}
Also used : ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) ElasticAgentMetadata(com.thoughtworks.go.server.domain.ElasticAgentMetadata) ClusterProfile(com.thoughtworks.go.config.elastic.ClusterProfile) Test(org.junit.jupiter.api.Test)

Example 60 with ClusterProfile

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

the class ElasticAgentPluginServiceTest method plan.

private JobPlan plan(int jobId, String pluginId) {
    ClusterProfile clusterProfile = new ClusterProfile("clusterProfileId", pluginId);
    ElasticProfile elasticProfile = new ElasticProfile("id", "clusterProfileId");
    JobIdentifier identifier = new JobIdentifier("pipeline-" + jobId, 1, "1", "stage", "1", "job");
    return new DefaultJobPlan(null, new ArrayList<>(), jobId, identifier, null, new EnvironmentVariables(), new EnvironmentVariables(), elasticProfile, clusterProfile);
}
Also used : ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) ClusterProfile(com.thoughtworks.go.config.elastic.ClusterProfile)

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