Search in sources :

Example 1 with ApiClusterTemplateRoleConfigGroup

use of com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup 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 2 with ApiClusterTemplateRoleConfigGroup

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

the class RangerRazDatahubConfigProviderTest method getAdditionalServicesWhenRazIsEnabledWithCm722.

@ParameterizedTest(name = "{0}")
@MethodSource("razCloudPlatformDataProvider")
@DisplayName("CM 7.2.2 DH is used and Raz is requested, Raz service needs to be added to the template")
void getAdditionalServicesWhenRazIsEnabledWithCm722(String testCaseName, CloudPlatform cloudPlatform) {
    ClouderaManagerRepo cmRepo = new ClouderaManagerRepo();
    cmRepo.setVersion("7.2.2");
    GeneralClusterConfigs generalClusterConfigs = new GeneralClusterConfigs();
    HostgroupView master = new HostgroupView("master", 0, InstanceGroupType.GATEWAY, List.of());
    HostgroupView worker = new HostgroupView("worker", 0, InstanceGroupType.CORE, List.of());
    TemplatePreparationObject preparationObject = Builder.builder().withStackType(StackType.WORKLOAD).withCloudPlatform(cloudPlatform).withProductDetails(cmRepo, List.of()).withDataLakeView(new DatalakeView(true)).withGeneralClusterConfigs(generalClusterConfigs).withHostgroupViews(Set.of(master, worker)).build();
    Map<String, ApiClusterTemplateService> additionalServices = configProvider.getAdditionalServices(cmTemplateProcessor, preparationObject);
    ApiClusterTemplateService service = additionalServices.get("master");
    List<ApiClusterTemplateRoleConfigGroup> roleConfigGroups = service.getRoleConfigGroups();
    Assertions.assertAll(() -> assertEquals(1, additionalServices.size()), () -> assertEquals("RANGER_RAZ", service.getServiceType()), () -> assertEquals("ranger-RANGER_RAZ", service.getRefName()), () -> assertEquals("RANGER_RAZ_SERVER", roleConfigGroups.get(0).getRoleType()), () -> assertEquals("ranger-RANGER_RAZ_SERVER", roleConfigGroups.get(0).getRefName()));
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) GeneralClusterConfigs(com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs) ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) DatalakeView(com.sequenceiq.cloudbreak.template.views.DatalakeView) ApiClusterTemplateRoleConfigGroup(com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup) HostgroupView(com.sequenceiq.cloudbreak.template.views.HostgroupView) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource) DisplayName(org.junit.jupiter.api.DisplayName)

Example 3 with ApiClusterTemplateRoleConfigGroup

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

the class CmTemplateProcessorTest method testExtendTemplateWithAdditionalServicesWithKnoxServiceAndMultipleGateway.

@Test
public void testExtendTemplateWithAdditionalServicesWithKnoxServiceAndMultipleGateway() {
    underTest = new CmTemplateProcessor(getBlueprintText("input/clouderamanager-multi-gateway.bp"));
    ApiClusterTemplateService knox = new ApiClusterTemplateService().serviceType("KNOX").refName("knox");
    ApiClusterTemplateRoleConfigGroup knoxGateway = new ApiClusterTemplateRoleConfigGroup().roleType("KNOX_GATEWAY").base(true).refName("knox-KNOX_GATEWAY-BASE");
    knox.roleConfigGroups(List.of(knoxGateway));
    underTest.extendTemplateWithAdditionalServices(Map.of("master", knox, "master2", knox));
    String actualTemplate = templateToString(underTest.getTemplate());
    CmTemplateProcessor expectedProcessor = new CmTemplateProcessor(getBlueprintText("input/clouderamanager-knox-multi-gateway.bp"));
    String expectedTemplate = templateToString(expectedProcessor.getTemplate());
    assertEquals(expectedTemplate, actualTemplate);
}
Also used : ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) ApiClusterTemplateRoleConfigGroup(com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup) Test(org.junit.jupiter.api.Test)

Example 4 with ApiClusterTemplateRoleConfigGroup

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

the class CmTemplateProcessorTest method testExtendTemplateWithAdditionalServicesWithKnoxService.

@Test
public void testExtendTemplateWithAdditionalServicesWithKnoxService() {
    underTest = new CmTemplateProcessor(getBlueprintText("input/clouderamanager.bp"));
    ApiClusterTemplateService knox = new ApiClusterTemplateService().serviceType("KNOX").refName("knox");
    ApiClusterTemplateRoleConfigGroup knoxGateway = new ApiClusterTemplateRoleConfigGroup().roleType("KNOX_GATEWAY").base(true).refName("knox-KNOX_GATEWAY-BASE");
    knox.roleConfigGroups(List.of(knoxGateway));
    underTest.extendTemplateWithAdditionalServices(Map.of("master", knox));
    String actualTemplate = templateToString(underTest.getTemplate());
    CmTemplateProcessor expectedProcessor = new CmTemplateProcessor(getBlueprintText("input/clouderamanager-knox.bp"));
    String expectedTemplate = templateToString(expectedProcessor.getTemplate());
    assertEquals(expectedTemplate, actualTemplate);
}
Also used : ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) ApiClusterTemplateRoleConfigGroup(com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup) Test(org.junit.jupiter.api.Test)

Example 5 with ApiClusterTemplateRoleConfigGroup

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

the class CmTemplateProcessorTest method testAddRoleConfigs.

@Test
public void testAddRoleConfigs() {
    underTest = new CmTemplateProcessor(getBlueprintText("input/clouderamanager.bp"));
    Map<String, List<ApiClusterTemplateConfig>> configs = new HashMap<>();
    configs.put("hdfs-NAMENODE-BASE", List.of(new ApiClusterTemplateConfig().name("dfs_name_dir_list").variable("master_NAMENODE")));
    configs.put("hdfs-DATANODE-BASE", List.of(new ApiClusterTemplateConfig().name("dfs_data_dir_list").variable("worker_DATANODE")));
    underTest.addRoleConfigs("HDFS", configs);
    ApiClusterTemplateService service = underTest.getTemplate().getServices().stream().filter(srv -> "HDFS".equals(srv.getServiceType())).findAny().get();
    ApiClusterTemplateRoleConfigGroup dn = service.getRoleConfigGroups().stream().filter(rcg -> "DATANODE".equals(rcg.getRoleType())).findAny().get();
    List<ApiClusterTemplateConfig> dnConfigs = dn.getConfigs();
    ApiClusterTemplateRoleConfigGroup nn = service.getRoleConfigGroups().stream().filter(rcg -> "NAMENODE".equals(rcg.getRoleType())).findAny().get();
    List<ApiClusterTemplateConfig> nnConfigs = nn.getConfigs();
    assertEquals(1, nnConfigs.size());
    assertEquals(1, dnConfigs.size());
    assertEquals("dfs_name_dir_list", nnConfigs.get(0).getName());
    assertEquals("dfs_data_dir_list", dnConfigs.get(0).getName());
}
Also used : HashMap(java.util.HashMap) ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) ApiClusterTemplateRoleConfigGroup(com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup) ArrayList(java.util.ArrayList) List(java.util.List) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig) Test(org.junit.jupiter.api.Test)

Aggregations

ApiClusterTemplateRoleConfigGroup (com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup)25 ApiClusterTemplateService (com.cloudera.api.swagger.model.ApiClusterTemplateService)22 ApiClusterTemplateConfig (com.cloudera.api.swagger.model.ApiClusterTemplateConfig)11 ArrayList (java.util.ArrayList)11 List (java.util.List)11 HashMap (java.util.HashMap)10 TemplatePreparationObject (com.sequenceiq.cloudbreak.template.TemplatePreparationObject)9 Test (org.junit.jupiter.api.Test)8 ApiClusterTemplate (com.cloudera.api.swagger.model.ApiClusterTemplate)5 ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)5 CustomConfigurationPropertyView (com.sequenceiq.cloudbreak.template.views.CustomConfigurationPropertyView)5 HashSet (java.util.HashSet)5 Map (java.util.Map)5 Optional (java.util.Optional)5 ApiClusterTemplateHostTemplate (com.cloudera.api.swagger.model.ApiClusterTemplateHostTemplate)4 ApiClusterTemplateInstantiator (com.cloudera.api.swagger.model.ApiClusterTemplateInstantiator)4 ApiClusterTemplateRoleConfigGroupInfo (com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroupInfo)4 JsonUtil (com.sequenceiq.cloudbreak.common.json.JsonUtil)4 ApiClusterTemplateHostInfo (com.cloudera.api.swagger.model.ApiClusterTemplateHostInfo)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)3