Search in sources :

Example 1 with Capabilities

use of com.thoughtworks.go.plugin.domain.elastic.Capabilities 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 2 with Capabilities

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

the class ElasticAgentExtensionV2Test method shouldGetCapabilitiesOfAPlugin.

@Test
public void shouldGetCapabilitiesOfAPlugin() {
    final String responseBody = "{\"supports_status_report\":\"true\"}";
    when(pluginManager.submitTo(eq(PLUGIN_ID), eq(ELASTIC_AGENT_EXTENSION), requestArgumentCaptor.capture())).thenReturn(DefaultGoPluginApiResponse.success(responseBody));
    final Capabilities capabilities = extensionV2.getCapabilities(PLUGIN_ID);
    assertTrue(capabilities.supportsStatusReport());
    assertFalse(capabilities.supportsAgentStatusReport());
}
Also used : Capabilities(com.thoughtworks.go.plugin.domain.elastic.Capabilities) Test(org.junit.Test)

Example 3 with Capabilities

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

the class ElasticAgentExtensionV2Test method getCapabilitiesOfAPluginShouldAlwaysReturnFalseForAgentStatusReport.

@Test
public void getCapabilitiesOfAPluginShouldAlwaysReturnFalseForAgentStatusReport() {
    final String responseBody = "{\"supports_status_report\":\"true\",\"supports_agent_status_report\":\"true\"}";
    when(pluginManager.submitTo(eq(PLUGIN_ID), eq(ELASTIC_AGENT_EXTENSION), requestArgumentCaptor.capture())).thenReturn(DefaultGoPluginApiResponse.success(responseBody));
    final Capabilities capabilities = extensionV2.getCapabilities(PLUGIN_ID);
    assertTrue(capabilities.supportsStatusReport());
    assertFalse(capabilities.supportsAgentStatusReport());
}
Also used : Capabilities(com.thoughtworks.go.plugin.domain.elastic.Capabilities) Test(org.junit.Test)

Example 4 with Capabilities

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

the class ElasticAgentExtensionConverterV2Test method shouldGetCapabilitiesFromResponseBody.

@Test
public void shouldGetCapabilitiesFromResponseBody() {
    String responseBody = "{\"supports_status_report\":\"true\"}";
    Capabilities capabilities = converterV2.getCapabilitiesFromResponseBody(responseBody);
    assertTrue(capabilities.supportsStatusReport());
}
Also used : Capabilities(com.thoughtworks.go.plugin.domain.elastic.Capabilities) Test(org.junit.Test)

Example 5 with Capabilities

use of com.thoughtworks.go.plugin.domain.elastic.Capabilities 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

Capabilities (com.thoughtworks.go.plugin.domain.elastic.Capabilities)16 Test (org.junit.Test)16 ElasticAgentPluginInfo (com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo)7 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)7 ElasticProfile (com.thoughtworks.go.config.elastic.ElasticProfile)2 ModelAndView (org.springframework.web.servlet.ModelAndView)2 AgentConfig (com.thoughtworks.go.config.AgentConfig)1