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");
}
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);
}
}
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());
}
}
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);
}
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;
}
Aggregations