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")));
}
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());
}
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);
}
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));
}
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>"));
}
Aggregations