AmbariMetaInfo { public ServiceInfo getService(String stackName, String version, String serviceName) throws AmbariException { ServiceInfo service = getStack(stackName, version).getService(serviceName); if (service == null) { throw new StackAccessException("stackName=" + stackName + ", stackVersion=" + version + ", serviceName=" + serviceName); } return service; } @Inject  AmbariMetaInfo(Configuration conf); @Inject void init(); StackManager getStackManager(); List<ComponentInfo> getComponentsByService(String stackName, String version, String serviceName); ComponentInfo getComponent(String stackName, String version, String serviceName,
                                    String componentName); List<DependencyInfo> getComponentDependencies(String stackName, String version,
                                                       String service, String component); DependencyInfo getComponentDependency(String stackName, String version, String service,
                                               String component, String dependencyName); Map<String, List<RepositoryInfo>> getRepository(String stackName,
                                                         String version); List<RepositoryInfo> getRepositories(String stackName,
                                              String version, String osType); RepositoryInfo getRepository(String stackName,
                                      String version, String osType, String repoId); boolean isSupportedStack(String stackName, String version); boolean isValidService(String stackName, String version, String serviceName); boolean isValidServiceComponent(String stackName, String version,
                                         String serviceName, String componentName); String getComponentToService(String stackName, String version,
                                      String componentName); Map<String, ServiceInfo> getServices(String stackName, String version); ServiceInfo getService(String stackName, String version, String serviceName); boolean isServiceRemovedInStack(String stackName, String version, String serviceName); Collection<String> getMonitoringServiceNames(String stackName, String version); Set<String> getRestartRequiredServicesNames(String stackName, String version); Set<String> getRackSensitiveServicesNames(String stackName, String version); Collection<StackInfo> getStacks(); Collection<StackInfo> getStacks(String stackName); StackInfo getStack(String stackName, String version); List<String> getStackParentVersions(String stackName, String version); Collection<ExtensionInfo> getExtensions(); Collection<ExtensionInfo> getExtensions(String extensionName); ExtensionInfo getExtension(String extensionName, String version); Set<PropertyInfo> getServiceProperties(String stackName, String version, String serviceName); Set<PropertyInfo> getStackProperties(String stackName, String version); Set<PropertyInfo> getPropertiesByName(String stackName, String version, String serviceName, String propertyName); Set<PropertyInfo> getStackPropertiesByName(String stackName, String version, String propertyName); Set<OperatingSystemInfo> getOperatingSystems(String stackName, String version); OperatingSystemInfo getOperatingSystem(String stackName, String version, String osType); List<ActionDefinition> getAllActionDefinition(); ActionDefinition getActionDefinition(String name); void addActionDefinition(ActionDefinition ad); String getServerVersion(); boolean isOsSupported(String osType); static String generateRepoMetaKey(String stackName, String stackVersion,
      String osType, String repoId, String field); void updateRepo(String stackName,
                         String stackVersion, String osType, String repoId, String newBaseUrl, String newMirrorsList); File getStackRoot(); File getExtensionsRoot(); Map<String, Map<String, List<MetricDefinition>>> getServiceMetrics(String stackName,
            String stackVersion, String serviceName); List<MetricDefinition> getMetrics(String stackName, String stackVersion,
      String serviceName, String componentName, String metricType); Set<AlertDefinition> getAlertDefinitions(String stackName, String stackVersion,
                                                  String serviceName); Set<AlertDefinition> getAlertDefinitions(ServiceInfo service); void reconcileAlertDefinitions(Clusters clusters); Map<String, UpgradePack> getUpgradePacks(String stackName, String stackVersion); ConfigUpgradePack getConfigUpgradePack(String stackName, String stackVersion); KerberosDescriptor getKerberosDescriptor(String stackName, String stackVersion); KerberosServiceDescriptor[] getKerberosDescriptor(ServiceInfo serviceInfo); Map<String, String> getAmbariServerProperties(); VersionDefinitionXml getVersionDefinition(String versionDefinitionId); Map<String, VersionDefinitionXml> getVersionDefinitions(); static final String SERVICE_CONFIG_FOLDER_NAME; static final String SERVICE_PROPERTIES_FOLDER_NAME; static final String SERVICE_THEMES_FOLDER_NAME; static final String SERVICE_QUICKLINKS_CONFIGURATIONS_FOLDER_NAME; static final String SERVICE_CONFIG_FILE_NAME_POSTFIX; static final String RCO_FILE_NAME; static final String SERVICE_METRIC_FILE_NAME; static final String SERVICE_ALERT_FILE_NAME; static final String SERVICE_ADVISOR_FILE_NAME; static final String KERBEROS_DESCRIPTOR_FILE_NAME; static final String WIDGETS_DESCRIPTOR_FILE_NAME; static final String SERVICE_THEME_FILE_NAME; static final String ANY_OS; static final String SCHEMA_VERSION_2; static final FilenameFilter FILENAME_FILTER; static final String REPOSITORY_XML_PROPERTY_BASEURL; static final String REPOSITORY_XML_PROPERTY_MIRRORSLIST; }
@Test public void getServiceInfo() throws Exception { ServiceInfo si = metaInfo.getService(STACK_NAME_HDP, STACK_VERSION_HDP, SERVICE_NAME_HDFS); assertNotNull(si); }
@Test public void testConfigDependencies() throws Exception { ServiceInfo serviceInfo = metaInfo.getService(STACK_NAME_HDP, EXT_STACK_NAME, SERVICE_NAME_MAPRED2); assertNotNull(serviceInfo); assertTrue(!serviceInfo.getConfigDependencies().isEmpty()); }
@Test public void testGlobalMapping() throws Exception { ServiceInfo sinfo = metaInfo.getService("HDP", "0.2", "HDFS"); List<PropertyInfo> pinfo = sinfo.getProperties(); boolean checkforglobal = false; for (PropertyInfo pinfol: pinfo) { if ("global.xml".equals(pinfol.getFilename())) { checkforglobal = true; } } Assert.assertTrue(checkforglobal); sinfo = metaInfo.getService("HDP", "0.2", "MAPREDUCE"); boolean checkforhadoopheapsize = false; pinfo = sinfo.getProperties(); for (PropertyInfo pinfol: pinfo) { if ("global.xml".equals(pinfol.getFilename())) { if ("hadoop_heapsize".equals(pinfol.getName())) { checkforhadoopheapsize = true; } } } Assert.assertTrue(checkforhadoopheapsize); }
@Test public void testGetService() throws Exception { ServiceInfo service = metaInfo.getService(STACK_NAME_HDP, STACK_VERSION_HDP, SERVICE_NAME_HDFS); Assert.assertEquals(service.getName(), SERVICE_NAME_HDFS); try { metaInfo.getService(STACK_NAME_HDP, STACK_VERSION_HDP, NON_EXT_VALUE); } catch (StackAccessException e) { } }
@Test public void testKerberosJson() throws Exception { ServiceInfo svc; svc = metaInfo.getService(STACK_NAME_HDP, "2.0.8", "HDFS"); Assert.assertNotNull(svc); File kerberosDescriptorFile1 = svc.getKerberosDescriptorFile(); Assert.assertNotNull(kerberosDescriptorFile1); Assert.assertTrue(kerberosDescriptorFile1.exists()); svc = metaInfo.getService(STACK_NAME_HDP, "2.1.1", "HDFS"); Assert.assertNotNull(svc); File kerberosDescriptorFile2 = svc.getKerberosDescriptorFile(); Assert.assertNotNull(kerberosDescriptorFile1); Assert.assertTrue(kerberosDescriptorFile1.exists()); Assert.assertEquals(kerberosDescriptorFile1, kerberosDescriptorFile2); svc = metaInfo.getService(STACK_NAME_HDP, "2.0.7", "HDFS"); Assert.assertNotNull(svc); File kerberosDescriptorFile3 = svc.getKerberosDescriptorFile(); Assert.assertNull(kerberosDescriptorFile3); }
@Test public void testGanglia134Dependencies() throws Exception { ServiceInfo service = metaInfo.getService(STACK_NAME_HDP, "1.3.4", "GANGLIA"); List<ComponentInfo> componentList = service.getComponents(); Assert.assertEquals(2, componentList.size()); for (ComponentInfo component : componentList) { String name = component.getName(); if (name.equals("GANGLIA_SERVER")) { Assert.assertEquals(0, component.getDependencies().size()); Assert.assertNull(component.getAutoDeploy()); Assert.assertEquals("1", component.getCardinality()); } if (name.equals("GANGLIA_MONITOR")) { Assert.assertEquals(0, component.getDependencies().size()); Assert.assertTrue(component.getAutoDeploy().isEnabled()); Assert.assertEquals("ALL", component.getCardinality()); } } }
@Test public void testHBase134Dependencies() throws Exception { ServiceInfo service = metaInfo.getService(STACK_NAME_HDP, "1.3.4", "HBASE"); List<ComponentInfo> componentList = service.getComponents(); Assert.assertEquals(3, componentList.size()); for (ComponentInfo component : componentList) { String name = component.getName(); if (name.equals("HBASE_MASTER")) { List<DependencyInfo> dependencyList = component.getDependencies(); Assert.assertEquals(2, dependencyList.size()); for (DependencyInfo dependency : dependencyList) { if (dependency.getName().equals("HDFS/HDFS_CLIENT")) { Assert.assertEquals("host", dependency.getScope()); Assert.assertEquals(true, dependency.getAutoDeploy().isEnabled()); } else if (dependency.getName().equals("ZOOKEEPER/ZOOKEEPER_SERVER")) { Assert.assertEquals("cluster", dependency.getScope()); AutoDeployInfo autoDeploy = dependency.getAutoDeploy(); Assert.assertEquals(true, autoDeploy.isEnabled()); Assert.assertEquals("HBASE/HBASE_MASTER", autoDeploy.getCoLocate()); } else { Assert.fail("Unexpected dependency"); } } Assert.assertNull(component.getAutoDeploy()); Assert.assertEquals("1", component.getCardinality()); } if (name.equals("HBASE_REGIONSERVER")) { Assert.assertEquals(0, component.getDependencies().size()); Assert.assertNull(component.getAutoDeploy()); Assert.assertEquals("1+", component.getCardinality()); } if (name.equals("HBASE_CLIENT")) { Assert.assertEquals(0, component.getDependencies().size()); Assert.assertNull(component.getAutoDeploy()); Assert.assertEquals("0+", component.getCardinality()); } } }
@Test public void testHDFS134Dependencies() throws Exception { ServiceInfo service = metaInfo.getService(STACK_NAME_HDP, "1.3.4", "HDFS"); List<ComponentInfo> componentList = service.getComponents(); Assert.assertEquals(4, componentList.size()); for (ComponentInfo component : componentList) { String name = component.getName(); if (name.equals("NAMENODE")) { Assert.assertEquals(0, component.getDependencies().size()); Assert.assertNull(component.getAutoDeploy()); Assert.assertEquals("1", component.getCardinality()); } if (name.equals("DATANODE")) { Assert.assertEquals(0, component.getDependencies().size()); Assert.assertNull(component.getAutoDeploy()); Assert.assertEquals("1+", component.getCardinality()); } if (name.equals("SECONDARY_NAMENODE")) { Assert.assertEquals(0, component.getDependencies().size()); Assert.assertNull(component.getAutoDeploy()); Assert.assertEquals("1", component.getCardinality()); } if (name.equals("HDFS_CLIENT")) { Assert.assertEquals(0, component.getDependencies().size()); Assert.assertNull(component.getAutoDeploy()); Assert.assertEquals("0+", component.getCardinality()); } } }
@Test public void testHive134Dependencies() throws Exception { ServiceInfo service = metaInfo.getService(STACK_NAME_HDP, "1.3.4", "HIVE"); List<ComponentInfo> componentList = service.getComponents(); Assert.assertEquals(4, componentList.size()); for (ComponentInfo component : componentList) { String name = component.getName(); if (name.equals("HIVE_METASTORE")) { Assert.assertEquals(0, component.getDependencies().size()); AutoDeployInfo autoDeploy = component.getAutoDeploy(); Assert.assertTrue(autoDeploy.isEnabled()); Assert.assertEquals("HIVE/HIVE_SERVER", autoDeploy.getCoLocate()); Assert.assertEquals("1", component.getCardinality()); } if (name.equals("HIVE_SERVER")) { List<DependencyInfo> dependencyList = component.getDependencies(); Assert.assertEquals(1, dependencyList.size()); DependencyInfo dependency = dependencyList.get(0); Assert.assertEquals("ZOOKEEPER/ZOOKEEPER_SERVER", dependency.getName()); Assert.assertEquals("cluster", dependency.getScope()); AutoDeployInfo autoDeploy = dependency.getAutoDeploy(); Assert.assertTrue(autoDeploy.isEnabled()); Assert.assertEquals("HIVE/HIVE_SERVER", autoDeploy.getCoLocate()); Assert.assertNull(component.getAutoDeploy()); Assert.assertEquals("1", component.getCardinality()); } if (name.equals("MYSQL_SERVER")) { Assert.assertEquals(0, component.getDependencies().size()); AutoDeployInfo autoDeploy = component.getAutoDeploy(); Assert.assertTrue(autoDeploy.isEnabled()); Assert.assertEquals("HIVE/HIVE_SERVER", autoDeploy.getCoLocate()); Assert.assertEquals("1", component.getCardinality()); } if (name.equals("HIVE_CLIENT")) { Assert.assertEquals(0, component.getDependencies().size()); Assert.assertNull(component.getAutoDeploy()); Assert.assertEquals("0+", component.getCardinality()); } } }
@Test public void testHue134Dependencies() throws Exception { ServiceInfo service = metaInfo.getService(STACK_NAME_HDP, "1.3.4", "HUE"); List<ComponentInfo> componentList = service.getComponents(); Assert.assertEquals(1, componentList.size()); ComponentInfo component = componentList.get(0); Assert.assertEquals("HUE_SERVER", component.getName()); Assert.assertEquals(0, component.getDependencies().size()); Assert.assertNull(component.getAutoDeploy()); Assert.assertEquals("1", component.getCardinality()); }
@Test public void testMapReduce134Dependencies() throws Exception { ServiceInfo service = metaInfo.getService(STACK_NAME_HDP, "1.3.4", "MAPREDUCE"); List<ComponentInfo> componentList = service.getComponents(); Assert.assertEquals(4, componentList.size()); for (ComponentInfo component : componentList) { String name = component.getName(); if (name.equals("JOBTRACKER")) { Assert.assertEquals(0, component.getDependencies().size()); Assert.assertNull(component.getAutoDeploy()); Assert.assertEquals("1", component.getCardinality()); } if (name.equals("TASKTRACKER")) { Assert.assertEquals(0, component.getDependencies().size()); Assert.assertNull(component.getAutoDeploy()); Assert.assertEquals("1+", component.getCardinality()); } if (name.equals("HISTORYSERVER")) { Assert.assertEquals(0, component.getDependencies().size()); AutoDeployInfo autoDeploy = component.getAutoDeploy(); Assert.assertTrue(autoDeploy.isEnabled()); Assert.assertEquals("MAPREDUCE/JOBTRACKER", autoDeploy.getCoLocate()); Assert.assertEquals("1", component.getCardinality()); } if (name.equals("MAPREDUCE_CLIENT")) { Assert.assertEquals(0, component.getDependencies().size()); Assert.assertNull(component.getAutoDeploy()); Assert.assertEquals("0+", component.getCardinality()); } } }
@Test public void testOozie134Dependencies() throws Exception { ServiceInfo service = metaInfo.getService(STACK_NAME_HDP, "1.3.4", "OOZIE"); List<ComponentInfo> componentList = service.getComponents(); Assert.assertEquals(2, componentList.size()); for (ComponentInfo component : componentList) { String name = component.getName(); if (name.equals("OOZIE_SERVER")) { List<DependencyInfo> dependencyList = component.getDependencies(); Assert.assertEquals(2, dependencyList.size()); for (DependencyInfo dependency : dependencyList) { if (dependency.getName().equals("HDFS/HDFS_CLIENT")) { Assert.assertEquals("host", dependency.getScope()); Assert.assertEquals(true, dependency.getAutoDeploy().isEnabled()); } else if (dependency.getName().equals("MAPREDUCE/MAPREDUCE_CLIENT")) { Assert.assertEquals("host", dependency.getScope()); Assert.assertEquals(true, dependency.getAutoDeploy().isEnabled()); } else { Assert.fail("Unexpected dependency"); } } Assert.assertNull(component.getAutoDeploy()); Assert.assertEquals("1", component.getCardinality()); } if (name.equals("OOZIE_CLIENT")) { List<DependencyInfo> dependencyList = component.getDependencies(); Assert.assertEquals(2, dependencyList.size()); for (DependencyInfo dependency : dependencyList) { if (dependency.getName().equals("HDFS/HDFS_CLIENT")) { Assert.assertEquals("host", dependency.getScope()); Assert.assertEquals(true, dependency.getAutoDeploy().isEnabled()); } else if (dependency.getName().equals("MAPREDUCE/MAPREDUCE_CLIENT")) { Assert.assertEquals("host", dependency.getScope()); Assert.assertEquals(true, dependency.getAutoDeploy().isEnabled()); } else { Assert.fail("Unexpected dependency"); } } Assert.assertNull(component.getAutoDeploy()); Assert.assertEquals("0+", component.getCardinality()); } } }
@Test public void testPig134Dependencies() throws Exception { ServiceInfo service = metaInfo.getService(STACK_NAME_HDP, "1.3.4", "PIG"); List<ComponentInfo> componentList = service.getComponents(); Assert.assertEquals(1, componentList.size()); ComponentInfo component = componentList.get(0); Assert.assertEquals("PIG", component.getName()); Assert.assertEquals(0, component.getDependencies().size()); Assert.assertNull(component.getAutoDeploy()); Assert.assertEquals("0+", component.getCardinality()); }
@Test public void testSqoop134Dependencies() throws Exception { ServiceInfo service = metaInfo.getService(STACK_NAME_HDP, "1.3.4", "SQOOP"); List<ComponentInfo> componentList = service.getComponents(); Assert.assertEquals(1, componentList.size()); ComponentInfo component = componentList.get(0); Assert.assertEquals("SQOOP", component.getName()); List<DependencyInfo> dependencyList = component.getDependencies(); Assert.assertEquals(2, dependencyList.size()); for (DependencyInfo dependency : dependencyList) { if (dependency.getName().equals("HDFS/HDFS_CLIENT")) { Assert.assertEquals("host", dependency.getScope()); Assert.assertEquals(true, dependency.getAutoDeploy().isEnabled()); } else if (dependency.getName().equals("MAPREDUCE/MAPREDUCE_CLIENT")) { Assert.assertEquals("host", dependency.getScope()); Assert.assertEquals(true, dependency.getAutoDeploy().isEnabled()); } else { Assert.fail("Unexpected dependency"); } } Assert.assertNull(component.getAutoDeploy()); Assert.assertEquals("0+", component.getCardinality()); }
@Test public void testWebHCat134Dependencies() throws Exception { ServiceInfo service = metaInfo.getService(STACK_NAME_HDP, "1.3.4", "WEBHCAT"); List<ComponentInfo> componentList = service.getComponents(); Assert.assertEquals(1, componentList.size()); ComponentInfo component = componentList.get(0); Assert.assertEquals("WEBHCAT_SERVER", component.getName()); List<DependencyInfo> dependencyList = component.getDependencies(); Assert.assertEquals(4, dependencyList.size()); for (DependencyInfo dependency : dependencyList) { if (dependency.getName().equals("HDFS/HDFS_CLIENT")) { Assert.assertEquals("host", dependency.getScope()); Assert.assertEquals(true, dependency.getAutoDeploy().isEnabled()); } else if (dependency.getName().equals("MAPREDUCE/MAPREDUCE_CLIENT")) { Assert.assertEquals("host", dependency.getScope()); Assert.assertEquals(true, dependency.getAutoDeploy().isEnabled()); } else if (dependency.getName().equals("ZOOKEEPER/ZOOKEEPER_SERVER")) { Assert.assertEquals("cluster", dependency.getScope()); AutoDeployInfo autoDeploy = dependency.getAutoDeploy(); Assert.assertEquals(true, autoDeploy.isEnabled()); Assert.assertEquals("WEBHCAT/WEBHCAT_SERVER", autoDeploy.getCoLocate()); }else if (dependency.getName().equals("ZOOKEEPER/ZOOKEEPER_CLIENT")) { Assert.assertEquals("host", dependency.getScope()); Assert.assertEquals(true, dependency.getAutoDeploy().isEnabled()); }else { Assert.fail("Unexpected dependency"); } } Assert.assertNull(component.getAutoDeploy()); Assert.assertEquals("1", component.getCardinality()); }
@Test public void testZooKeeper134Dependencies() throws Exception { ServiceInfo service = metaInfo.getService(STACK_NAME_HDP, "1.3.4", "ZOOKEEPER"); List<ComponentInfo> componentList = service.getComponents(); Assert.assertEquals(2, componentList.size()); for (ComponentInfo component : componentList) { String name = component.getName(); if (name.equals("ZOOKEEPER_SERVER")) { Assert.assertEquals(0, component.getDependencies().size()); Assert.assertNull(component.getAutoDeploy()); Assert.assertEquals("1", component.getCardinality()); } if (name.equals("ZOOKEEPER_CLIENT")) { Assert.assertEquals(0, component.getDependencies().size()); Assert.assertNull(component.getAutoDeploy()); Assert.assertEquals("0+", component.getCardinality()); } } }
@Test public void testServicePackageDirInheritance() throws Exception { String assertionTemplate07 = StringUtils.join( new String[]{"stacks", "HDP", "2.0.7", "services", "%s", "package"}, File.separator); String assertionTemplate08 = StringUtils.join( new String[]{"stacks", "HDP", "2.0.8", "services", "%s", "package"}, File.separator); ServiceInfo service = metaInfo.getService(STACK_NAME_HDP, "2.0.7", "HBASE"); Assert.assertEquals(String.format(assertionTemplate07, "HBASE"), service.getServicePackageFolder()); service = metaInfo.getService(STACK_NAME_HDP, "2.0.7", "HDFS"); Assert.assertEquals(String.format(assertionTemplate07, "HDFS"), service.getServicePackageFolder()); service = metaInfo.getService(STACK_NAME_HDP, "2.0.8", "HBASE"); Assert.assertEquals(String.format(assertionTemplate07, "HBASE"), service.getServicePackageFolder()); service = metaInfo.getService(STACK_NAME_HDP, "2.0.8", "HDFS"); Assert.assertEquals(String.format(assertionTemplate08, "HDFS"), service.getServicePackageFolder()); }
@Test public void testServiceCommandScriptInheritance() throws Exception { ServiceInfo service = metaInfo.getService(STACK_NAME_HDP, "2.0.7", "HDFS"); Assert.assertEquals("scripts/service_check_1.py", service.getCommandScript().getScript()); service = metaInfo.getService(STACK_NAME_HDP, "2.0.7", "HBASE"); Assert.assertEquals("scripts/service_check.py", service.getCommandScript().getScript()); service = metaInfo.getService(STACK_NAME_HDP, "2.0.8", "HBASE"); Assert.assertEquals("scripts/service_check.py", service.getCommandScript().getScript()); service = metaInfo.getService(STACK_NAME_HDP, "2.0.8", "HDFS"); Assert.assertEquals("scripts/service_check_2.py", service.getCommandScript().getScript()); }
@Test public void testServiceCustomCommandScriptInheritance() throws Exception { ServiceInfo service = metaInfo.getService(STACK_NAME_HDP, "2.0.7", "HDFS"); CustomCommandDefinition ccd = findCustomCommand("RESTART", service); Assert.assertEquals("scripts/restart_parent.py", ccd.getCommandScript().getScript()); ccd = findCustomCommand("YET_ANOTHER_PARENT_SRV_COMMAND", service); Assert.assertEquals("scripts/yet_another_parent_srv_command.py", ccd.getCommandScript().getScript()); Assert.assertEquals(2, service.getCustomCommands().size()); service = metaInfo.getService(STACK_NAME_HDP, "2.0.8", "HDFS"); Assert.assertEquals(3, service.getCustomCommands().size()); ccd = findCustomCommand("YET_ANOTHER_PARENT_SRV_COMMAND", service); Assert.assertEquals("scripts/yet_another_parent_srv_command.py", ccd.getCommandScript().getScript()); service = metaInfo.getService(STACK_NAME_HDP, "2.0.8", "HDFS"); ccd = findCustomCommand("RESTART", service); Assert.assertEquals("scripts/restart_child.py", ccd.getCommandScript().getScript()); ccd = findCustomCommand("YET_ANOTHER_CHILD_SRV_COMMAND", service); Assert.assertEquals("scripts/yet_another_child_srv_command.py", ccd.getCommandScript().getScript()); }
@Test public void testServiceOsSpecificsInheritance() throws Exception { ServiceInfo service = metaInfo.getService(STACK_NAME_HDP, "2.0.7", "HDFS"); Assert.assertEquals("parent-package-def", service.getOsSpecifics().get("any").getPackages().get(0).getName()); service = metaInfo.getService(STACK_NAME_HDP, "2.0.7", "HBASE"); Assert.assertEquals(2, service.getOsSpecifics().keySet().size()); service = metaInfo.getService(STACK_NAME_HDP, "2.0.8", "HBASE"); Assert.assertEquals(2, service.getOsSpecifics().keySet().size()); service = metaInfo.getService(STACK_NAME_HDP, "2.0.8", "HDFS"); Assert.assertEquals("child-package-def", service.getOsSpecifics().get("any").getPackages().get(0).getName()); }
@Test public void testServiceSchemaVersionInheritance() throws Exception { ServiceInfo service = metaInfo.getService(STACK_NAME_HDP, "2.0.7", "SQOOP"); Assert.assertEquals("2.0", service.getSchemaVersion()); service = metaInfo.getService(STACK_NAME_HDP, "2.0.8", "SQOOP"); Assert.assertEquals("2.0", service.getSchemaVersion()); }
@Test public void testCustomConfigDir() throws Exception { ServiceInfo service = metaInfo.getService(STACK_NAME_HDP, "2.0.7", "MAPREDUCE2"); boolean found = false; for (PropertyInfo pi : service.getProperties()) { if (pi.getName().equals("mr2-prop")) { Assert.assertEquals("some-mr2-value", pi.getValue()); found = true; } } Assert.assertTrue(found); }
@Test public void testPasswordPropertyAttribute() throws Exception { ServiceInfo service = metaInfo.getService(STACK_NAME_HDP, "2.0.1", "HIVE"); List<PropertyInfo> propertyInfoList = service.getProperties(); Assert.assertNotNull(propertyInfoList); PropertyInfo passwordProperty = null; for (PropertyInfo propertyInfo : propertyInfoList) { if (propertyInfo.isRequireInput() && propertyInfo.getPropertyTypes().contains(PropertyInfo.PropertyType.PASSWORD)) { passwordProperty = propertyInfo; } else { Assert.assertTrue(propertyInfo.getPropertyTypes().isEmpty()); } } Assert.assertNotNull(passwordProperty); Assert.assertEquals("javax.jdo.option.ConnectionPassword", passwordProperty.getName()); }
@Test public void testKerberosDescriptor() throws Exception { ServiceInfo service; service = metaInfo.getService(STACK_NAME_HDP, "2.1.1", "PIG"); Assert.assertNotNull(service); Assert.assertNull(service.getKerberosDescriptorFile()); service = metaInfo.getService(STACK_NAME_HDP, "2.0.8", "HDFS"); Assert.assertNotNull(service); Assert.assertNotNull(service.getKerberosDescriptorFile()); service = metaInfo.getService(STACK_NAME_HDP, "2.1.1", "HDFS"); Assert.assertNotNull(service); Assert.assertNotNull(service.getKerberosDescriptorFile()); Map<?,?> kerberosDescriptorData = new Gson() .fromJson(new FileReader(service.getKerberosDescriptorFile()), Map.class); Assert.assertNotNull(kerberosDescriptorData); Assert.assertEquals(1, kerberosDescriptorData.size()); }