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:36:37 UTC
[ambari] 03/03: fix UT and issues from review
This is an automated email from the ASF dual-hosted git repository.
hapylestat pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git
commit a9ed08134716a41a4feee07f50c8954c306f3117
Author: Dmitry Grinenko <ha...@gmail.com>
AuthorDate: Wed May 2 08:30:36 2018 +0300
fix UT and issues from review
---
.../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, 23 insertions(+), 22 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 fdee179..9f4330a 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 were executed with no package name passed")
+ raise ValueError("Installation command was executed with no package name")
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 0f056ba..7df4632 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 were executed with no package name passed")
+ raise ValueError("Installation command was executed with no package name")
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 592e7c8..8d901c2 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 were executed with no package name passed")
+ raise ValueError("Installation command was executed with no package name")
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 60aac9c..1ddc49a 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,6 +783,8 @@ 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 7efe226..6e04938 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):
+ def _add_packages(*args, **kwargs):
return [
["pkg1", "1.0", "repo"],
["pkg2", "2.0", "repo2"]
]
@staticmethod
- def _add_packages_available(*args):
+ def _add_packages_available(*args, **kwargs):
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):
- return TestInstallPackages._add_packages_available(*args)
+ def _add_packages_lookUpYum(*args, **kwargs):
+ return TestInstallPackages._add_packages_available(*args, **kwargs)
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
- 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})
+ 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.assertNoMoreResources()
@@ -339,7 +339,7 @@ class TestInstallPackages(RMFTestCase):
_install_failed = False
@staticmethod
- def _add_packages_with_fail():
+ def _add_packages_with_fail(*args, **kwargs):
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,8 +400,7 @@ 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',
- 'actual_version': '2.2.0.1-885'})
+ 'package_installation_result': 'FAIL'})
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.