Search in sources :

Example 1 with ApiClusterTemplateHostInfo

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

the class CmTemplateProcessorTest method verifyHostInfo.

private void verifyHostInfo(List<ApiClusterTemplateHostInfo> hosts, String hostTemplateRefNameExpected, String hostNameExpected, String rackIdExpected) {
    Optional<ApiClusterTemplateHostInfo> hostInfoOptional = hosts.stream().filter(h -> h.getHostName().equals(hostNameExpected)).findFirst();
    assertThat(hostInfoOptional).isNotEmpty();
    ApiClusterTemplateHostInfo hostInfo = hostInfoOptional.get();
    assertThat(hostInfo).isNotNull();
    assertThat(hostInfo.getHostTemplateRefName()).isEqualTo(hostTemplateRefNameExpected);
    assertThat(hostInfo.getRackId()).isEqualTo(rackIdExpected);
}
Also used : InstanceCount(com.sequenceiq.cloudbreak.cloud.model.InstanceCount) GeneralClusterConfigs(com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) HashMap(java.util.HashMap) JsonUtil(com.sequenceiq.cloudbreak.common.json.JsonUtil) ServiceAttributes(com.sequenceiq.cloudbreak.template.model.ServiceAttributes) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) Map(java.util.Map) ApiClusterTemplateRoleConfigGroup(com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup) ApiClusterTemplateInstantiator(com.cloudera.api.swagger.model.ApiClusterTemplateInstantiator) FileReaderUtils(com.sequenceiq.cloudbreak.util.FileReaderUtils) ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) Map.entry(java.util.Map.entry) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) GatewayRecommendation(com.sequenceiq.cloudbreak.cloud.model.GatewayRecommendation) YarnRoles(com.sequenceiq.cloudbreak.cmtemplate.configproviders.yarn.YarnRoles) ApiClusterTemplateRoleConfigGroupInfo(com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroupInfo) ApiClusterTemplate(com.cloudera.api.swagger.model.ApiClusterTemplate) CustomConfigurationPropertyView(com.sequenceiq.cloudbreak.template.views.CustomConfigurationPropertyView) ClusterHostAttributes(com.sequenceiq.cloudbreak.cluster.model.ClusterHostAttributes) AutoscaleRecommendation(com.sequenceiq.cloudbreak.cloud.model.AutoscaleRecommendation) Versioned(com.sequenceiq.cloudbreak.common.type.Versioned) ConfigUtils.configVar(com.sequenceiq.cloudbreak.cmtemplate.configproviders.ConfigUtils.configVar) Set(java.util.Set) Collectors(java.util.stream.Collectors) ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) Test(org.junit.jupiter.api.Test) ServiceComponent(com.sequenceiq.cloudbreak.template.model.ServiceComponent) List(java.util.List) YarnConstants(com.sequenceiq.cloudbreak.cmtemplate.configproviders.yarn.YarnConstants) TreeMap(java.util.TreeMap) ApiClusterTemplateHostInfo(com.cloudera.api.swagger.model.ApiClusterTemplateHostInfo) ResizeRecommendation(com.sequenceiq.cloudbreak.cloud.model.ResizeRecommendation) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig) Optional(java.util.Optional) ApiClusterTemplateHostInfo(com.cloudera.api.swagger.model.ApiClusterTemplateHostInfo)

Example 2 with ApiClusterTemplateHostInfo

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

the class CmTemplateProcessorTest method addHostsTest.

@Test
void addHostsTest() {
    Map<String, List<Map<String, String>>> hostGroupMappings = Map.ofEntries(entry("hostGroup1", List.of()), entry("hostGroup2", List.of(hostAttributes("host2_1", false, null), hostAttributes("host2_2", true, null))), entry("hostGroup3", List.of(hostAttributes("host3_1", true, ""), hostAttributes("host3_2", true, "/rack3_2"))));
    underTest = new CmTemplateProcessor(getBlueprintText("input/clouderamanager.bp"));
    ApiClusterTemplate template = underTest.getTemplate();
    ApiClusterTemplateInstantiator instantiator = new ApiClusterTemplateInstantiator();
    template.setInstantiator(instantiator);
    underTest.addHosts(hostGroupMappings);
    List<ApiClusterTemplateHostInfo> hosts = instantiator.getHosts();
    assertThat(hosts).hasSize(4);
    verifyHostInfo(hosts, "hostGroup2", "host2_1", null);
    verifyHostInfo(hosts, "hostGroup2", "host2_2", null);
    verifyHostInfo(hosts, "hostGroup3", "host3_1", null);
    verifyHostInfo(hosts, "hostGroup3", "host3_2", "/rack3_2");
}
Also used : ApiClusterTemplateHostInfo(com.cloudera.api.swagger.model.ApiClusterTemplateHostInfo) ApiClusterTemplateInstantiator(com.cloudera.api.swagger.model.ApiClusterTemplateInstantiator) ArrayList(java.util.ArrayList) List(java.util.List) ApiClusterTemplate(com.cloudera.api.swagger.model.ApiClusterTemplate) Test(org.junit.jupiter.api.Test)

Aggregations

ApiClusterTemplate (com.cloudera.api.swagger.model.ApiClusterTemplate)2 ApiClusterTemplateHostInfo (com.cloudera.api.swagger.model.ApiClusterTemplateHostInfo)2 ApiClusterTemplateInstantiator (com.cloudera.api.swagger.model.ApiClusterTemplateInstantiator)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Test (org.junit.jupiter.api.Test)2 ApiClusterTemplateConfig (com.cloudera.api.swagger.model.ApiClusterTemplateConfig)1 ApiClusterTemplateRoleConfigGroup (com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup)1 ApiClusterTemplateRoleConfigGroupInfo (com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroupInfo)1 ApiClusterTemplateService (com.cloudera.api.swagger.model.ApiClusterTemplateService)1 AutoscaleRecommendation (com.sequenceiq.cloudbreak.cloud.model.AutoscaleRecommendation)1 ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)1 GatewayRecommendation (com.sequenceiq.cloudbreak.cloud.model.GatewayRecommendation)1 InstanceCount (com.sequenceiq.cloudbreak.cloud.model.InstanceCount)1 ResizeRecommendation (com.sequenceiq.cloudbreak.cloud.model.ResizeRecommendation)1 ClusterHostAttributes (com.sequenceiq.cloudbreak.cluster.model.ClusterHostAttributes)1 ConfigUtils.configVar (com.sequenceiq.cloudbreak.cmtemplate.configproviders.ConfigUtils.configVar)1 YarnConstants (com.sequenceiq.cloudbreak.cmtemplate.configproviders.yarn.YarnConstants)1 YarnRoles (com.sequenceiq.cloudbreak.cmtemplate.configproviders.yarn.YarnRoles)1 JsonUtil (com.sequenceiq.cloudbreak.common.json.JsonUtil)1