use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceMetadataType.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());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceMetadataType.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());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceMetadataType.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());
}
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceMetadataType.GATEWAY in project cloudbreak by hortonworks.
the class ClusterRequestToClusterConverterTest method testConvert.
@Test
public void testConvert() {
// GIVEN
ClusterV4Request request = getRequest("cluster.json");
Blueprint blueprint = new Blueprint();
blueprint.setStackType(StackType.HDP.name());
given(blueprintService.getByNameForWorkspaceAndLoadDefaultsIfNecessary(eq("my-blueprint"), any())).willReturn(blueprint);
given(gatewayV4RequestToGatewayConverter.convert(request.getGateway())).willReturn(new Gateway());
// WHEN
Cluster result = underTest.convert(request);
// THEN
assertAllFieldsNotNull(result, Arrays.asList("stack", "blueprint", "creationStarted", "creationFinished", "upSince", "statusReason", "clusterManagerIp", "fileSystem", "additionalFileSystem", "rdsConfigs", "attributes", "uptime", "ambariSecurityMasterKey", "proxyConfigCrn", "configStrategy", "extendedBlueprintText", "environmentCrn", "variant", "description", "databaseServerCrn", "fqdn", "customConfigurations"));
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceMetadataType.GATEWAY in project cloudbreak by hortonworks.
the class ClusterRequestToClusterConverterTest method testNoGateway.
@Test
public void testNoGateway() {
// GIVEN
Blueprint blueprint = new Blueprint();
blueprint.setStackType(StackType.HDP.name());
given(blueprintService.getByNameForWorkspaceAndLoadDefaultsIfNecessary(eq("my-blueprint"), any())).willReturn(blueprint);
// WHEN
ClusterV4Request clusterRequest = getRequest("cluster-no-gateway.json");
Cluster result = underTest.convert(clusterRequest);
// THEN
assertAllFieldsNotNull(result, Arrays.asList("stack", "blueprint", "creationStarted", "creationFinished", "upSince", "statusReason", "clusterManagerIp", "fileSystem", "additionalFileSystem", "rdsConfigs", "attributes", "uptime", "ambariSecurityMasterKey", "proxyConfigCrn", "configStrategy", "extendedBlueprintText", "gateway", "environmentCrn", "variant", "description", "databaseServerCrn", "fqdn", "customConfigurations"));
assertNull(result.getGateway());
}
Aggregations