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