You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ja...@apache.org on 2017/01/25 20:11:17 UTC

ambari git commit: Revert "AMBARI-19630: Ambari should accept stack version in format of x.x.x.x without the build level digits (dili)"

Repository: ambari
Updated Branches:
  refs/heads/trunk 3217fbc06 -> f571cebdb


Revert "AMBARI-19630: Ambari should accept stack version in format of x.x.x.x without the build level digits (dili)"

This reverts commit 21c18a78beb397da324c80d6943d55038167d855.


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

Branch: refs/heads/trunk
Commit: f571cebdb53666d54b3365307ef5da4af9eeb493
Parents: 3217fbc
Author: Jaimin Jetly <ja...@hortonworks.com>
Authored: Wed Jan 25 12:09:07 2017 -0800
Committer: Jaimin Jetly <ja...@hortonworks.com>
Committed: Wed Jan 25 12:09:07 2017 -0800

----------------------------------------------------------------------
 .../libraries/functions/get_stack_version.py    |  2 +-
 .../libraries/functions/version_select_util.py  |  5 +--
 .../src/test/python/TestVersionSelectUtil.py    | 40 --------------------
 3 files changed, 3 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/f571cebd/ambari-common/src/main/python/resource_management/libraries/functions/get_stack_version.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/libraries/functions/get_stack_version.py b/ambari-common/src/main/python/resource_management/libraries/functions/get_stack_version.py
index 463d61f..7274a59 100644
--- a/ambari-common/src/main/python/resource_management/libraries/functions/get_stack_version.py
+++ b/ambari-common/src/main/python/resource_management/libraries/functions/get_stack_version.py
@@ -85,7 +85,7 @@ def get_stack_version(package_name):
 
   stack_version = re.sub(package_name + ' - ', '', stack_output)
   stack_version = stack_version.rstrip()
-  match = re.match('[0-9]+.[0-9]+.[0-9]+.[0-9]+(-[0-9]+)?', stack_version)
+  match = re.match('[0-9]+.[0-9]+.[0-9]+.[0-9]+-[0-9]+', stack_version)
 
   if match is None:
     Logger.info('Failed to get extracted version with ' + stack_selector_path)

http://git-wip-us.apache.org/repos/asf/ambari/blob/f571cebd/ambari-common/src/main/python/resource_management/libraries/functions/version_select_util.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/libraries/functions/version_select_util.py b/ambari-common/src/main/python/resource_management/libraries/functions/version_select_util.py
index ff00a1f..615a0cd 100644
--- a/ambari-common/src/main/python/resource_management/libraries/functions/version_select_util.py
+++ b/ambari-common/src/main/python/resource_management/libraries/functions/version_select_util.py
@@ -67,9 +67,8 @@ def get_component_version(stack_name, component_name):
           raise Exception("Code is nonzero or output is empty")
 
         Logger.debug("Command: %s\nOutput: %s" % (get_stack_comp_version_cmd, str(out)))
-        matches = re.findall(r"( [\d\.]+(\-\d+)?)", out)
-        version = matches[0][0].strip() if matches and len(matches) > 0 and len(matches[0]) > 0 else None
-        Logger.debug("Version for component %s: %s" % (component_name, str(version)))
+        matches = re.findall(r"([\d\.]+\-\d+)", out)
+        version = matches[0] if matches and len(matches) > 0 else None
       except Exception, e:
         Logger.error("Could not determine stack version for component %s by calling '%s'. Return Code: %s, Output: %s." %
                      (component_name, get_stack_comp_version_cmd, str(code), str(out)))

http://git-wip-us.apache.org/repos/asf/ambari/blob/f571cebd/ambari-server/src/test/python/TestVersionSelectUtil.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/TestVersionSelectUtil.py b/ambari-server/src/test/python/TestVersionSelectUtil.py
index 5facf31..38798e2 100644
--- a/ambari-server/src/test/python/TestVersionSelectUtil.py
+++ b/ambari-server/src/test/python/TestVersionSelectUtil.py
@@ -97,43 +97,3 @@ class TestVersionSelectUtil(TestCase):
     self.assertEquals(version, stack_expected_version)
     version = self.module.get_component_version("HDP", "hadoop-hdfs-datanode")
     self.assertEquals(version, stack_expected_version)
-
-  @patch('__builtin__.open')
-  @patch("resource_management.core.shell.call")
-  @patch('os.path.exists')
-  @patch("resource_management.libraries.functions.stack_tools.get_stack_tool")
-  def test_get_component_version_no_build_ids(self, get_stack_tool_mock, os_path_exists_mock, call_mock, open_mock):
-    stack_expected_version = "2.2.1.0"
-
-    # Mock classes for reading from a file
-    class MagicFile(object):
-      allowed_names = set(["hive-server2",
-                           "zookeeper-server"])
-      def read(self, value):
-        return (value + " - " + stack_expected_version) if value in self.allowed_names else ("ERROR: Invalid package - " + value)
-
-      def __exit__(self, exc_type, exc_val, exc_tb):
-        pass
-
-      def __enter__(self):
-        return self
-    pass
-
-    class MagicFile1(MagicFile):
-      def read(self):
-        return super(MagicFile1, self).read("hive-server2")
-    class MagicFile2(MagicFile):
-      def read(self):
-        return super(MagicFile2, self).read("zookeeper-server")
-
-    get_stack_tool_mock.side_effect = [("hdp-select", "/usr/bin/hdp-select", "hdp-select"),
-                                       ("hdp-select", "/usr/bin/hdp-select", "hdp-select")]
-    os_path_exists_mock.side_effect = [False, True, True, True]
-    open_mock.side_effect = [MagicFile1(), MagicFile2()]
-    call_mock.side_effect = [(0, "value will come from MagicFile"), ] * 2
-
-    # Pass
-    version = self.module.get_component_version("HDP", "hive-server2")
-    self.assertEquals(version, stack_expected_version)
-    version = self.module.get_component_version("HDP", "zookeeper-server")
-    self.assertEquals(version, stack_expected_version)