Search in sources :

Example 51 with ApiClusterTemplateConfig

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

the class CmHostGroupRoleConfigProviderProcessorTest method retainsExistingConfigsInEachClone.

@Test
public void retainsExistingConfigsInEachClone() {
    HostgroupView master = new HostgroupView("master", 1, InstanceGroupType.GATEWAY, 1);
    HostgroupView worker = new HostgroupView("worker", 2, InstanceGroupType.CORE, 2);
    HostgroupView compute = new HostgroupView("compute", 3, InstanceGroupType.CORE, 2);
    setup("input/clouderamanager-3hg-same-DN-role.bp", Builder.builder().withHostgroupViews(Set.of(master, worker, compute)));
    ApiClusterTemplateConfig existingConfig = config("existing_config", "some_Value");
    templateProcessor.getServiceByType("HDFS").ifPresent(service -> service.getRoleConfigGroups().stream().filter(rcg -> "hdfs-DATANODE-BASE".equals(rcg.getRefName())).forEach(rcg -> rcg.addConfigsItem(existingConfig)));
    underTest.process(templateProcessor, templatePreparator);
    Map<String, List<ApiClusterTemplateConfig>> roleConfigs = mapRoleConfigs();
    assertNull(roleConfigs.get("hdfs-DATANODE-BASE"));
    assertEquals(Set.of(existingConfig, config("dfs_data_dir_list", "/hadoopfs/fs1/datanode,/hadoopfs/fs2/datanode")), Set.copyOf(roleConfigs.get("hdfs-DATANODE-worker")));
    assertEquals(Set.of(existingConfig, config("dfs_data_dir_list", "/hadoopfs/fs1/datanode,/hadoopfs/fs2/datanode,/hadoopfs/fs3/datanode")), Set.copyOf(roleConfigs.get("hdfs-DATANODE-compute")));
}
Also used : Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) GeneralClusterConfigs(com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs) HbaseVolumeConfigProvider(com.sequenceiq.cloudbreak.cmtemplate.configproviders.hbase.HbaseVolumeConfigProvider) ConfigUtils.config(com.sequenceiq.cloudbreak.cmtemplate.configproviders.ConfigUtils.config) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) Builder(com.sequenceiq.cloudbreak.template.TemplatePreparationObject.Builder) ArrayList(java.util.ArrayList) VolumeTemplate(com.sequenceiq.cloudbreak.domain.VolumeTemplate) BlueprintView(com.sequenceiq.cloudbreak.template.views.BlueprintView) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) Map(java.util.Map) Spy(org.mockito.Spy) ApiClusterTemplateRoleConfigGroup(com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup) FileReaderUtils(com.sequenceiq.cloudbreak.util.FileReaderUtils) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) YarnVolumeConfigProvider(com.sequenceiq.cloudbreak.cmtemplate.configproviders.yarn.YarnVolumeConfigProvider) InjectMocks(org.mockito.InjectMocks) MockitoExtension(org.mockito.junit.jupiter.MockitoExtension) ZooKeeperVolumeConfigProvider(com.sequenceiq.cloudbreak.cmtemplate.configproviders.zookeeper.ZooKeeperVolumeConfigProvider) Optional.ofNullable(java.util.Optional.ofNullable) Set(java.util.Set) Collectors(java.util.stream.Collectors) TemporaryStorage(com.sequenceiq.cloudbreak.common.type.TemporaryStorage) TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) Sets(com.google.common.collect.Sets) InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) Objects(java.util.Objects) Test(org.junit.jupiter.api.Test) HostgroupView(com.sequenceiq.cloudbreak.template.views.HostgroupView) List(java.util.List) HdfsVolumeConfigProvider(com.sequenceiq.cloudbreak.cmtemplate.configproviders.hdfs.HdfsVolumeConfigProvider) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig) Collections(java.util.Collections) ArrayList(java.util.ArrayList) List(java.util.List) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig) HostgroupView(com.sequenceiq.cloudbreak.template.views.HostgroupView) Test(org.junit.jupiter.api.Test)

Example 52 with ApiClusterTemplateConfig

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

Example 53 with ApiClusterTemplateConfig

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

the class CmTemplateProcessorTest method testAddRoleConfigsWithNoMatchinRefName.

@Test
public void testAddRoleConfigsWithNoMatchinRefName() {
    underTest = new CmTemplateProcessor(getBlueprintText("input/clouderamanager.bp"));
    Map<String, List<ApiClusterTemplateConfig>> configs = new HashMap<>();
    configs.put("hdfs-NAMENODE-nomatch", List.of(new ApiClusterTemplateConfig().name("dfs_name_dir_list").variable("master_NAMENODE")));
    configs.put("hdfs-DATANODE-nomatch", 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();
    assertNull(nnConfigs);
    assertNull(dnConfigs);
}
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)

Example 54 with ApiClusterTemplateConfig

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

the class CmTemplateProcessorTest method testIfCustomServiceConfigsMapIsRetrievedCorrectly.

@Test
void testIfCustomServiceConfigsMapIsRetrievedCorrectly() {
    underTest = new CmTemplateProcessor(getBlueprintText("input/de-ha.bp"));
    Map<String, List<ApiClusterTemplateConfig>> expectedMap = new HashMap<>();
    Set<CustomConfigurationPropertyView> configs = Set.of(new CustomConfigurationPropertyView("property1", "value1", null, "service1"), new CustomConfigurationPropertyView("property2", "value2", "role1", "service2"), new CustomConfigurationPropertyView("property3", "value3", null, "service3"));
    expectedMap.put("service1", List.of(new ApiClusterTemplateConfig().name("property1").value("value1")));
    expectedMap.put("service3", List.of(new ApiClusterTemplateConfig().name("property3").value("value3")));
    assertEquals(expectedMap, underTest.getCustomServiceConfigsMap(configs));
}
Also used : HashMap(java.util.HashMap) CustomConfigurationPropertyView(com.sequenceiq.cloudbreak.template.views.CustomConfigurationPropertyView) ArrayList(java.util.ArrayList) List(java.util.List) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig) Test(org.junit.jupiter.api.Test)

Example 55 with ApiClusterTemplateConfig

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

the class CmTemplateProcessorTest method testIfCustomServiceConfigsAreMerged.

@Test
public void testIfCustomServiceConfigsAreMerged() {
    underTest = new CmTemplateProcessor(getBlueprintText("input/de-ha.bp"));
    // config not present in template
    List<ApiClusterTemplateConfig> sparkConfigs = List.of(new ApiClusterTemplateConfig().name("spark_drive_log_persist_to_dfs").value("false"));
    // config present in template
    List<ApiClusterTemplateConfig> hiveConfigs = List.of(new ApiClusterTemplateConfig().name("tez_auto_reducer_parallelism").value("true"), new ApiClusterTemplateConfig().name("hive_service_config_safety_valve").value("<property><name>hive_server2_tez_session_lifetime</name><value>30m</value></property>"));
    ApiClusterTemplateService spark = underTest.getTemplate().getServices().stream().filter(service -> "SPARK_ON_YARN".equals(service.getServiceType())).findFirst().get();
    ApiClusterTemplateService hive = underTest.getTemplate().getServices().stream().filter(service -> "HIVE_ON_TEZ".equals(service.getServiceType())).findFirst().get();
    List<ApiClusterTemplateConfig> existingSparkConfigs = spark.getServiceConfigs();
    List<ApiClusterTemplateConfig> existingHiveConfigs = hive.getServiceConfigs();
    underTest.mergeCustomServiceConfigs(spark, sparkConfigs);
    underTest.mergeCustomServiceConfigs(hive, hiveConfigs);
    assertEquals(spark.getServiceConfigs().size(), (existingSparkConfigs == null ? 0 : existingSparkConfigs.size()) + sparkConfigs.size());
    assertEquals(hive.getServiceConfigs().size(), existingHiveConfigs.size());
    assertTrue(existingHiveConfigs.get(2).getValue().endsWith("<property><name>hive_server2_tez_session_lifetime</name><value>30m</value></property>"));
}
Also used : ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig) Test(org.junit.jupiter.api.Test)

Aggregations

ApiClusterTemplateConfig (com.cloudera.api.swagger.model.ApiClusterTemplateConfig)172 TemplatePreparationObject (com.sequenceiq.cloudbreak.template.TemplatePreparationObject)129 Test (org.junit.Test)78 CmTemplateProcessor (com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor)74 Test (org.junit.jupiter.api.Test)57 ArrayList (java.util.ArrayList)55 List (java.util.List)50 HostgroupView (com.sequenceiq.cloudbreak.template.views.HostgroupView)25 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)22 Builder (com.sequenceiq.cloudbreak.template.TemplatePreparationObject.Builder)21 ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)18 GeneralClusterConfigs (com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs)17 BlueprintView (com.sequenceiq.cloudbreak.template.views.BlueprintView)17 ApiClusterTemplateService (com.cloudera.api.swagger.model.ApiClusterTemplateService)13 AccountMappingView (com.sequenceiq.cloudbreak.template.views.AccountMappingView)13 ApiClusterTemplateRoleConfigGroup (com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup)12 HashMap (java.util.HashMap)12 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)11 BaseFileSystemConfigurationsView (com.sequenceiq.cloudbreak.template.filesystem.BaseFileSystemConfigurationsView)9 BlueprintTextProcessor (com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor)8