Search in sources :

Example 6 with ExposedService

use of com.sequenceiq.cloudbreak.api.service.ExposedService in project cloudbreak by hortonworks.

the class ClusterHostServiceRunnerTest method setupMocksForRunClusterServices.

private void setupMocksForRunClusterServices() {
    when(umsClient.getAccountDetails(any(), any(), any())).thenReturn(UserManagementProto.Account.getDefaultInstance());
    when(stackService.get(any())).thenReturn(stack);
    when(stack.getCluster()).thenReturn(cluster);
    when(stack.getTunnel()).thenReturn(Tunnel.DIRECT);
    when(stack.getCloudPlatform()).thenReturn(CloudPlatform.AWS.name());
    when(stack.getResourceCrn()).thenReturn(TEST_CLUSTER_CRN);
    when(cluster.getName()).thenReturn("clustername");
    when(cluster.getStack()).thenReturn(stack);
    when(componentLocator.getComponentLocation(any(), any())).thenReturn(new HashMap<>());
    when(exposedServiceCollector.getImpalaService()).thenReturn(mock(ExposedService.class));
    when(environmentConfigProvider.getParentEnvironmentCrn(any())).thenReturn("crn:cdp:iam:us-west-1:accid:user:mockuser@cloudera.com");
    ClouderaManagerRepo clouderaManagerRepo = mock(ClouderaManagerRepo.class);
    when(clouderaManagerRepo.getVersion()).thenReturn("7.2.2");
    GatewayConfig gatewayConfig = mock(GatewayConfig.class);
    when(gatewayConfig.getPrivateAddress()).thenReturn("1.2.3.4");
    when(gatewayConfig.getHostname()).thenReturn("hostname");
    when(gatewayConfigService.getPrimaryGatewayConfig(any())).thenReturn(gatewayConfig);
    when(clusterComponentConfigProvider.getClouderaManagerRepoDetails(any())).thenReturn(clouderaManagerRepo);
    when(exposedServiceCollector.getRangerService()).thenReturn(mock(ExposedService.class));
    ExposedService cmExposedService = mock(ExposedService.class);
    when(cmExposedService.getServiceName()).thenReturn("CM");
    when(exposedServiceCollector.getClouderaManagerService()).thenReturn(cmExposedService);
    Template template = new Template();
    template.setTemporaryStorage(TemporaryStorage.EPHEMERAL_VOLUMES);
    Set<InstanceGroup> instanceGroups = new HashSet<>();
    createInstanceGroup(template, instanceGroups, "fqdn1", null, "1.1.1.1", "1.1.1.2");
    createInstanceGroup(template, instanceGroups, "fqdn2", null, "1.1.2.1", "1.1.2.2");
    InstanceGroup gwIg = createInstanceGroup(template, instanceGroups, "gateway1", "gateway2", "1.1.3.1", "1.1.3.2");
    lenient().when(stack.getNotTerminatedAndNotZombieGatewayInstanceMetadata()).thenReturn(Lists.newArrayList(gwIg.getAllInstanceMetaData()));
    when(stack.getInstanceGroups()).thenReturn(instanceGroups);
    RdsConfigWithoutCluster rdsConfigWithoutCluster = mock(RdsConfigWithoutCluster.class);
    when(rdsConfigWithoutClusterService.findByClusterIdAndType(any(), eq(DatabaseType.CLOUDERA_MANAGER))).thenReturn(rdsConfigWithoutCluster);
    when(rdsConfigWithoutCluster.getType()).thenReturn("asdf");
    when(rdsConfigWithoutCluster.getConnectionURL()).thenReturn("jdbc:postgresql:subname://some-rds.1d3nt1f13r.eu-west-1.rds.amazonaws.com:5432/ranger");
    when(rdsConfigWithoutCluster.getConnectionUserName()).thenReturn(new Secret("username"));
    when(rdsConfigWithoutCluster.getConnectionPassword()).thenReturn(new Secret("password"));
    when(loadBalancerSANProvider.getLoadBalancerSAN(stack)).thenReturn(Optional.empty());
    ClusterPreCreationApi clusterPreCreationApi = mock(ClusterPreCreationApi.class);
    when(clusterApiConnectors.getConnector(cluster)).thenReturn(clusterPreCreationApi);
    ServiceLocationMap serviceLocationMap = new ServiceLocationMap();
    serviceLocationMap.add(new ServiceLocation("serv", "paath"));
    when(clusterPreCreationApi.getServiceLocations()).thenReturn(serviceLocationMap);
    ReflectionTestUtils.setField(underTest, "cmHeartbeatInterval", "1");
    ReflectionTestUtils.setField(underTest, "cmMissedHeartbeatInterval", "1");
}
Also used : ServiceLocationMap(com.sequenceiq.cloudbreak.cluster.model.ServiceLocationMap) ClusterPreCreationApi(com.sequenceiq.cloudbreak.cluster.api.ClusterPreCreationApi) Template(com.sequenceiq.cloudbreak.domain.Template) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) Secret(com.sequenceiq.cloudbreak.service.secret.domain.Secret) ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) ExposedService(com.sequenceiq.cloudbreak.api.service.ExposedService) ServiceLocation(com.sequenceiq.cloudbreak.cluster.model.ServiceLocation) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig) HashSet(java.util.HashSet) RdsConfigWithoutCluster(com.sequenceiq.cloudbreak.domain.view.RdsConfigWithoutCluster)

Example 7 with ExposedService

use of com.sequenceiq.cloudbreak.api.service.ExposedService in project cloudbreak by hortonworks.

the class OpdbServiceEndpointCollectorTest method parseExposedServices.

private static MultiValuedMap<String, ExposedService> parseExposedServices() {
    MultiValuedMap<String, ExposedService> services = new ArrayListValuedHashMap<>();
    try (InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("definitions/exposed-services.json")) {
        String rawJson = IOUtils.toString(is, StandardCharsets.UTF_8);
        JsonUtil.readValue(rawJson, com.sequenceiq.cloudbreak.api.service.ExposedServices.class).getServices().forEach(exposedService -> services.put(exposedService.getName(), exposedService));
        return services;
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : ExposedService(com.sequenceiq.cloudbreak.api.service.ExposedService) InputStream(java.io.InputStream) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) IOException(java.io.IOException) ArrayListValuedHashMap(org.apache.commons.collections4.multimap.ArrayListValuedHashMap)

Example 8 with ExposedService

use of com.sequenceiq.cloudbreak.api.service.ExposedService 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 9 with ExposedService

use of com.sequenceiq.cloudbreak.api.service.ExposedService in project cloudbreak by hortonworks.

the class ServiceEndpointCollectorTest method testGetCmServerUrlInTopologiesWithIndividualGatewayOnPort8443.

@Test
public void testGetCmServerUrlInTopologiesWithIndividualGatewayOnPort8443() {
    ExposedService clouderaManagerUIService = getClouderaManagerUIService();
    Cluster cluster = createClusterWithComponents(new ExposedService[] { clouderaManagerUIService, exposedService("ATLAS") }, new ExposedService[] { exposedService("HIVE_SERVER") }, GatewayType.INDIVIDUAL);
    cluster.getGateway().setGatewayPort(8443);
    String result = underTest.getManagerServerUrl(cluster, CLOUDERA_MANAGER_IP);
    assertEquals("https://127.0.0.1:8443/gateway-path/topology1/cmf/home/", result);
}
Also used : ExposedService(com.sequenceiq.cloudbreak.api.service.ExposedService) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 10 with ExposedService

use of com.sequenceiq.cloudbreak.api.service.ExposedService in project cloudbreak by hortonworks.

the class ExposedServiceUtil method exposedService.

public static ExposedService exposedService(String name) {
    ExposedService exposedService = new ExposedService();
    exposedService.setApiIncluded(true);
    exposedService.setApiOnly(true);
    exposedService.setDisplayName(name);
    exposedService.setKnoxService(name);
    exposedService.setKnoxUrl(name);
    exposedService.setName(name);
    exposedService.setPort(1);
    exposedService.setServiceName(name);
    exposedService.setSsoSupported(true);
    exposedService.setTlsPort(1);
    exposedService.setVisibleForDatahub(true);
    exposedService.setVisibleForDatalake(true);
    return exposedService;
}
Also used : ExposedService(com.sequenceiq.cloudbreak.api.service.ExposedService)

Aggregations

ExposedService (com.sequenceiq.cloudbreak.api.service.ExposedService)24 Gateway (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway)10 ArrayList (java.util.ArrayList)8 GatewayTopology (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology)6 List (java.util.List)6 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)5 ClusterExposedServiceV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.gateway.topology.ClusterExposedServiceV4Response)4 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)4 ExposedServices (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.ExposedServices)4 IOException (java.io.IOException)4 GatewayType (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.GatewayType)3 GatewayTopologyV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.topology.GatewayTopologyV4Request)3 ExposedServiceV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.ExposedServiceV4Response)3 ExposedServiceCollector (com.sequenceiq.cloudbreak.api.service.ExposedServiceCollector)3 EntitlementService (com.sequenceiq.cloudbreak.auth.altus.EntitlementService)3 CmTemplateProcessor (com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor)3 CmTemplateProcessorFactory (com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessorFactory)3 Json (com.sequenceiq.cloudbreak.common.json.Json)3 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)3 BlueprintService (com.sequenceiq.cloudbreak.service.blueprint.BlueprintService)3