Repository: ambari Updated Branches: refs/heads/trunk b95fe4423 -> d7fcd258d
http://git-wip-us.apache.org/repos/asf/ambari/blob/d7fcd258/ambari-server/src/main/resources/stacks/PHD/3.0.0.0/services/stack_advisor.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/PHD/3.0.0.0/services/stack_advisor.py b/ambari-server/src/main/resources/stacks/PHD/3.0.0.0/services/stack_advisor.py index 9052509..3a2347a 100644 --- a/ambari-server/src/main/resources/stacks/PHD/3.0.0.0/services/stack_advisor.py +++ b/ambari-server/src/main/resources/stacks/PHD/3.0.0.0/services/stack_advisor.py @@ -106,7 +106,7 @@ class BasePHD3000StackAdvisor(DefaultStackAdvisor): putMapredProperty('mapreduce.reduce.java.opts', "-Xmx" + str(int(round(0.8 * clusterData['reduceMemory']))) + "m") putMapredProperty('mapreduce.task.io.sort.mb', min(int(round(0.4 * clusterData['mapMemory'])), 1024)) - def getConfigurationClusterSummary(self, servicesList, hosts, components): + def getConfigurationClusterSummary(self, servicesList, hosts, components, services): hBaseInstalled = False if 'HBASE' in servicesList: http://git-wip-us.apache.org/repos/asf/ambari/blob/d7fcd258/ambari-server/src/main/resources/stacks/stack_advisor.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/stack_advisor.py b/ambari-server/src/main/resources/stacks/stack_advisor.py index 42db088..c19a7ce 100644 --- a/ambari-server/src/main/resources/stacks/stack_advisor.py +++ b/ambari-server/src/main/resources/stacks/stack_advisor.py @@ -465,7 +465,7 @@ class DefaultStackAdvisor(StackAdvisor): def getComponentLayoutValidations(self, services, hosts): return [] - def getConfigurationClusterSummary(self, servicesList, hosts, components): + def getConfigurationClusterSummary(self, servicesList, hosts, components, services): pass def getConfigurationsValidationItems(self, services, hosts): @@ -480,7 +480,7 @@ class DefaultStackAdvisor(StackAdvisor): for service in services["services"] for component in service["components"]] - clusterSummary = self.getConfigurationClusterSummary(servicesList, hosts, components) + clusterSummary = self.getConfigurationClusterSummary(servicesList, hosts, components, services) recommendations = { "Versions": {"stack_name": stackName, "stack_version": stackVersion}, http://git-wip-us.apache.org/repos/asf/ambari/blob/d7fcd258/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java index 051cf54..22bece8 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java @@ -35,6 +35,7 @@ import java.lang.reflect.Field; import java.util.Collection; import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; @@ -62,6 +63,7 @@ import org.apache.ambari.server.state.AutoDeployInfo; import org.apache.ambari.server.state.Cluster; import org.apache.ambari.server.state.Clusters; import org.apache.ambari.server.state.ComponentInfo; +import org.apache.ambari.server.state.ConfigHelper; import org.apache.ambari.server.state.CustomCommandDefinition; import org.apache.ambari.server.state.DependencyInfo; import org.apache.ambari.server.state.OperatingSystemInfo; @@ -750,7 +752,7 @@ public class AmbariMetaInfoTest { PropertyInfo originalProperty = null; PropertyDependencyInfo propertyDependencyInfo = - new PropertyDependencyInfo("yarn-site.xml", "new-enhanced-yarn-property"); + new PropertyDependencyInfo("yarn-site", "new-enhanced-yarn-property"); for (PropertyInfo propertyInfo : redefinedService.getProperties()) { if (propertyInfo.getName().equals("yarn.resourcemanager.resource-tracker.address")) { @@ -799,8 +801,8 @@ public class AmbariMetaInfoTest { Assert.assertEquals("some enhanced description.", newEnhancedProperty.getDescription()); Assert.assertEquals("yarn-site.xml", newEnhancedProperty.getFilename()); Assert.assertEquals(2, newEnhancedProperty.getDependsOnProperties().size()); - Assert.assertTrue(newEnhancedProperty.getDependsOnProperties().contains(new PropertyDependencyInfo("yarn-site.xml", "new-yarn-property"))); - Assert.assertTrue(newEnhancedProperty.getDependsOnProperties().contains(new PropertyDependencyInfo("global.xml", "yarn_heapsize"))); + Assert.assertTrue(newEnhancedProperty.getDependsOnProperties().contains(new PropertyDependencyInfo("yarn-site", "new-yarn-property"))); + Assert.assertTrue(newEnhancedProperty.getDependsOnProperties().contains(new PropertyDependencyInfo("global", "yarn_heapsize"))); Assert.assertEquals("MB", newEnhancedProperty.getPropertyValueAttributes().getUnit()); Assert.assertEquals("int", newEnhancedProperty.getPropertyValueAttributes().getType()); Assert.assertEquals("512", newEnhancedProperty.getPropertyValueAttributes().getMinimum()); @@ -816,6 +818,18 @@ public class AmbariMetaInfoTest { originalProperty.getDescription()); Assert.assertEquals(6, redefinedService.getConfigDependencies().size()); Assert.assertEquals(7, redefinedService.getConfigDependenciesWithComponents().size()); + + // Test directed-acyclic-graph (DAG) of dependencies between configurations + List<PropertyDependencyInfo> changedConfigs = new LinkedList<PropertyDependencyInfo>(); + String type = ConfigHelper.fileNameToConfigType(newProperty.getFilename()); + String name = newProperty.getName(); + changedConfigs.add(new PropertyDependencyInfo(type, name)); + Set<PropertyDependencyInfo> dependedByProperties = metaInfo.getDependedByProperties(stackInfo.getName(), stackInfo.getVersion(), changedConfigs); + Assert.assertEquals(3, dependedByProperties.size()); + Assert.assertTrue(dependedByProperties.contains(new PropertyDependencyInfo("yarn-site", "new-enhanced-yarn-property2"))); + Assert.assertTrue(dependedByProperties.contains(new PropertyDependencyInfo("yarn-site", "new-enhanced-yarn-property"))); + Assert.assertTrue(dependedByProperties.contains(new PropertyDependencyInfo("yarn-site", "new-yarn-property"))); + } @Test http://git-wip-us.apache.org/repos/asf/ambari/blob/d7fcd258/ambari-server/src/test/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorHelperTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorHelperTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorHelperTest.java index 87729b1..5190dea 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorHelperTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorHelperTest.java @@ -30,9 +30,10 @@ import java.io.IOException; import org.apache.ambari.server.api.services.AmbariMetaInfo; import org.apache.ambari.server.api.services.stackadvisor.StackAdvisorRequest.StackAdvisorRequestBuilder; import org.apache.ambari.server.api.services.stackadvisor.StackAdvisorRequest.StackAdvisorRequestType; -import org.apache.ambari.server.api.services.stackadvisor.commands.GetComponentLayoutRecommnedationCommand; -import org.apache.ambari.server.api.services.stackadvisor.commands.GetComponentLayoutValidationCommand; -import org.apache.ambari.server.api.services.stackadvisor.commands.GetConfigurationValidationCommand; +import org.apache.ambari.server.api.services.stackadvisor.commands.ComponentLayoutRecommendationCommand; +import org.apache.ambari.server.api.services.stackadvisor.commands.ComponentLayoutValidationCommand; +import org.apache.ambari.server.api.services.stackadvisor.commands.ConfigurationDependenciesRecommendationCommand; +import org.apache.ambari.server.api.services.stackadvisor.commands.ConfigurationValidationCommand; import org.apache.ambari.server.api.services.stackadvisor.commands.StackAdvisorCommand; import org.apache.ambari.server.api.services.stackadvisor.recommendations.RecommendationResponse; import org.apache.ambari.server.api.services.stackadvisor.validations.ValidationResponse; @@ -129,7 +130,7 @@ public class StackAdvisorHelperTest { } @Test - public void testCreateRecommendationCommand_returnsGetComponentLayoutRecommnedationCommand() + public void testCreateRecommendationCommand_returnsComponentLayoutRecommendationCommand() throws IOException, StackAdvisorException { Configuration configuration = mock(Configuration.class); StackAdvisorRunner saRunner = mock(StackAdvisorRunner.class); @@ -140,11 +141,11 @@ public class StackAdvisorHelperTest { StackAdvisorCommand<RecommendationResponse> command = helper .createRecommendationCommand(requestType); - assertEquals(GetComponentLayoutRecommnedationCommand.class, command.getClass()); + assertEquals(ComponentLayoutRecommendationCommand.class, command.getClass()); } @Test - public void testCreateValidationCommand_returnsGetComponentLayoutValidationCommand() + public void testCreateValidationCommand_returnsComponentLayoutValidationCommand() throws IOException, StackAdvisorException { Configuration configuration = mock(Configuration.class); StackAdvisorRunner saRunner = mock(StackAdvisorRunner.class); @@ -154,11 +155,11 @@ public class StackAdvisorHelperTest { StackAdvisorCommand<ValidationResponse> command = helper.createValidationCommand(requestType); - assertEquals(GetComponentLayoutValidationCommand.class, command.getClass()); + assertEquals(ComponentLayoutValidationCommand.class, command.getClass()); } @Test - public void testCreateValidationCommand_returnsGetConfigurationValidationCommand() + public void testCreateValidationCommand_returnsConfigurationValidationCommand() throws IOException, StackAdvisorException { Configuration configuration = mock(Configuration.class); StackAdvisorRunner saRunner = mock(StackAdvisorRunner.class); @@ -168,7 +169,21 @@ public class StackAdvisorHelperTest { StackAdvisorCommand<ValidationResponse> command = helper.createValidationCommand(requestType); - assertEquals(GetConfigurationValidationCommand.class, command.getClass()); + assertEquals(ConfigurationValidationCommand.class, command.getClass()); + } + + @Test + public void testCreateRecommendationDependencyCommand_returnsConfigurationDependencyRecommendationCommand() + throws IOException, StackAdvisorException { + Configuration configuration = mock(Configuration.class); + StackAdvisorRunner saRunner = mock(StackAdvisorRunner.class); + AmbariMetaInfo metaInfo = mock(AmbariMetaInfo.class); + StackAdvisorHelper helper = new StackAdvisorHelper(configuration, saRunner, metaInfo); + StackAdvisorRequestType requestType = StackAdvisorRequestType.CONFIGURATION_DEPENDENCIES; + + StackAdvisorCommand<RecommendationResponse> command = helper.createRecommendationCommand(requestType); + + assertEquals(ConfigurationDependenciesRecommendationCommand.class, command.getClass()); } } http://git-wip-us.apache.org/repos/asf/ambari/blob/d7fcd258/ambari-server/src/test/java/org/apache/ambari/server/api/services/stackadvisor/commands/ConfigurationRecommendationCommandTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/services/stackadvisor/commands/ConfigurationRecommendationCommandTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/services/stackadvisor/commands/ConfigurationRecommendationCommandTest.java new file mode 100644 index 0000000..bc9cf77 --- /dev/null +++ b/ambari-server/src/test/java/org/apache/ambari/server/api/services/stackadvisor/commands/ConfigurationRecommendationCommandTest.java @@ -0,0 +1,103 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ambari.server.api.services.stackadvisor.commands; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; + +import java.io.File; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.ambari.server.api.services.AmbariMetaInfo; +import org.apache.ambari.server.api.services.stackadvisor.StackAdvisorRequest; +import org.apache.ambari.server.api.services.stackadvisor.StackAdvisorRunner; +import org.apache.ambari.server.api.services.stackadvisor.recommendations.RecommendationResponse; +import org.junit.Test; + +public class ConfigurationRecommendationCommandTest { + + @Test + public void testProcessHostGroups() throws Exception { + StackAdvisorRunner saRunner = mock(StackAdvisorRunner.class); + File file = mock(File.class); + AmbariMetaInfo metaInfo = mock(AmbariMetaInfo.class); + ConfigurationRecommendationCommand command = new ConfigurationRecommendationCommand(file, "script", 1, saRunner, metaInfo); + + StackAdvisorRequest request = mock(StackAdvisorRequest.class); + Map<String, Set<String>> componentHostGroupMap = new HashMap<String, Set<String>>(); + Set<String> components1 = new HashSet<String>(); + components1.add("component1"); + components1.add("component4"); + components1.add("component5"); + componentHostGroupMap.put("group1", components1); + Set<String> components2 = new HashSet<String>(); + components2.add("component2"); + components2.add("component3"); + componentHostGroupMap.put("group2", components2); + doReturn(componentHostGroupMap).when(request).getHostComponents(); + Set<RecommendationResponse.HostGroup> hostGroups = command.processHostGroups(request); + + assertNotNull(hostGroups); + assertEquals(2, hostGroups.size()); + Map<String, RecommendationResponse.HostGroup> hostGroupMap = + new HashMap<String, RecommendationResponse.HostGroup>(); + for (RecommendationResponse.HostGroup hostGroup : hostGroups) { + hostGroupMap.put(hostGroup.getName(), hostGroup); + } + RecommendationResponse.HostGroup hostGroup1 = hostGroupMap.get("group1"); + assertNotNull(hostGroup1); + Set<Map<String, String>> host1Components = hostGroup1.getComponents(); + assertNotNull(host1Components); + assertEquals(3, host1Components.size()); + Set<String> componentNames1 = new HashSet<String>(); + for (Map<String, String> host1Component : host1Components) { + assertNotNull(host1Component); + assertEquals(1, host1Component.size()); + String componentName = host1Component.get("name"); + assertNotNull(componentName); + componentNames1.add(componentName); + } + assertEquals(3, componentNames1.size()); + assertTrue(componentNames1.contains("component1")); + assertTrue(componentNames1.contains("component4")); + assertTrue(componentNames1.contains("component5")); + RecommendationResponse.HostGroup hostGroup2 = hostGroupMap.get("group2"); + assertNotNull(hostGroup2); + Set<Map<String, String>> host2Components = hostGroup2.getComponents(); + assertNotNull(host2Components); + assertEquals(2, host2Components.size()); + Set<String> componentNames2 = new HashSet<String>(); + for (Map<String, String> host2Component : host2Components) { + assertNotNull(host2Component); + assertEquals(1, host2Component.size()); + String componentName = host2Component.get("name"); + assertNotNull(componentName); + componentNames2.add(componentName); + } + assertEquals(2, componentNames2.size()); + assertTrue(componentNames2.contains("component2")); + assertTrue(componentNames2.contains("component3")); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/d7fcd258/ambari-server/src/test/java/org/apache/ambari/server/api/services/stackadvisor/commands/GetConfigurationRecommnedationCommandTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/services/stackadvisor/commands/GetConfigurationRecommnedationCommandTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/services/stackadvisor/commands/GetConfigurationRecommnedationCommandTest.java deleted file mode 100644 index 1bd66a4..0000000 --- a/ambari-server/src/test/java/org/apache/ambari/server/api/services/stackadvisor/commands/GetConfigurationRecommnedationCommandTest.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ambari.server.api.services.stackadvisor.commands; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; - -import java.io.File; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import org.apache.ambari.server.api.services.AmbariMetaInfo; -import org.apache.ambari.server.api.services.stackadvisor.StackAdvisorRequest; -import org.apache.ambari.server.api.services.stackadvisor.StackAdvisorRunner; -import org.apache.ambari.server.api.services.stackadvisor.recommendations.RecommendationResponse; -import org.junit.Test; - -public class GetConfigurationRecommnedationCommandTest { - - @Test - public void testProcessHostGroups() throws Exception { - StackAdvisorRunner saRunner = mock(StackAdvisorRunner.class); - File file = mock(File.class); - AmbariMetaInfo metaInfo = mock(AmbariMetaInfo.class); - GetConfigurationRecommnedationCommand command = new GetConfigurationRecommnedationCommand(file, "script", 1, saRunner, metaInfo); - - StackAdvisorRequest request = mock(StackAdvisorRequest.class); - Map<String, Set<String>> componentHostGroupMap = new HashMap<String, Set<String>>(); - Set<String> components1 = new HashSet<String>(); - components1.add("component1"); - components1.add("component4"); - components1.add("component5"); - componentHostGroupMap.put("group1", components1); - Set<String> components2 = new HashSet<String>(); - components2.add("component2"); - components2.add("component3"); - componentHostGroupMap.put("group2", components2); - doReturn(componentHostGroupMap).when(request).getHostComponents(); - Set<RecommendationResponse.HostGroup> hostGroups = command.processHostGroups(request); - - assertNotNull(hostGroups); - assertEquals(2, hostGroups.size()); - Map<String, RecommendationResponse.HostGroup> hostGroupMap = - new HashMap<String, RecommendationResponse.HostGroup>(); - for (RecommendationResponse.HostGroup hostGroup : hostGroups) { - hostGroupMap.put(hostGroup.getName(), hostGroup); - } - RecommendationResponse.HostGroup hostGroup1 = hostGroupMap.get("group1"); - assertNotNull(hostGroup1); - Set<Map<String, String>> host1Components = hostGroup1.getComponents(); - assertNotNull(host1Components); - assertEquals(3, host1Components.size()); - Set<String> componentNames1 = new HashSet<String>(); - for (Map<String, String> host1Component : host1Components) { - assertNotNull(host1Component); - assertEquals(1, host1Component.size()); - String componentName = host1Component.get("name"); - assertNotNull(componentName); - componentNames1.add(componentName); - } - assertEquals(3, componentNames1.size()); - assertTrue(componentNames1.contains("component1")); - assertTrue(componentNames1.contains("component4")); - assertTrue(componentNames1.contains("component5")); - RecommendationResponse.HostGroup hostGroup2 = hostGroupMap.get("group2"); - assertNotNull(hostGroup2); - Set<Map<String, String>> host2Components = hostGroup2.getComponents(); - assertNotNull(host2Components); - assertEquals(2, host2Components.size()); - Set<String> componentNames2 = new HashSet<String>(); - for (Map<String, String> host2Component : host2Components) { - assertNotNull(host2Component); - assertEquals(1, host2Component.size()); - String componentName = host2Component.get("name"); - assertNotNull(componentName); - componentNames2.add(componentName); - } - assertEquals(2, componentNames2.size()); - assertTrue(componentNames2.contains("component2")); - assertTrue(componentNames2.contains("component3")); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/d7fcd258/ambari-server/src/test/python/stacks/2.0.6/common/test_stack_advisor.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.0.6/common/test_stack_advisor.py b/ambari-server/src/test/python/stacks/2.0.6/common/test_stack_advisor.py index bae5ef8..1f5549b 100644 --- a/ambari-server/src/test/python/stacks/2.0.6/common/test_stack_advisor.py +++ b/ambari-server/src/test/python/stacks/2.0.6/common/test_stack_advisor.py @@ -302,7 +302,7 @@ class TestHDP206StackAdvisor(TestCase): "amMemory": 512 } - result = self.stackAdvisor.getConfigurationClusterSummary(servicesList, hosts, components) + result = self.stackAdvisor.getConfigurationClusterSummary(servicesList, hosts, components, None) self.assertEquals(result, expected) @@ -344,7 +344,7 @@ class TestHDP206StackAdvisor(TestCase): "amMemory": 3072 } - result = self.stackAdvisor.getConfigurationClusterSummary(servicesList, hosts, components) + result = self.stackAdvisor.getConfigurationClusterSummary(servicesList, hosts, components, None) self.assertEquals(result, expected) @@ -402,7 +402,7 @@ class TestHDP206StackAdvisor(TestCase): hosts = { "items" : [] } - result = self.stackAdvisor.getConfigurationClusterSummary(servicesList, hosts, components) + result = self.stackAdvisor.getConfigurationClusterSummary(servicesList, hosts, components, None) expected = { "hBaseInstalled": False, @@ -530,7 +530,7 @@ class TestHDP206StackAdvisor(TestCase): } } - clusterData = self.stackAdvisor.getConfigurationClusterSummary(servicesList, hosts, components) + clusterData = self.stackAdvisor.getConfigurationClusterSummary(servicesList, hosts, components, None) self.assertEquals(clusterData['hbaseRam'], 8) self.stackAdvisor.recommendHbaseEnvConfigurations(configurations, clusterData, None, None) http://git-wip-us.apache.org/repos/asf/ambari/blob/d7fcd258/ambari-server/src/test/python/stacks/2.1/common/test_stack_advisor.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.1/common/test_stack_advisor.py b/ambari-server/src/test/python/stacks/2.1/common/test_stack_advisor.py index 11356a2..9a6b58d 100644 --- a/ambari-server/src/test/python/stacks/2.1/common/test_stack_advisor.py +++ b/ambari-server/src/test/python/stacks/2.1/common/test_stack_advisor.py @@ -191,7 +191,7 @@ class TestHDP21StackAdvisor(TestCase): } } - clusterData = self.stackAdvisor.getConfigurationClusterSummary(servicesList, hosts, components) + clusterData = self.stackAdvisor.getConfigurationClusterSummary(servicesList, hosts, components, None) self.assertEquals(clusterData['hbaseRam'], 8) self.stackAdvisor.recommendHbaseEnvConfigurations(configurations, clusterData, None, None) http://git-wip-us.apache.org/repos/asf/ambari/blob/d7fcd258/ambari-server/src/test/python/stacks/2.2/common/test_stack_advisor.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.2/common/test_stack_advisor.py b/ambari-server/src/test/python/stacks/2.2/common/test_stack_advisor.py index 5fbc945..76ecc96 100644 --- a/ambari-server/src/test/python/stacks/2.2/common/test_stack_advisor.py +++ b/ambari-server/src/test/python/stacks/2.2/common/test_stack_advisor.py @@ -644,6 +644,226 @@ class TestHDP22StackAdvisor(TestCase): self.stackAdvisor.recommendYARNConfigurations(configurations, clusterData, None, None) self.assertEquals(configurations, expected) + def test_recommendYARNConfigurationAttributes(self): + configurations = { + "yarn-env": { + "properties": { + "min_user_id": "500" + } + }, + "yarn-site": { + "properties": { + "yarn.nodemanager.resource.memory-mb": "1280", + "yarn.scheduler.minimum-allocation-mb": "256", + "yarn.scheduler.maximum-allocation-mb": "1280", + "yarn.nodemanager.resource.cpu-vcores": "2" + }, + } + } + clusterData = { + "cpu": 4, + "containers" : 5, + "ramPerContainer": 256 + } + expected = { + "yarn-env": { + "properties": { + "min_user_id": "500" + } + }, + "yarn-site": { + "properties": { + "yarn.nodemanager.resource.memory-mb": "1280", + "yarn.scheduler.minimum-allocation-mb": "256", + "yarn.scheduler.maximum-allocation-mb": "1280", + "yarn.nodemanager.resource.cpu-vcores": "2" + }, + "property_attributes": { + 'yarn.nodemanager.resource.memory-mb': {'max': '1877'}, + 'yarn.nodemanager.resource.cpu-vcores': {'max': '4'}, + 'yarn.scheduler.minimum-allocation-vcores': {'max': '2'}, + 'yarn.scheduler.maximum-allocation-vcores': {'max': '2'}, + 'yarn.scheduler.minimum-allocation-mb': {'max': '1280'}, + 'yarn.scheduler.maximum-allocation-mb': {'max': '1280'} + } + } + } + services = { + "services": [ + { + "href": "/api/v1/stacks/HDP/versions/2.2/services/YARN", + "StackServices": { + "service_name": "YARN", + "service_version": "2.6.0.2.2", + "stack_name": "HDP", + "stack_version": "2.2" + }, + "components": [ + { + "StackServiceComponents": { + "advertise_version": "false", + "cardinality": "1", + "component_category": "MASTER", + "component_name": "APP_TIMELINE_SERVER", + "display_name": "App Timeline Server", + "is_client": "false", + "is_master": "true", + "hostnames": [] + }, + "dependencies": [] + }, + { + "StackServiceComponents": { + "advertise_version": "true", + "cardinality": "1+", + "component_category": "SLAVE", + "component_name": "NODEMANAGER", + "display_name": "NodeManager", + "is_client": "false", + "is_master": "false", + "hostnames": [ + "c6403.ambari.apache.org" + ] + }, + "dependencies": [] + }, + { + "StackServiceComponents": { + "advertise_version": "true", + "cardinality": "1-2", + "component_category": "MASTER", + "component_name": "RESOURCEMANAGER", + "display_name": "ResourceManager", + "is_client": "false", + "is_master": "true", + "hostnames": [] + }, + "dependencies": [] + }, + { + "StackServiceComponents": { + "advertise_version": "true", + "cardinality": "1+", + "component_category": "CLIENT", + "component_name": "YARN_CLIENT", + "display_name": "YARN Client", + "is_client": "true", + "is_master": "false", + "hostnames": [] + }, + "dependencies": [] + } + ] + }, + ], + "configurations": configurations, + "changed-configurations": [ + { + "type": "yarn-site", + "name": "yarn.nodemanager.resource.memory-mb" + }, + { + "type": "yarn-site", + "name": "yarn.scheduler.minimum-allocation-mb" + }, + { + "type": "yarn-site", + "name": "yarn.scheduler.maximum-allocation-mb" + }, + { + "type": "yarn-site", + "name": "yarn.nodemanager.resource.cpu-vcores" + }, + { + "type": "yarn-env", + "name": "min_user_id" + }, + ], + "depended-configurations": [ + { + "type" : "mapred-site", + "name" : "yarn.app.mapreduce.am.admin-command-opts" + }, { + "type" : "yarn-site", + "name" : "yarn.scheduler.maximum-allocation-mb" + }, { + "type" : "yarn-site", + "name" : "yarn.scheduler.minimum-allocation-mb" + }, { + "type" : "mapred-site", + "name" : "mapreduce.reduce.java.opts" + }, { + "type" : "mapred-site", + "name" : "mapreduce.map.java.opts" + }, { + "type" : "mapred-site", + "name" : "yarn.app.mapreduce.am.command-opts" + }, { + "type" : "mapred-site", + "name" : "yarn.app.mapreduce.am.resource.mb" + }, { + "type" : "yarn-site", + "name" : "yarn.nodemanager.resource.memory-mb" + }, { + "type" : "mapred-site", + "name" : "mapreduce.task.io.sort.mb" + }, { + "type" : "mapred-site", + "name" : "mapreduce.reduce.memory.mb" + }, { + "type" : "mapred-site", + "name" : "mapreduce.map.memory.mb" + } + ] + + } + hosts = { + "items" : [ + { + "href" : "/api/v1/hosts/c6401.ambari.apache.org", + "Hosts" : { + "cpu_count" : 1, + "host_name" : "c6401.ambari.apache.org", + "os_arch" : "x86_64", + "os_type" : "centos6", + "ph_cpu_count" : 1, + "public_host_name" : "c6401.ambari.apache.org", + "rack_info" : "/default-rack", + "total_mem" : 1922680 + } + }, + { + "href" : "/api/v1/hosts/c6402.ambari.apache.org", + "Hosts" : { + "cpu_count" : 1, + "host_name" : "c6402.ambari.apache.org", + "os_arch" : "x86_64", + "os_type" : "centos6", + "ph_cpu_count" : 1, + "public_host_name" : "c6402.ambari.apache.org", + "rack_info" : "/default-rack", + "total_mem" : 1922680 + } + }, + { + "href" : "/api/v1/hosts/c6403.ambari.apache.org", + "Hosts" : { + "cpu_count" : 1, + "host_name" : "c6403.ambari.apache.org", + "os_arch" : "x86_64", + "os_type" : "centos6", + "ph_cpu_count" : 1, + "public_host_name" : "c6403.ambari.apache.org", + "rack_info" : "/default-rack", + "total_mem" : 1922680 + } + } + ] + } + + self.stackAdvisor.recommendYARNConfigurations(configurations, clusterData, services, hosts) + self.assertEquals(configurations, expected) + def test_recommendAmsConfigurations(self): configurations = {} clusterData = {} @@ -730,7 +950,7 @@ class TestHDP22StackAdvisor(TestCase): } } - clusterData = self.stackAdvisor.getConfigurationClusterSummary(servicesList, hosts, components) + clusterData = self.stackAdvisor.getConfigurationClusterSummary(servicesList, hosts, components, None) self.assertEquals(clusterData['hbaseRam'], 8) self.stackAdvisor.recommendHbaseEnvConfigurations(configurations, clusterData, None, None) http://git-wip-us.apache.org/repos/asf/ambari/blob/d7fcd258/ambari-server/src/test/resources/stacks/HDP/2.0.6/services/YARN/configuration/yarn-site.xml ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/resources/stacks/HDP/2.0.6/services/YARN/configuration/yarn-site.xml b/ambari-server/src/test/resources/stacks/HDP/2.0.6/services/YARN/configuration/yarn-site.xml index de723a3..ccad7c0 100644 --- a/ambari-server/src/test/resources/stacks/HDP/2.0.6/services/YARN/configuration/yarn-site.xml +++ b/ambari-server/src/test/resources/stacks/HDP/2.0.6/services/YARN/configuration/yarn-site.xml @@ -69,15 +69,28 @@ </value-attributes> <depends-on> <property> - <type>yarn-site.xml</type> + <type>yarn-site</type> <name>new-yarn-property</name> </property> <property> - <type>global.xml</type> + <type>global</type> <name>yarn_heapsize</name> </property> </depends-on> </property> + <property> + <name>new-enhanced-yarn-property2</name> + <value>1024</value> + <description>some enhanced description.</description> + + <depends-on> + <property> + <type>yarn-site</type> + <name>new-enhanced-yarn-property</name> + </property> + </depends-on> + </property> + </configuration>
