ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonathanhur...@apache.org
Subject [13/50] [abbrv] ambari git commit: AMBARI-14966: Stack Advisor incorrectly recommends Slave component on a host which does not have it installed during Add service wizard (bhuvnesh2703 via jaoki)
Date Tue, 16 Feb 2016 18:30:18 GMT
AMBARI-14966: Stack Advisor incorrectly recommends Slave component on a host which does not
have it installed during Add service wizard (bhuvnesh2703 via jaoki)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/8aab6327
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/8aab6327
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/8aab6327

Branch: refs/heads/branch-dev-patch-upgrade
Commit: 8aab63270ebfe34aa75c47a150fbb4a1838d0ec1
Parents: 6c6ec63
Author: Jun Aoki <jaoki@apache.org>
Authored: Thu Feb 11 17:05:46 2016 -0800
Committer: Jun Aoki <jaoki@apache.org>
Committed: Thu Feb 11 17:05:46 2016 -0800

----------------------------------------------------------------------
 .../src/main/resources/stacks/stack_advisor.py  |  3 +-
 .../stacks/2.0.6/common/test_stack_advisor.py   | 59 ++++++++++++++++++++
 2 files changed, 61 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/8aab6327/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 d993feb..539bd25 100644
--- a/ambari-server/src/main/resources/stacks/stack_advisor.py
+++ b/ambari-server/src/main/resources/stacks/stack_advisor.py
@@ -409,7 +409,8 @@ class DefaultStackAdvisor(StackAdvisor):
                 hostsMin = int(cardinality)
               if hostsMin > len(hostsForComponent):
                 hostsForComponent.extend(freeHosts[0:hostsMin-len(hostsForComponent)])
-            else:
+            # Components which are already installed, keep the recommendation as the existing
layout
+            elif not componentIsPopulated:
               hostsForComponent.extend(freeHosts)
               if not hostsForComponent:  # hostsForComponent is empty
                 hostsForComponent = hostsList[-1:]

http://git-wip-us.apache.org/repos/asf/ambari/blob/8aab6327/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 22b16bb..4f059ba 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
@@ -1941,3 +1941,62 @@ class TestHDP206StackAdvisor(TestCase):
     siteProperties = stack_advisor.getServicesSiteProperties(services, "ranger-admin-site")
     self.assertEquals(siteProperties, expected)
 
+  def test_createComponentLayoutRecommendations_addService_1freeHost(self):
+    """
+    Test that already installed slaves are not added to any free hosts (not having any component
installed)
+    as part of recommendation received during Add service operation.
+    For already installed services, recommendation for installed components should match
the existing layout
+    """
+
+    services = {
+                  "services" : [
+                 {
+                    "StackServices" : {
+                      "service_name" : "HDFS"
+                    },
+                    "components" : [ {
+                      "StackServiceComponents" : {
+                        "cardinality" : "1+",
+                        "component_category" : "SLAVE",
+                        "component_name" : "DATANODE",
+                        "hostnames" : [ "c6401.ambari.apache.org" ]
+                      }
+                    } ]
+                 } ]
+              }
+
+    hosts = self.prepareHosts(["c6401.ambari.apache.org", "c6402.ambari.apache.org"])
+    recommendations = self.stackAdvisor.createComponentLayoutRecommendations(services, hosts)
+    """
+    Recommendation received should be as below:
+                               {
+                                  'blueprint': {
+                                          'host_groups': [{
+                                                  'name': 'host-group-1',
+                                                  'components': []
+                                          }, {
+                                                  'name': 'host-group-2',
+                                                  'components': [{
+                                                          'name': 'DATANODE'
+                                                  }]
+                                          }]
+                                  },
+                                  'blueprint_cluster_binding': {
+                                          'host_groups': [{
+                                                  'hosts': [{
+                                                          'fqdn': 'c6402.ambari.apache.org'
+                                                  }],
+                                                  'name': 'host-group-1'
+                                          }, {
+                                                  'hosts': [{
+                                                          'fqdn': 'c6401.ambari.apache.org'
+                                                  }],
+                                                  'name': 'host-group-2'
+                                          }]
+                                  }
+                           }
+    """
+    # Assert that the list is empty for host-group-1
+    self.assertFalse(recommendations['blueprint']['host_groups'][0]['components'])
+    # Assert that DATANODE is placed on host-group-2
+    self.assertEquals(recommendations['blueprint']['host_groups'][1]['components'][0]['name'],
'DATANODE')


Mime
View raw message