Search in sources :

Example 1 with ElasticAgentPluginInfo

use of com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo in project gocd by gocd.

the class CombinedPluginInfoTest method shouldFindFirstExtensionWithImageIfPluginImplementsAtleastOneExtensionWithImage.

@Test
public void shouldFindFirstExtensionWithImageIfPluginImplementsAtleastOneExtensionWithImage() throws Exception {
    Image image1 = new Image("c1", "d1", "hash1");
    Image image2 = new Image("c2", "d2", "hash2");
    Image image3 = new Image("c3", "d3", "hash3");
    ElasticAgentPluginInfo elasticAgentPluginInfo = new ElasticAgentPluginInfo(null, null, image1, null, null);
    AuthorizationPluginInfo authorizationPluginInfo = new AuthorizationPluginInfo(null, null, null, image2, null);
    AnalyticsPluginInfo analyticsPluginInfo = new AnalyticsPluginInfo(null, image3, null, null);
    assertThat(new CombinedPluginInfo(elasticAgentPluginInfo).getImage(), is(image1));
    assertThat(new CombinedPluginInfo(authorizationPluginInfo).getImage(), is(image2));
    assertThat(new CombinedPluginInfo(analyticsPluginInfo).getImage(), is(image3));
    assertThat(new CombinedPluginInfo(asList(elasticAgentPluginInfo, authorizationPluginInfo)).getImage(), anyOf(is(image1), is(image2)));
    assertThat(new CombinedPluginInfo(asList(analyticsPluginInfo, authorizationPluginInfo)).getImage(), anyOf(is(image2), is(image3)));
}
Also used : ElasticAgentPluginInfo(com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo) AnalyticsPluginInfo(com.thoughtworks.go.plugin.domain.analytics.AnalyticsPluginInfo) AuthorizationPluginInfo(com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo) Test(org.junit.Test)

Example 2 with ElasticAgentPluginInfo

use of com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo in project gocd by gocd.

the class JobControllerIntegrationTest method jobDetailModel_shouldHaveTheElasticProfilePluginIdWhenAgentIsNotAssigned.

@Test
public void jobDetailModel_shouldHaveTheElasticProfilePluginIdWhenAgentIsNotAssigned() throws Exception {
    Pipeline pipeline = fixture.createPipelineWithFirstStageAssigned();
    Stage stage = pipeline.getFirstStage();
    JobInstance job = stage.getFirstJob();
    GoPluginDescriptor.About about = new GoPluginDescriptor.About("name", "0.1", "17.3.0", "desc", null, null);
    GoPluginDescriptor descriptor = new GoPluginDescriptor("plugin_id", null, about, null, null, false);
    ElasticAgentMetadataStore.instance().setPluginInfo(new ElasticAgentPluginInfo(descriptor, null, null, null, new Capabilities(false, true)));
    fixture.addJobAgentMetadata(new JobAgentMetadata(job.getId(), new ElasticProfile("profile_id", "plugin_id", Collections.EMPTY_LIST)));
    ModelAndView modelAndView = controller.jobDetail(pipeline.getName(), String.valueOf(pipeline.getCounter()), stage.getName(), String.valueOf(stage.getCounter()), job.getName());
    assertThat(modelAndView.getModel().get("elasticAgentPluginId"), is("plugin_id"));
}
Also used : ElasticAgentPluginInfo(com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo) Capabilities(com.thoughtworks.go.plugin.domain.elastic.Capabilities) ModelAndView(org.springframework.web.servlet.ModelAndView) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) Test(org.junit.Test)

Example 3 with ElasticAgentPluginInfo

use of com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo in project gocd by gocd.

the class ElasticAgentMetadataLoaderTest method onPluginLoaded_shouldAddPluginInfoToMetadataStore.

@Test
public void onPluginLoaded_shouldAddPluginInfoToMetadataStore() throws Exception {
    GoPluginDescriptor descriptor = new GoPluginDescriptor("plugin1", null, null, null, null, false);
    ElasticAgentMetadataLoader metadataLoader = new ElasticAgentMetadataLoader(pluginManager, metadataStore, infoBuilder, extension);
    ElasticAgentPluginInfo pluginInfo = new ElasticAgentPluginInfo(descriptor, null, null, null, null);
    when(extension.canHandlePlugin(descriptor.id())).thenReturn(true);
    when(infoBuilder.pluginInfoFor(descriptor)).thenReturn(pluginInfo);
    metadataLoader.pluginLoaded(descriptor);
    verify(metadataStore).setPluginInfo(pluginInfo);
}
Also used : ElasticAgentPluginInfo(com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) Test(org.junit.Test)

Example 4 with ElasticAgentPluginInfo

use of com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo in project gocd by gocd.

the class ElasticAgentMetadataLoaderTest method onPluginUnloded_shouldRemoveTheCorrespondingPluginInfoFromStore.

@Test
public void onPluginUnloded_shouldRemoveTheCorrespondingPluginInfoFromStore() throws Exception {
    GoPluginDescriptor descriptor = new GoPluginDescriptor("plugin1", null, null, null, null, false);
    ElasticAgentMetadataLoader metadataLoader = new ElasticAgentMetadataLoader(pluginManager, metadataStore, infoBuilder, extension);
    ElasticAgentPluginInfo pluginInfo = new ElasticAgentPluginInfo(descriptor, null, null, null, null);
    metadataStore.setPluginInfo(pluginInfo);
    metadataLoader.pluginUnLoaded(descriptor);
    verify(metadataStore).remove(descriptor.id());
}
Also used : ElasticAgentPluginInfo(com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) Test(org.junit.Test)

Example 5 with ElasticAgentPluginInfo

use of com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo in project gocd by gocd.

the class ElasticAgentPluginServiceTest method shouldErrorOutWhenPluginDoesNotAgentSupportStatusReport.

@Test
public void shouldErrorOutWhenPluginDoesNotAgentSupportStatusReport() {
    final Capabilities capabilities = new Capabilities(true, false);
    final GoPluginDescriptor descriptor = new GoPluginDescriptor("cd.go.example.plugin", null, null, null, null, false);
    elasticAgentMetadataStore.setPluginInfo(new ElasticAgentPluginInfo(descriptor, null, null, null, capabilities));
    thrown.expect(UnsupportedOperationException.class);
    thrown.expectMessage("Plugin does not support agent status report.");
    service.getAgentStatusReport("cd.go.example.plugin", null, null);
}
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)

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