Search in sources :

Example 11 with Gateway

use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway in project cloudbreak by hortonworks.

the class StackToTemplatePreparationObjectConverterTest method testConvertWhenClusterGivesGatewayThenNotNullShouldBeStored.

@Test
public void testConvertWhenClusterGivesGatewayThenNotNullShouldBeStored() {
    Gateway gateway = mock(Gateway.class);
    when(gateway.getSignKey()).thenReturn(null);
    when(cluster.getGateway()).thenReturn(gateway);
    when(blueprintViewProvider.getBlueprintView(any())).thenReturn(getBlueprintView());
    TemplatePreparationObject result = underTest.convert(stackMock);
    assertThat(result.getGatewayView()).isNotNull();
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) Test(org.junit.jupiter.api.Test)

Example 12 with Gateway

use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway in project cloudbreak by hortonworks.

the class StackV4RequestToGatewayConverterTest method shouldCreateCorrectSsoUrlWhenClusterNameisProvided.

@Test
public void shouldCreateCorrectSsoUrlWhenClusterNameisProvided() {
    GatewayV4Request gatewayJson = new GatewayV4Request();
    gatewayJson.setPath("funnyPath");
    gatewayJson.setTopologies(Arrays.asList(getGatewayTopologyV4Request()));
    StackV4Request source = generateStackV4Request(gatewayJson);
    when(gatewayJsonValidator.validate(gatewayJson)).thenReturn(ValidationResult.builder().build());
    doAnswer(i -> {
        Gateway gw = i.getArgument(1);
        gw.setSsoProvider("SSOPROVIDER");
        gw.setPath(gatewayJson.getPath());
        gw.setTopologies(GATEWAY_TOPOLOGY);
        gw.setGatewayType(GatewayType.CENTRAL);
        return null;
    }).when(convertUtil).setBasicProperties(eq(gatewayJson), any(Gateway.class));
    Gateway result = underTest.convert(source);
    assertEquals("SSOPROVIDER", result.getSsoProvider());
    assertEquals("funnyPath", result.getPath());
    assertTrue(EqualsBuilder.reflectionEquals(GATEWAY_TOPOLOGY, result.getTopologies()));
    assertEquals(GatewayType.CENTRAL, result.getGatewayType());
}
Also used : GatewayV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.GatewayV4Request) StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) Test(org.junit.Test)

Example 13 with Gateway

use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway in project cloudbreak by hortonworks.

the class StackV4RequestToTemplatePreparationObjectConverterTest method testConvertWhenGatewayExistsInStack.

@Test
public void testConvertWhenGatewayExistsInStack() {
    when(stackV4RequestToGatewayConverter.convert(source)).thenReturn(new Gateway());
    when(cluster.getGateway()).thenReturn(new GatewayV4Request());
    TemplatePreparationObject result = underTest.convert(source);
    assertNotNull(result.getGatewayView());
}
Also used : GatewayV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.GatewayV4Request) TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) Test(org.junit.Test)

Example 14 with Gateway

use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway in project cloudbreak by hortonworks.

the class ServiceEndpointCollectorTest method testPrepareClusterExposedServicesByGeneratedBlueprint.

@Test
public void testPrepareClusterExposedServicesByGeneratedBlueprint() {
    Cluster cluster = createClusterWithComponents(new ExposedService[] { exposedService("ATLAS") }, new ExposedService[] { exposedService("HIVE_SERVER"), exposedService("WEBHDFS") }, GatewayType.INDIVIDUAL);
    cluster.getGateway().setGatewayPort(443);
    cluster.setExtendedBlueprintText("extended-blueprint");
    mockBlueprintTextProcessor();
    mockComponentLocator(Lists.newArrayList("10.0.0.1"));
    Map<String, Collection<ClusterExposedServiceV4Response>> clusterExposedServicesMap = underTest.prepareClusterExposedServices(cluster, "10.0.0.1");
    assertEquals(4L, clusterExposedServicesMap.keySet().size());
    Collection<ClusterExposedServiceV4Response> topology2ClusterExposedServiceV4Responses = clusterExposedServicesMap.get("topology2");
    Optional<ClusterExposedServiceV4Response> webHDFS = topology2ClusterExposedServiceV4Responses.stream().filter(service -> "WEBHDFS".equals(service.getKnoxService())).findFirst();
    if (webHDFS.isPresent()) {
        assertEquals("https://10.0.0.1/gateway-path/topology2/webhdfs/v1", webHDFS.get().getServiceUrl());
        assertEquals("WEBHDFS", webHDFS.get().getKnoxService());
        assertEquals("WebHDFS", webHDFS.get().getDisplayName());
        assertEquals("NAMENODE", webHDFS.get().getServiceName());
        assertTrue(webHDFS.get().isOpen());
    }
    Optional<ClusterExposedServiceV4Response> sparkHistoryUI = topology2ClusterExposedServiceV4Responses.stream().filter(service -> "SPARKHISTORYUI".equals(service.getKnoxService())).findFirst();
    if (sparkHistoryUI.isPresent()) {
        assertEquals("https://10.0.0.1/gateway-path/topology2/sparkhistory/", sparkHistoryUI.get().getServiceUrl());
        assertEquals("SPARKHISTORYUI", sparkHistoryUI.get().getKnoxService());
        assertEquals("Spark 1.x History Server", sparkHistoryUI.get().getDisplayName());
        assertEquals("SPARK_YARN_HISTORY_SERVER", sparkHistoryUI.get().getServiceName());
        assertFalse(sparkHistoryUI.get().isOpen());
    }
    Optional<ClusterExposedServiceV4Response> hiveServer = topology2ClusterExposedServiceV4Responses.stream().filter(service -> "HIVE".equals(service.getKnoxService())).findFirst();
    if (hiveServer.isPresent()) {
        assertEquals("jdbc:hive2://10.0.0.1/;ssl=true;sslTrustStore=/cert/gateway.jks;trustStorePassword=${GATEWAY_JKS_PASSWORD};" + "transportMode=http;httpPath=gateway-path/topology2/hive", hiveServer.get().getServiceUrl());
        assertEquals("HIVE", hiveServer.get().getKnoxService());
        assertEquals("Hive Server", hiveServer.get().getDisplayName());
        assertEquals("HIVE_SERVER", hiveServer.get().getServiceName());
        assertTrue(hiveServer.get().isOpen());
    }
}
Also used : Arrays(java.util.Arrays) EntitlementService(com.sequenceiq.cloudbreak.auth.altus.EntitlementService) ClusterExposedServiceV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.gateway.topology.ClusterExposedServiceV4Response) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) GatewayTopologyV4RequestToExposedServicesConverter(com.sequenceiq.cloudbreak.converter.v4.stacks.cluster.gateway.topology.GatewayTopologyV4RequestToExposedServicesConverter) CmTemplateProcessorFactory(com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessorFactory) Orchestrator(com.sequenceiq.cloudbreak.domain.Orchestrator) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) Map(java.util.Map) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) ExposedServiceCollector(com.sequenceiq.cloudbreak.api.service.ExposedServiceCollector) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) ExposedServiceListValidator(com.sequenceiq.cloudbreak.controller.validation.stack.cluster.gateway.ExposedServiceListValidator) Collection(java.util.Collection) Set(java.util.Set) ExposedService(com.sequenceiq.cloudbreak.api.service.ExposedService) ArgumentMatchers.anyList(org.mockito.ArgumentMatchers.anyList) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) Json(com.sequenceiq.cloudbreak.common.json.Json) List(java.util.List) GatewayType(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.GatewayType) StackServiceComponentDescriptors(com.sequenceiq.cloudbreak.cmtemplate.validation.StackServiceComponentDescriptors) Assert.assertFalse(org.junit.Assert.assertFalse) Tenant(com.sequenceiq.cloudbreak.workspace.model.Tenant) Optional(java.util.Optional) ExposedServices(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.ExposedServices) CmTemplateProcessor(com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) GatewayTopologyV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.topology.GatewayTopologyV4Request) Mockito.mock(org.mockito.Mockito.mock) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ArgumentMatchers.anyLong(org.mockito.ArgumentMatchers.anyLong) ExposedServiceUtil.exposedService(com.sequenceiq.cloudbreak.controller.validation.stack.cluster.gateway.ExposedServiceUtil.exposedService) Mock(org.mockito.Mock) RunWith(org.junit.runner.RunWith) ArrayList(java.util.ArrayList) Lists(com.google.common.collect.Lists) ExposedServiceV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.ExposedServiceV4Response) FileReaderUtils(com.sequenceiq.cloudbreak.util.FileReaderUtils) Before(org.junit.Before) InjectMocks(org.mockito.InjectMocks) Collections.emptyMap(java.util.Collections.emptyMap) Assert.assertTrue(org.junit.Assert.assertTrue) ReflectionTestUtils(org.springframework.test.util.ReflectionTestUtils) IOException(java.io.IOException) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Maps(com.google.common.collect.Maps) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace) GatewayTopology(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology) BlueprintService(com.sequenceiq.cloudbreak.service.blueprint.BlueprintService) ComponentLocatorService(com.sequenceiq.cloudbreak.service.blueprint.ComponentLocatorService) Assert.assertEquals(org.junit.Assert.assertEquals) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) Collection(java.util.Collection) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ClusterExposedServiceV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.gateway.topology.ClusterExposedServiceV4Response) Test(org.junit.Test)

Example 15 with Gateway

use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway in project cloudbreak by hortonworks.

the class ServiceEndpointCollectorTest method clusterkWithOrchestrator.

private Cluster clusterkWithOrchestrator(String orchestratorType) {
    Cluster cluster = new Cluster();
    Stack stack = new Stack();
    Orchestrator orchestrator = new Orchestrator();
    orchestrator.setType(orchestratorType);
    Gateway gateway = new Gateway();
    gateway.setPath(GATEWAY_PATH);
    stack.setOrchestrator(orchestrator);
    cluster.setStack(stack);
    cluster.setGateway(gateway);
    Blueprint blueprint = new Blueprint();
    Workspace workspace = new Workspace();
    Tenant tenant = new Tenant();
    tenant.setName("tenant");
    workspace.setTenant(tenant);
    cluster.setWorkspace(workspace);
    try {
        String testBlueprint = FileReaderUtils.readFileFromClasspath("/test/defaults/blueprints/hdp26-data-science-spark2-text.bp");
        blueprint.setBlueprintText(testBlueprint);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    cluster.setBlueprint(blueprint);
    return cluster;
}
Also used : Tenant(com.sequenceiq.cloudbreak.workspace.model.Tenant) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) IOException(java.io.IOException) Orchestrator(com.sequenceiq.cloudbreak.domain.Orchestrator) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace)

Aggregations

Gateway (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway)69 Test (org.junit.Test)30 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)20 HashSet (java.util.HashSet)17 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)15 TemplatePreparationObject (com.sequenceiq.cloudbreak.template.TemplatePreparationObject)15 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)15 GatewayV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.GatewayV4Request)13 ExposedService (com.sequenceiq.cloudbreak.api.service.ExposedService)12 GatewayTopology (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology)12 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)11 BlueprintView (com.sequenceiq.cloudbreak.template.views.BlueprintView)11 GeneralClusterConfigs (com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs)10 IOException (java.io.IOException)10 VirtualGroupRequest (com.sequenceiq.cloudbreak.auth.altus.VirtualGroupRequest)8 ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)8 ArrayList (java.util.ArrayList)8 Json (com.sequenceiq.cloudbreak.common.json.Json)7 IdBroker (com.sequenceiq.cloudbreak.domain.stack.cluster.IdBroker)7 ExposedServices (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.ExposedServices)7