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