Search in sources :

Example 21 with CmTemplateProcessor

use of com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor 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 22 with CmTemplateProcessor

use of com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor 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 23 with CmTemplateProcessor

use of com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor in project cloudbreak by hortonworks.

the class KnoxGatewayConfigProviderTest method testGetAdditionalServicesWhenKnoxRequestedAndBlueprintDoesNoContainKnox.

@Test
public void testGetAdditionalServicesWhenKnoxRequestedAndBlueprintDoesNoContainKnox() {
    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.bp");
    CmTemplateProcessor cmTemplateProcessor = new CmTemplateProcessor(inputJson);
    Map<String, ApiClusterTemplateService> additionalServices = underTest.getAdditionalServices(cmTemplateProcessor, preparationObject);
    ApiClusterTemplateService knox = additionalServices.get("master");
    assertEquals(1, additionalServices.size());
    assertNotNull(knox);
    assertEquals("KNOX", knox.getServiceType());
    assertEquals("knox", knox.getRefName());
    ApiClusterTemplateRoleConfigGroup roleConfigGroup = knox.getRoleConfigGroups().get(0);
    assertEquals("KNOX_GATEWAY", roleConfigGroup.getRoleType());
    assertTrue(roleConfigGroup.getBase());
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) ApiClusterTemplateRoleConfigGroup(com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup) 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 24 with CmTemplateProcessor

use of com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor in project cloudbreak by hortonworks.

the class KnoxGatewayConfigProviderTest method testGetAdditionalServicesWhenNoKnoxRequested.

@Test
public void testGetAdditionalServicesWhenNoKnoxRequested() {
    HostgroupView master = new HostgroupView("master", 1, InstanceGroupType.GATEWAY, 1);
    HostgroupView worker = new HostgroupView("worker", 2, InstanceGroupType.CORE, 2);
    TemplatePreparationObject preparationObject = Builder.builder().withHostgroupViews(Set.of(master, worker)).build();
    String inputJson = getBlueprintText("input/clouderamanager.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) 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) Test(org.junit.Test)

Example 25 with CmTemplateProcessor

use of com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor in project cloudbreak by hortonworks.

the class NifiRegistryRoleConfigProviderTest method testGetSchemaRegistryRoleConfigs720.

@Test
public void testGetSchemaRegistryRoleConfigs720() {
    String inputJson = loadBlueprint("7.2.0");
    CmTemplateProcessor cmTemplateProcessor = new CmTemplateProcessor(inputJson);
    TemplatePreparationObject preparationObject = getTemplatePreparationObject(cmTemplateProcessor);
    List<ApiClusterTemplateConfig> roleConfigs = underTest.getRoleConfigs(NifiRegistryRoles.NIFI_REGISTRY_SERVER, preparationObject);
    assertThat(roleConfigs).hasSameElementsAs(List.of(config("nifi.registry.db.url", "jdbc:postgresql://testhost:5432/nifi_registry"), config("nifi.registry.db.username", "nifi_registry_server_user"), config("nifi.registry.db.password", "nifi_registry_server_password"), config("nifi.registry.db.driver.class", "org.postgresql.Driver"), config("nifi.registry.db.driver.directory", "/usr/share/java/")));
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) CmTemplateProcessor(com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig) Test(org.junit.Test)

Aggregations

CmTemplateProcessor (com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor)149 TemplatePreparationObject (com.sequenceiq.cloudbreak.template.TemplatePreparationObject)115 Test (org.junit.Test)84 ApiClusterTemplateConfig (com.cloudera.api.swagger.model.ApiClusterTemplateConfig)75 List (java.util.List)46 ArrayList (java.util.ArrayList)33 Test (org.junit.jupiter.api.Test)19 HostgroupView (com.sequenceiq.cloudbreak.template.views.HostgroupView)18 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)15 BlueprintView (com.sequenceiq.cloudbreak.template.views.BlueprintView)13 HashSet (java.util.HashSet)12 ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)10 Builder (com.sequenceiq.cloudbreak.template.TemplatePreparationObject.Builder)10 Set (java.util.Set)10 ApiClusterTemplateService (com.cloudera.api.swagger.model.ApiClusterTemplateService)9 RDSConfig (com.sequenceiq.cloudbreak.domain.RDSConfig)8 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)8 Map (java.util.Map)8 BaseFileSystemConfigurationsView (com.sequenceiq.cloudbreak.template.filesystem.BaseFileSystemConfigurationsView)7 Collectors (java.util.stream.Collectors)7