Search in sources :

Example 11 with TemplatePreparationObject

use of com.sequenceiq.cloudbreak.template.TemplatePreparationObject in project cloudbreak by hortonworks.

the class RangerCloudStorageServiceConfigProviderTest method testGetRangerAzureCloudStorageServiceConfigs.

@Test
public void testGetRangerAzureCloudStorageServiceConfigs() {
    CmTemplateProcessor templateProcessor = mock(CmTemplateProcessor.class);
    TemplatePreparationObject preparationObject = getTemplatePreparationObjectForAzure(true).withBlueprintView(mock(BlueprintView.class)).withCloudPlatform(CloudPlatform.AZURE).withProductDetails(new ClouderaManagerRepo().withVersion("7.2.2"), List.of()).build();
    List<ApiClusterTemplateConfig> serviceConfigs = underTest.getServiceConfigs(templateProcessor, preparationObject);
    assertEquals(2, serviceConfigs.size());
    assertEquals("ranger_plugin_hdfs_audit_url", serviceConfigs.get(0).getName());
    assertEquals("abfs://data@your-san.dfs.core.windows.net/ranger/audit", serviceConfigs.get(0).getValue());
    assertEquals("cloud_storage_paths", serviceConfigs.get(1).getName());
    assertEquals("HIVE_METASTORE_WAREHOUSE=abfs://data@your-san.dfs.core.windows.net/warehouse/tablespace/managed/hive," + "HIVE_REPLICA_WAREHOUSE=abfs://data@your-san.dfs.core.windows.net/hive_replica_functions_dir," + "HIVE_METASTORE_EXTERNAL_WAREHOUSE=abfs://data@your-san.dfs.core.windows.net/warehouse/tablespace/external/hive," + "RANGER_AUDIT=abfs://data@your-san.dfs.core.windows.net/ranger/audit," + "HBASE_ROOT=abfs://data@your-san.dfs.core.windows.net/hbase", serviceConfigs.get(1).getValue());
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) CmTemplateProcessor(com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig) Test(org.junit.jupiter.api.Test)

Example 12 with TemplatePreparationObject

use of com.sequenceiq.cloudbreak.template.TemplatePreparationObject in project cloudbreak by hortonworks.

the class RangerRoleConfigProviderTest method testGetRoleConfigsWithSingleRolesPerHostGroup.

@Test
public void testGetRoleConfigsWithSingleRolesPerHostGroup() {
    HostgroupView master = new HostgroupView("master", 1, InstanceGroupType.GATEWAY, 1);
    HostgroupView worker = new HostgroupView("worker", 2, InstanceGroupType.CORE, 2);
    String inputJson = getBlueprintText("input/clouderamanager-db-config.bp");
    CmTemplateProcessor cmTemplateProcessor = new CmTemplateProcessor(inputJson);
    TemplatePreparationObject preparationObject = Builder.builder().withHostgroupViews(Set.of(master, worker)).withBlueprintView(new BlueprintView(inputJson, "", "", cmTemplateProcessor)).withRdsConfigs(Set.of(rdsConfig(DatabaseType.RANGER))).withProductDetails(generateCmRepo(() -> "7.0.0"), null).build();
    Map<String, List<ApiClusterTemplateConfig>> roleConfigs = underTest.getRoleConfigs(cmTemplateProcessor, preparationObject);
    // Shall be only a single match, which is the Ranger one
    assertThat(roleConfigs.size()).isEqualTo(1);
    List<ApiClusterTemplateConfig> masterRangerAdmin = roleConfigs.get("ranger-RANGER_ADMIN-BASE");
    assertThat(masterRangerAdmin.size()).isEqualTo(5);
    assertThat(masterRangerAdmin.get(0).getName()).isEqualTo(RANGER_DATABASE_HOST);
    assertThat(masterRangerAdmin.get(0).getValue()).isEqualTo("10.1.1.1");
    assertThat(masterRangerAdmin.get(1).getName()).isEqualTo(RANGER_DATABASE_NAME);
    assertThat(masterRangerAdmin.get(1).getValue()).isEqualTo("ranger");
    assertThat(masterRangerAdmin.get(2).getName()).isEqualTo(RANGER_DATABASE_TYPE);
    assertThat(masterRangerAdmin.get(2).getValue()).isEqualTo("PostgreSQL");
    assertThat(masterRangerAdmin.get(3).getName()).isEqualTo(RANGER_DATABASE_USER);
    assertThat(masterRangerAdmin.get(3).getValue()).isEqualTo("heyitsme");
    assertThat(masterRangerAdmin.get(4).getName()).isEqualTo(RANGER_DATABASE_PASSWORD);
    assertThat(masterRangerAdmin.get(4).getValue()).isEqualTo("iamsoosecure");
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) BlueprintView(com.sequenceiq.cloudbreak.template.views.BlueprintView) List(java.util.List) CmTemplateProcessor(com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig) HostgroupView(com.sequenceiq.cloudbreak.template.views.HostgroupView) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 13 with TemplatePreparationObject

use of com.sequenceiq.cloudbreak.template.TemplatePreparationObject in project cloudbreak by hortonworks.

the class RangerRoleConfigProviderTest method testGetRangerAdminDefaultPolicyGroups.

@ParameterizedTest(name = "{0}")
@MethodSource("defaultPolicyGroupsDataProvider")
public void testGetRangerAdminDefaultPolicyGroups(String testCaseName, String cdhVersion, int expectedRoleConfigCount, int expectedSvcConfigCount) {
    HostgroupView master = new HostgroupView("master", 1, InstanceGroupType.GATEWAY, 1);
    HostgroupView worker = new HostgroupView("worker", 2, InstanceGroupType.CORE, 2);
    String inputJson = getBlueprintText("input/clouderamanager-db-config.bp");
    CmTemplateProcessor cmTemplateProcessor = new CmTemplateProcessor(inputJson);
    cmTemplateProcessor.setCdhVersion(cdhVersion);
    TemplatePreparationObject preparationObject = Builder.builder().withHostgroupViews(Set.of(master, worker)).withBlueprintView(new BlueprintView(inputJson, "", "", cmTemplateProcessor)).withRdsConfigs(Set.of(rdsConfig(DatabaseType.RANGER))).withVirtualGroupView(new VirtualGroupRequest(TestConstants.CRN, "")).withProductDetails(generateCmRepo(() -> cdhVersion), null).build();
    if (expectedRoleConfigCount == 6) {
        when(virtualGroupService.createOrGetVirtualGroup(preparationObject.getVirtualGroupRequest(), RANGER_ADMIN)).thenReturn(ADMIN_GROUP);
    }
    if ("7.6.0".equals(cdhVersion)) {
        when(virtualGroupService.createOrGetVirtualGroup(preparationObject.getVirtualGroupRequest(), RANGER_ADMIN)).thenReturn(ADMIN_GROUP);
        when(virtualGroupService.createOrGetVirtualGroup(preparationObject.getVirtualGroupRequest(), HBASE_ADMIN)).thenReturn(HBASE_ADMIN_GROUP);
    }
    Map<String, List<ApiClusterTemplateConfig>> roleConfigs = underTest.getRoleConfigs(cmTemplateProcessor, preparationObject);
    List<ApiClusterTemplateConfig> masterRangerAdmin = roleConfigs.get("ranger-RANGER_ADMIN-BASE");
    assertThat(masterRangerAdmin.size()).isEqualTo(expectedRoleConfigCount);
    List<ApiClusterTemplateConfig> serviceConfigs = underTest.getServiceConfigs(cmTemplateProcessor, preparationObject);
    assertThat(serviceConfigs.size()).isEqualTo(expectedSvcConfigCount);
    if (expectedRoleConfigCount == 6) {
        assertThat(masterRangerAdmin.get(5).getName()).isEqualTo(RANGER_DEFAULT_POLICY_GROUPS);
        assertThat(masterRangerAdmin.get(5).getValue()).isEqualTo(ADMIN_GROUP);
    }
    if ("7.6.0".equals(cdhVersion)) {
        assertThat(masterRangerAdmin.get(1).getName()).isEqualTo(RANGER_HBASE_ADMIN_VIRTUAL_GROUPS);
        assertThat(masterRangerAdmin.get(1).getValue()).isEqualTo(HBASE_ADMIN_GROUP);
    }
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) VirtualGroupRequest(com.sequenceiq.cloudbreak.auth.altus.VirtualGroupRequest) BlueprintView(com.sequenceiq.cloudbreak.template.views.BlueprintView) List(java.util.List) CmTemplateProcessor(com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig) HostgroupView(com.sequenceiq.cloudbreak.template.views.HostgroupView) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 14 with TemplatePreparationObject

use of com.sequenceiq.cloudbreak.template.TemplatePreparationObject in project cloudbreak by hortonworks.

the class RangerRazBaseConfigProviderTest method getServiceTypesConfigWheAGCPAnd729ShouldNOTAddProperty.

@Test
public void getServiceTypesConfigWheAGCPAnd729ShouldNOTAddProperty() {
    BlueprintTextProcessor blueprintTextProcessor = mock(BlueprintTextProcessor.class);
    when(blueprintTextProcessor.getVersion()).thenReturn(Optional.of("7.2.9"));
    TemplatePreparationObject preparationObject = TemplatePreparationObject.Builder.builder().withStackType(StackType.WORKLOAD).withBlueprintView(new BlueprintView("", "7.2.9", "CDH", blueprintTextProcessor)).withCloudPlatform(CloudPlatform.GCP).withGeneralClusterConfigs(new GeneralClusterConfigs()).withDataLakeView(new DatalakeView(false)).build();
    List<ApiClusterTemplateConfig> roleConfigs = underTest.getRoleConfigs("", preparationObject);
    assertEquals(0, roleConfigs.size());
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) GeneralClusterConfigs(com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs) BlueprintTextProcessor(com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor) BlueprintView(com.sequenceiq.cloudbreak.template.views.BlueprintView) DatalakeView(com.sequenceiq.cloudbreak.template.views.DatalakeView) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig) Test(org.junit.jupiter.api.Test)

Example 15 with TemplatePreparationObject

use of com.sequenceiq.cloudbreak.template.TemplatePreparationObject in project cloudbreak by hortonworks.

the class RangerRazBaseConfigProviderTest method getServiceTypesConfigWheAWSAnd7210ShouldAddProperty.

@Test
public void getServiceTypesConfigWheAWSAnd7210ShouldAddProperty() {
    BlueprintTextProcessor blueprintTextProcessor = mock(BlueprintTextProcessor.class);
    when(blueprintTextProcessor.getVersion()).thenReturn(Optional.of("7.2.10"));
    TemplatePreparationObject preparationObject = TemplatePreparationObject.Builder.builder().withStackType(StackType.WORKLOAD).withBlueprintView(new BlueprintView("", "7.2.10", "CDH", blueprintTextProcessor)).withCloudPlatform(CloudPlatform.AWS).withGeneralClusterConfigs(new GeneralClusterConfigs()).withDataLakeView(new DatalakeView(false)).build();
    List<ApiClusterTemplateConfig> roleConfigs = underTest.getRoleConfigs("", preparationObject);
    assertEquals(1, roleConfigs.size());
    assertEquals("<property><name>ranger.raz.bootstrap.servicetypes</name><value>s3</value></property>", roleConfigs.get(0).getValue());
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) GeneralClusterConfigs(com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs) BlueprintTextProcessor(com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor) BlueprintView(com.sequenceiq.cloudbreak.template.views.BlueprintView) DatalakeView(com.sequenceiq.cloudbreak.template.views.DatalakeView) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig) Test(org.junit.jupiter.api.Test)

Aggregations

TemplatePreparationObject (com.sequenceiq.cloudbreak.template.TemplatePreparationObject)266 Test (org.junit.Test)133 ApiClusterTemplateConfig (com.cloudera.api.swagger.model.ApiClusterTemplateConfig)127 CmTemplateProcessor (com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor)116 Test (org.junit.jupiter.api.Test)87 GeneralClusterConfigs (com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs)53 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)48 List (java.util.List)45 ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)40 HostgroupView (com.sequenceiq.cloudbreak.template.views.HostgroupView)38 Builder (com.sequenceiq.cloudbreak.template.TemplatePreparationObject.Builder)36 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)35 ArrayList (java.util.ArrayList)34 BlueprintView (com.sequenceiq.cloudbreak.template.views.BlueprintView)32 ApiClusterTemplateService (com.cloudera.api.swagger.model.ApiClusterTemplateService)27 MethodSource (org.junit.jupiter.params.provider.MethodSource)23 BaseFileSystemConfigurationsView (com.sequenceiq.cloudbreak.template.filesystem.BaseFileSystemConfigurationsView)20 AccountMappingView (com.sequenceiq.cloudbreak.template.views.AccountMappingView)17 RDSConfig (com.sequenceiq.cloudbreak.domain.RDSConfig)16 DisplayName (org.junit.jupiter.api.DisplayName)16