You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ha...@apache.org on 2018/05/02 06:38:57 UTC

[ambari] 01/03: Revert "fix UT and issues from review"

This is an automated email from the ASF dual-hosted git repository.

hapylestat pushed a commit to branch revert-1136-in-work/trunk/AMBARI-23717
in repository https://gitbox.apache.org/repos/asf/ambari.git

commit b76b1a7018a2aa17d7bf9cc4f91d87c4fa9a53b8
Author: Dmytro Grinenko <ha...@gmail.com>
AuthorDate: Wed May 2 09:38:54 2018 +0300

    Revert "fix UT and issues from review"
    
    This reverts commit a9ed08134716a41a4feee07f50c8954c306f3117.
---
 .../ambari_commons/repo_manager/apt_manager.py     |  2 +-
 .../ambari_commons/repo_manager/yum_manager.py     |  2 +-
 .../ambari_commons/repo_manager/zypper_manager.py  |  2 +-
 .../resource_management/libraries/script/script.py |  2 --
 .../python/custom_actions/TestInstallPackages.py   | 37 +++++++++++-----------
 5 files changed, 22 insertions(+), 23 deletions(-)

diff --git a/ambari-common/src/main/python/ambari_commons/repo_manager/apt_manager.py b/ambari-common/src/main/python/ambari_commons/repo_manager/apt_manager.py
index 9f4330a..fdee179 100644
--- a/ambari-common/src/main/python/ambari_commons/repo_manager/apt_manager.py
+++ b/ambari-common/src/main/python/ambari_commons/repo_manager/apt_manager.py
@@ -223,7 +223,7 @@ class AptManager(GenericManager):
     apt_sources_list_tmp_dir = None
 
     if not name:
-      raise ValueError("Installation command was executed with no package name")
+      raise ValueError("Installation command were executed with no package name passed")
     elif context.is_upgrade or context.use_repos or not self._check_existence(name):
       cmd = self.properties.install_cmd[context.log_output]
       copied_sources_files = []
diff --git a/ambari-common/src/main/python/ambari_commons/repo_manager/yum_manager.py b/ambari-common/src/main/python/ambari_commons/repo_manager/yum_manager.py
index 7df4632..0f056ba 100644
--- a/ambari-common/src/main/python/ambari_commons/repo_manager/yum_manager.py
+++ b/ambari-common/src/main/python/ambari_commons/repo_manager/yum_manager.py
@@ -207,7 +207,7 @@ class YumManager(GenericManager):
     """
 
     if not name:
-      raise ValueError("Installation command was executed with no package name")
+      raise ValueError("Installation command were executed with no package name passed")
     elif context.is_upgrade or context.use_repos or not self._check_existence(name):
       cmd = self.properties.install_cmd[context.log_output]
       if context.use_repos:
diff --git a/ambari-common/src/main/python/ambari_commons/repo_manager/zypper_manager.py b/ambari-common/src/main/python/ambari_commons/repo_manager/zypper_manager.py
index 8d901c2..592e7c8 100644
--- a/ambari-common/src/main/python/ambari_commons/repo_manager/zypper_manager.py
+++ b/ambari-common/src/main/python/ambari_commons/repo_manager/zypper_manager.py
@@ -182,7 +182,7 @@ class ZypperManager(GenericManager):
     :raise ValueError if name is empty
     """
     if not name:
-      raise ValueError("Installation command was executed with no package name")
+      raise ValueError("Installation command were executed with no package name passed")
     elif context.is_upgrade or context.use_repos or not self._check_existence(name):
       cmd = self.properties.install_cmd[context.log_output]
 
diff --git a/ambari-common/src/main/python/resource_management/libraries/script/script.py b/ambari-common/src/main/python/resource_management/libraries/script/script.py
index 1ddc49a..60aac9c 100644
--- a/ambari-common/src/main/python/resource_management/libraries/script/script.py
+++ b/ambari-common/src/main/python/resource_management/libraries/script/script.py
@@ -783,8 +783,6 @@ class Script(object):
       Logger.exception("Unable to load available packages")
       self.available_packages_in_repos = []
 
-    return self.available_packages_in_repos
-
 
   def install_packages(self, env):
     """
diff --git a/ambari-server/src/test/python/custom_actions/TestInstallPackages.py b/ambari-server/src/test/python/custom_actions/TestInstallPackages.py
index 6e04938..7efe226 100644
--- a/ambari-server/src/test/python/custom_actions/TestInstallPackages.py
+++ b/ambari-server/src/test/python/custom_actions/TestInstallPackages.py
@@ -49,14 +49,14 @@ class TestInstallPackages(RMFTestCase):
     self.maxDiff = None
 
   @staticmethod
-  def _add_packages(*args, **kwargs):
+  def _add_packages(*args):
     return [
       ["pkg1", "1.0", "repo"],
       ["pkg2", "2.0", "repo2"]
     ]
 
   @staticmethod
-  def _add_packages_available(*args, **kwargs):
+  def _add_packages_available(*args):
     return [
       ["hadoop_2_2_0_1_885", "1.0", "HDP-2.2"],
       ["hadooplzo_2_2_0_1_885", "1.0", "HDP-2.2"],
@@ -64,8 +64,8 @@ class TestInstallPackages(RMFTestCase):
     ]
 
   @staticmethod
-  def _add_packages_lookUpYum(*args, **kwargs):
-    return TestInstallPackages._add_packages_available(*args, **kwargs)
+  def _add_packages_lookUpYum(*args):
+    return TestInstallPackages._add_packages_available(*args)
 
   def test_get_installed_package_version(self):
     from ambari_commons.os_check import OSConst
@@ -185,18 +185,18 @@ class TestInstallPackages(RMFTestCase):
 
       get_provider.return_value = pkg_manager
 
-      try:
-        self.executeScript("scripts/install_packages.py",
-                           classname="InstallPackages",
-                           command="actionexecute",
-                           config_dict = command_json,
-                           target=RMFTestCase.TARGET_CUSTOM_ACTIONS,
-                           os_type=('Redhat', '6.4', 'Final'),
-        )
-      except Fail as e:
-        self.assertEquals(e.message, "Failed to distribute repositories/install packages")
-      else:
-        self.assertFalse("Packages can't be installed without repos")
+      self.executeScript("scripts/install_packages.py",
+                         classname="InstallPackages",
+                         command="actionexecute",
+                         config_dict = command_json,
+                         target=RMFTestCase.TARGET_CUSTOM_ACTIONS,
+                         os_type=('Redhat', '6.4', 'Final'),
+      )
+      self.assertTrue(put_structured_out_mock.called)
+      self.assertEquals(put_structured_out_mock.call_args[0][0],
+                        {'package_installation_result': 'SUCCESS',
+                         'repository_version_id': 1,
+                         'actual_version': VERSION_STUB})
 
       self.assertNoMoreResources()
 
@@ -339,7 +339,7 @@ class TestInstallPackages(RMFTestCase):
   _install_failed = False
 
   @staticmethod
-  def _add_packages_with_fail(*args, **kwargs):
+  def _add_packages_with_fail():
     arg = []
     arg.append(["pkg1_2_2_0_1_885_pack", "1.0", "repo"])
     arg.append(["pkg2_2_2_0_1_885_pack2", "2.0", "repo2"])
@@ -400,7 +400,8 @@ class TestInstallPackages(RMFTestCase):
       self.assertTrue(put_structured_out_mock.called)
       self.assertEquals(put_structured_out_mock.call_args[0][0],
                         {'repository_version_id': 1,
-                        'package_installation_result': 'FAIL'})
+                        'package_installation_result': 'FAIL',
+                         'actual_version': '2.2.0.1-885'})
       self.assertResourceCalled('Repository', 'HDP-UTILS-1.1.0.20',
                                 base_url=u'http://repo1/HDP/centos5/2.x/updates/2.2.0.0',
                                 action=['create'],

-- 
To stop receiving notification emails like this one, please contact
hapylestat@apache.org.