Search in sources :

Example 1 with ApiClusterTemplateVariable

use of com.cloudera.api.swagger.model.ApiClusterTemplateVariable in project cloudbreak by hortonworks.

the class HueConfigProviderTest method getProxyHostsWhenLoadBalancerConfigured.

@Test
public void getProxyHostsWhenLoadBalancerConfigured() {
    BlueprintView blueprintView = getMockBlueprintView("7.0.1", "7.0.1");
    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 expectedLBFQDN = "loadbalancer-gateway.cloudera.site";
    GeneralClusterConfigs generalClusterConfigs = new GeneralClusterConfigs();
    generalClusterConfigs.setExternalFQDN(expectedExternalFQDN);
    generalClusterConfigs.setKnoxUserFacingCertConfigured(true);
    generalClusterConfigs.setPrimaryGatewayInstanceDiscoveryFQDN(Optional.empty());
    generalClusterConfigs.setLoadBalancerGatewayFqdn(Optional.of(expectedLBFQDN));
    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(",", expectedExternalFQDN, expectedLBFQDN);
    String proxyHostsExpected2 = String.join(",", expectedLBFQDN, expectedExternalFQDN);
    String expectedSafetyValveValue1 = "[desktop]\n[[knox]]\nknox_proxyhosts=".concat(proxyHostsExpected1);
    String expectedSafetyValveValue2 = "[desktop]\n[[knox]]\nknox_proxyhosts=".concat(proxyHostsExpected2);
    assertThat(paramToVariable).containsAnyOf(new SimpleEntry<>("hue-hue_service_safety_valve", expectedSafetyValveValue1), new SimpleEntry<>("hue-hue_service_safety_valve", expectedSafetyValveValue2));
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) GeneralClusterConfigs(com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs) BlueprintView(com.sequenceiq.cloudbreak.template.views.BlueprintView) RDSConfig(com.sequenceiq.cloudbreak.domain.RDSConfig) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) Builder(com.sequenceiq.cloudbreak.template.TemplatePreparationObject.Builder) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ApiClusterTemplateVariable(com.cloudera.api.swagger.model.ApiClusterTemplateVariable) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 2 with ApiClusterTemplateVariable

use of com.cloudera.api.swagger.model.ApiClusterTemplateVariable in project cloudbreak by hortonworks.

the class HueConfigProviderTest method getServiceConfigVariables.

@Test
public void getServiceConfigVariables() {
    BlueprintView blueprintView = getMockBlueprintView("7.2.0", "7.1.0");
    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);
    TemplatePreparationObject tpo = new Builder().withRdsConfigs(Set.of(rdsConfig)).withBlueprintView(blueprintView).build();
    List<ApiClusterTemplateVariable> result = underTest.getServiceConfigVariables(tpo);
    Map<String, String> paramToVariable = result.stream().collect(Collectors.toMap(ApiClusterTemplateVariable::getName, ApiClusterTemplateVariable::getValue));
    assertThat(paramToVariable).containsOnly(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));
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) 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) ApiClusterTemplateVariable(com.cloudera.api.swagger.model.ApiClusterTemplateVariable) Test(org.junit.Test)

Example 3 with ApiClusterTemplateVariable

use of com.cloudera.api.swagger.model.ApiClusterTemplateVariable in project cloudbreak by hortonworks.

the class HueConfigProviderTest method getServiceConfigVariablesWhenKnoxConfiguredToExternalDomain.

@Test
public void getServiceConfigVariablesWhenKnoxConfiguredToExternalDomain() {
    BlueprintView blueprintView = getMockBlueprintView("7.0.1", "7.0.1");
    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);
    String expectedSafetyValveValue1 = "[desktop]\n[[knox]]\nknox_proxyhosts=".concat(proxyHostsExpected1);
    String expectedSafetyValveValue2 = "[desktop]\n[[knox]]\nknox_proxyhosts=".concat(proxyHostsExpected2);
    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-hue_service_safety_valve", expectedSafetyValveValue1), new SimpleEntry<>("hue-hue_service_safety_valve", expectedSafetyValveValue2));
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) GeneralClusterConfigs(com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs) BlueprintView(com.sequenceiq.cloudbreak.template.views.BlueprintView) RDSConfig(com.sequenceiq.cloudbreak.domain.RDSConfig) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) Builder(com.sequenceiq.cloudbreak.template.TemplatePreparationObject.Builder) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ApiClusterTemplateVariable(com.cloudera.api.swagger.model.ApiClusterTemplateVariable) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 4 with ApiClusterTemplateVariable

use of com.cloudera.api.swagger.model.ApiClusterTemplateVariable in project cloudbreak by hortonworks.

the class HueConfigProviderTest method getProxyHostsWhenLoadBalancerConfiguredPost710.

@Test
public void getProxyHostsWhenLoadBalancerConfiguredPost710() {
    BlueprintView blueprintView = getMockBlueprintView("7.2.0", "7.1.0");
    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 expectedLBFQDN = "loadbalancer-gateway.cloudera.site";
    GeneralClusterConfigs generalClusterConfigs = new GeneralClusterConfigs();
    generalClusterConfigs.setExternalFQDN(expectedExternalFQDN);
    generalClusterConfigs.setKnoxUserFacingCertConfigured(true);
    generalClusterConfigs.setPrimaryGatewayInstanceDiscoveryFQDN(Optional.empty());
    generalClusterConfigs.setLoadBalancerGatewayFqdn(Optional.of(expectedLBFQDN));
    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(",", expectedExternalFQDN, expectedLBFQDN);
    String proxyHostsExpected2 = String.join(",", expectedLBFQDN, expectedExternalFQDN);
    assertThat(paramToVariable).containsAnyOf(new SimpleEntry<>("hue-knox_proxyhosts", proxyHostsExpected1), new SimpleEntry<>("hue-knox_proxyhosts", proxyHostsExpected2));
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) GeneralClusterConfigs(com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs) BlueprintView(com.sequenceiq.cloudbreak.template.views.BlueprintView) RDSConfig(com.sequenceiq.cloudbreak.domain.RDSConfig) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) Builder(com.sequenceiq.cloudbreak.template.TemplatePreparationObject.Builder) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ApiClusterTemplateVariable(com.cloudera.api.swagger.model.ApiClusterTemplateVariable) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 5 with ApiClusterTemplateVariable

use of com.cloudera.api.swagger.model.ApiClusterTemplateVariable 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)

Aggregations

ApiClusterTemplateVariable (com.cloudera.api.swagger.model.ApiClusterTemplateVariable)7 RDSConfig (com.sequenceiq.cloudbreak.domain.RDSConfig)5 TemplatePreparationObject (com.sequenceiq.cloudbreak.template.TemplatePreparationObject)5 Builder (com.sequenceiq.cloudbreak.template.TemplatePreparationObject.Builder)5 GeneralClusterConfigs (com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs)5 BlueprintView (com.sequenceiq.cloudbreak.template.views.BlueprintView)5 HashSet (java.util.HashSet)5 Test (org.junit.Test)5 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)5 Gateway (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway)4 CmTemplateProcessor (com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor)1 GatewayView (com.sequenceiq.cloudbreak.template.views.GatewayView)1 RdsView (com.sequenceiq.cloudbreak.template.views.RdsView)1 ArrayList (java.util.ArrayList)1