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