use of com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo in project gocd by gocd.
the class ElasticAgentPluginServiceTest method shouldGetAPluginStatusReportWhenPluginSupportsStatusReport.
@Test
public void shouldGetAPluginStatusReportWhenPluginSupportsStatusReport() {
final Capabilities capabilities = new Capabilities(true);
final GoPluginDescriptor descriptor = new GoPluginDescriptor("cd.go.example.plugin", null, null, null, null, false);
elasticAgentMetadataStore.setPluginInfo(new ElasticAgentPluginInfo(descriptor, null, null, null, capabilities));
when(registry.getPluginStatusReport("cd.go.example.plugin")).thenReturn("<div>This is a plugin status report snippet.</div>");
final String pluginStatusReport = service.getPluginStatusReport("cd.go.example.plugin");
assertThat(pluginStatusReport, is("<div>This is a plugin status report snippet.</div>"));
}
use of com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo in project gocd by gocd.
the class JobController method addElasticAgentInfo.
private void addElasticAgentInfo(JobInstance jobInstance, Map data) {
if (!jobInstance.currentStatus().isActive()) {
return;
}
final JobAgentMetadata jobAgentMetadata = jobAgentMetadataDao.load(jobInstance.getId());
if (jobAgentMetadata == null) {
return;
}
final String pluginId = jobAgentMetadata.elasticProfile().getPluginId();
final ElasticAgentPluginInfo pluginInfo = elasticAgentMetadataStore.getPluginInfo(pluginId);
if (pluginInfo != null && pluginInfo.getCapabilities().supportsAgentStatusReport()) {
final AgentConfig agentConfig = goConfigService.agentByUuid(jobInstance.getAgentUuid());
if (agentConfig != null && agentConfig.isElastic()) {
data.put("elasticAgentPluginId", agentConfig.getElasticPluginId());
data.put("elasticAgentId", agentConfig.getElasticAgentId());
return;
}
data.put("elasticAgentPluginId", pluginId);
}
}
use of com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo in project gocd by gocd.
the class ElasticAgentPluginInfoBuilderTest method shouldBuildPluginInfoWithProfileSettings.
@Test
public void shouldBuildPluginInfoWithProfileSettings() {
GoPluginDescriptor descriptor = new GoPluginDescriptor("plugin1", null, null, null, null, false);
List<PluginConfiguration> pluginConfigurations = Arrays.asList(new PluginConfiguration("aws_password", new Metadata(true, false)));
PluginSettingsProperty property = new PluginSettingsProperty("ami-id", "ami-123");
PluginSettingsConfiguration pluginSettingsConfiguration = new PluginSettingsConfiguration();
pluginSettingsConfiguration.add(property);
Image icon = new Image("content_type", "data", "hash");
when(pluginManager.resolveExtensionVersion("plugin1", ELASTIC_AGENT_EXTENSION, SUPPORTED_VERSIONS)).thenReturn("1.0");
when(extension.getPluginSettingsConfiguration(descriptor.id())).thenReturn(pluginSettingsConfiguration);
when(extension.getPluginSettingsView(descriptor.id())).thenReturn("some html");
when(extension.getIcon(descriptor.id())).thenReturn(icon);
when(extension.getProfileMetadata(descriptor.id())).thenReturn(pluginConfigurations);
when(extension.getProfileView(descriptor.id())).thenReturn("profile_view");
ElasticAgentPluginInfoBuilder builder = new ElasticAgentPluginInfoBuilder(extension);
ElasticAgentPluginInfo pluginInfo = builder.pluginInfoFor(descriptor);
assertThat(pluginInfo.getDescriptor(), is(descriptor));
assertThat(pluginInfo.getExtensionName(), is("elastic-agent"));
assertThat(pluginInfo.getImage(), is(icon));
assertThat(pluginInfo.getProfileSettings(), is(new PluggableInstanceSettings(pluginConfigurations, new PluginView("profile_view"))));
assertThat(pluginInfo.getPluginSettings(), is(new PluggableInstanceSettings(builder.configurations(pluginSettingsConfiguration), new PluginView("some html"))));
assertFalse(pluginInfo.supportsStatusReport());
}
use of com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo in project gocd by gocd.
the class ElasticAgentPluginInfoBuilderTest method shouldGetCapabilitiesForAPlugin.
@Test
public void shouldGetCapabilitiesForAPlugin() {
GoPluginDescriptor descriptor = new GoPluginDescriptor("plugin1", null, null, null, null, false);
when(pluginManager.resolveExtensionVersion("plugin1", ELASTIC_AGENT_EXTENSION, SUPPORTED_VERSIONS)).thenReturn("2.0");
Capabilities capabilities = new Capabilities(true);
when(extension.getCapabilities(descriptor.id())).thenReturn(capabilities);
ElasticAgentPluginInfo pluginInfo = new ElasticAgentPluginInfoBuilder(extension).pluginInfoFor(descriptor);
assertThat(pluginInfo.getCapabilities(), is(capabilities));
}
use of com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo in project gocd by gocd.
the class ElasticAgentPluginInfoBuilderTest method shouldContinueWithBuildingPluginInfoIfPluginSettingsIsNotProvidedByThePlugin.
@Test
public void shouldContinueWithBuildingPluginInfoIfPluginSettingsIsNotProvidedByThePlugin() {
GoPluginDescriptor descriptor = new GoPluginDescriptor("plugin1", null, null, null, null, false);
List<PluginConfiguration> pluginConfigurations = Arrays.asList(new PluginConfiguration("aws_password", new Metadata(true, false)));
Image icon = new Image("content_type", "data", "hash");
doThrow(new RuntimeException("foo")).when(extension).getPluginSettingsConfiguration(descriptor.id());
when(pluginManager.resolveExtensionVersion("plugin1", ELASTIC_AGENT_EXTENSION, SUPPORTED_VERSIONS)).thenReturn("1.0");
when(extension.getIcon(descriptor.id())).thenReturn(icon);
when(extension.getProfileMetadata(descriptor.id())).thenReturn(pluginConfigurations);
when(extension.getProfileView(descriptor.id())).thenReturn("profile_view");
ElasticAgentPluginInfoBuilder builder = new ElasticAgentPluginInfoBuilder(extension);
ElasticAgentPluginInfo pluginInfo = builder.pluginInfoFor(descriptor);
assertThat(pluginInfo.getDescriptor(), is(descriptor));
assertThat(pluginInfo.getExtensionName(), is("elastic-agent"));
assertThat(pluginInfo.getImage(), is(icon));
assertThat(pluginInfo.getProfileSettings(), is(new PluggableInstanceSettings(pluginConfigurations, new PluginView("profile_view"))));
assertNull(pluginInfo.getPluginSettings());
}
Aggregations