Search in sources :

Example 11 with ElasticAgentPluginInfo

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>"));
}
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) Test(org.junit.Test)

Example 12 with ElasticAgentPluginInfo

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);
    }
}
Also used : ElasticAgentPluginInfo(com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo)

Example 13 with ElasticAgentPluginInfo

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());
}
Also used : ElasticAgentPluginInfo(com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) PluginSettingsConfiguration(com.thoughtworks.go.plugin.access.common.settings.PluginSettingsConfiguration) PluginSettingsProperty(com.thoughtworks.go.plugin.access.common.settings.PluginSettingsProperty) Test(org.junit.Test)

Example 14 with ElasticAgentPluginInfo

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));
}
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) Test(org.junit.Test)

Example 15 with ElasticAgentPluginInfo

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());
}
Also used : ElasticAgentPluginInfo(com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) Test(org.junit.Test)

Aggregations

ElasticAgentPluginInfo (com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo)16 Test (org.junit.Test)15 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)11 Capabilities (com.thoughtworks.go.plugin.domain.elastic.Capabilities)7 ConfigurationKey (com.thoughtworks.go.domain.config.ConfigurationKey)3 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)3 ConfigurationValue (com.thoughtworks.go.domain.config.ConfigurationValue)3 EncryptedConfigurationValue (com.thoughtworks.go.domain.config.EncryptedConfigurationValue)3 PluggableInstanceSettings (com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings)3 ElasticProfile (com.thoughtworks.go.config.elastic.ElasticProfile)2 Metadata (com.thoughtworks.go.plugin.domain.common.Metadata)2 PluginConfiguration (com.thoughtworks.go.plugin.domain.common.PluginConfiguration)2 ModelAndView (org.springframework.web.servlet.ModelAndView)2 AgentConfig (com.thoughtworks.go.config.AgentConfig)1 PluginSettingsConfiguration (com.thoughtworks.go.plugin.access.common.settings.PluginSettingsConfiguration)1 PluginSettingsProperty (com.thoughtworks.go.plugin.access.common.settings.PluginSettingsProperty)1 AnalyticsPluginInfo (com.thoughtworks.go.plugin.domain.analytics.AnalyticsPluginInfo)1 AuthorizationPluginInfo (com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo)1 ArrayList (java.util.ArrayList)1