Search in sources :

Example 66 with Gateway

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

the class HueConfigProviderTest method getServiceConfigVariablesWhenKnoxConfiguredToExternalDomainWhenNoSafetyValve.

@Test
public void getServiceConfigVariablesWhenKnoxConfiguredToExternalDomainWhenNoSafetyValve() {
    BlueprintView blueprintView = mock(BlueprintView.class);
    when(blueprintView.getVersion()).thenReturn("7.1.0");
    CmTemplateProcessor templateProcessor = mock(CmTemplateProcessor.class);
    when(templateProcessor.getVersion()).thenReturn(Optional.ofNullable("7.1.0"));
    when(blueprintView.getProcessor()).thenReturn(templateProcessor);
    RDSConfig rdsConfig = new RDSConfig();
    rdsConfig.setType(HUE);
    rdsConfig.setConnectionURL(String.format("jdbc:%s://%s:%s/%s", DB_PROVIDER, HOST, PORT, DB_NAME));
    rdsConfig.setConnectionUserName(USER_NAME);
    rdsConfig.setConnectionPassword(PASSWORD);
    String expectedExternalFQDN = "myaddress.cloudera.site";
    String expectedInternalFQDN = "private-gateway.cloudera.site";
    GeneralClusterConfigs generalClusterConfigs = new GeneralClusterConfigs();
    generalClusterConfigs.setExternalFQDN(expectedExternalFQDN);
    generalClusterConfigs.setKnoxUserFacingCertConfigured(true);
    generalClusterConfigs.setPrimaryGatewayInstanceDiscoveryFQDN(Optional.of(expectedInternalFQDN));
    TemplatePreparationObject tpo = new Builder().withGeneralClusterConfigs(generalClusterConfigs).withGateway(new Gateway(), "", new HashSet<>()).withBlueprintView(blueprintView).withRdsConfigs(Set.of(rdsConfig)).build();
    List<ApiClusterTemplateVariable> result = underTest.getServiceConfigVariables(tpo);
    Map<String, String> paramToVariable = result.stream().collect(Collectors.toMap(ApiClusterTemplateVariable::getName, ApiClusterTemplateVariable::getValue));
    String proxyHostsExpected1 = String.join(",", expectedInternalFQDN, expectedExternalFQDN);
    String proxyHostsExpected2 = String.join(",", expectedExternalFQDN, expectedInternalFQDN);
    assertEquals(7, paramToVariable.size());
    assertThat(paramToVariable).contains(new SimpleEntry<>("hue-hue_database_host", HOST), new SimpleEntry<>("hue-hue_database_port", PORT), new SimpleEntry<>("hue-hue_database_name", DB_NAME), new SimpleEntry<>("hue-hue_database_type", DB_PROVIDER), new SimpleEntry<>("hue-hue_database_user", USER_NAME), new SimpleEntry<>("hue-hue_database_password", PASSWORD));
    assertThat(paramToVariable).containsAnyOf(new SimpleEntry<>("hue-knox_proxyhosts", proxyHostsExpected1), new SimpleEntry<>("hue-knox_proxyhosts", proxyHostsExpected2));
}
Also used : GeneralClusterConfigs(com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs) BlueprintView(com.sequenceiq.cloudbreak.template.views.BlueprintView) RDSConfig(com.sequenceiq.cloudbreak.domain.RDSConfig) Builder(com.sequenceiq.cloudbreak.template.TemplatePreparationObject.Builder) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) CmTemplateProcessor(com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor) ApiClusterTemplateVariable(com.cloudera.api.swagger.model.ApiClusterTemplateVariable) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 67 with Gateway

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

the class HueConfigProviderTest method getServiceConfigsWhenKnoxConfiguredToExternalDomain.

@Test
public void getServiceConfigsWhenKnoxConfiguredToExternalDomain() {
    BlueprintView blueprintView = getMockBlueprintView("7.0.2", "7.0.2");
    GeneralClusterConfigs generalClusterConfigs = new GeneralClusterConfigs();
    generalClusterConfigs.setExternalFQDN("myaddress.cloudera.site");
    generalClusterConfigs.setKnoxUserFacingCertConfigured(true);
    generalClusterConfigs.setPrimaryGatewayInstanceDiscoveryFQDN(Optional.of("private-gateway.cloudera.site"));
    TemplatePreparationObject tpo = new Builder().withGeneralClusterConfigs(generalClusterConfigs).withBlueprintView(blueprintView).withGateway(new Gateway(), "", new HashSet<>()).build();
    List<ApiClusterTemplateConfig> result = underTest.getServiceConfigs(null, tpo);
    Map<String, String> paramToVariable = result.stream().collect(Collectors.toMap(ApiClusterTemplateConfig::getName, ApiClusterTemplateConfig::getVariable));
    assertThat(paramToVariable).containsOnly(new SimpleEntry<>("database_host", "hue-hue_database_host"), new SimpleEntry<>("database_port", "hue-hue_database_port"), new SimpleEntry<>("database_name", "hue-hue_database_name"), new SimpleEntry<>("database_type", "hue-hue_database_type"), new SimpleEntry<>("database_user", "hue-hue_database_user"), new SimpleEntry<>("database_password", "hue-hue_database_password"), new SimpleEntry<>("hue_service_safety_valve", "hue-hue_service_safety_valve"));
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) GeneralClusterConfigs(com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs) BlueprintView(com.sequenceiq.cloudbreak.template.views.BlueprintView) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) Builder(com.sequenceiq.cloudbreak.template.TemplatePreparationObject.Builder) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 68 with Gateway

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

the class KnoxGatewayConfigProviderTest method testGetAdditionalServicesWhenKnoxRequestedAndBlueprintContainsIt.

@Test
public void testGetAdditionalServicesWhenKnoxRequestedAndBlueprintContainsIt() {
    HostgroupView master = new HostgroupView("master", 1, InstanceGroupType.GATEWAY, 1);
    HostgroupView worker = new HostgroupView("worker", 2, InstanceGroupType.CORE, 2);
    Gateway gateway = new Gateway();
    TemplatePreparationObject preparationObject = Builder.builder().withHostgroupViews(Set.of(master, worker)).withGateway(gateway, "key", new HashSet<>()).build();
    String inputJson = getBlueprintText("input/clouderamanager-knox.bp");
    CmTemplateProcessor cmTemplateProcessor = new CmTemplateProcessor(inputJson);
    Map<String, ApiClusterTemplateService> additionalServices = underTest.getAdditionalServices(cmTemplateProcessor, preparationObject);
    assertTrue(additionalServices.isEmpty());
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) CmTemplateProcessor(com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor) HostgroupView(com.sequenceiq.cloudbreak.template.views.HostgroupView) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 69 with Gateway

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

the class GatewayViewTest method gatewayEnabled.

public Gateway gatewayEnabled(GatewayTopology... gatewayTopology) {
    Gateway gateway = new Gateway();
    gateway.setPath("/path");
    gateway.setTopologies(Set.of(gatewayTopology));
    gateway.setSsoProvider("simple");
    gateway.setSsoType(SSOType.SSO_PROVIDER);
    gateway.setGatewayType(GatewayType.CENTRAL);
    gateway.setSignCert("signcert");
    gateway.setSignKey("signkey");
    gateway.setTokenCert("tokencert");
    gateway.setSignPub("signpub");
    return gateway;
}
Also used : Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway)

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