ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dmitriu...@apache.org
Subject [2/2] ambari git commit: AMBARI-21744. package_regex in get_package_from_available() can match (dlysnichenko)
Date Wed, 30 Aug 2017 11:02:17 GMT
AMBARI-21744. package_regex in get_package_from_available() can match (dlysnichenko)


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

Branch: refs/heads/branch-2.6
Commit: 890a5f584cc2e3c9489eb6f5ad98e3ec4a1a48df
Parents: 39bc724
Author: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Authored: Wed Aug 30 14:00:12 2017 +0300
Committer: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Committed: Wed Aug 30 14:01:31 2017 +0300

----------------------------------------------------------------------
 .../libraries/script/script.py                  |  3 +-
 .../custom_actions/TestInstallPackages.py       | 30 +++++++++-----------
 2 files changed, 16 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/890a5f58/ambari-common/src/main/python/resource_management/libraries/script/script.py
----------------------------------------------------------------------
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 313b666..9b1e500 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
@@ -452,10 +452,11 @@ class Script(object):
     if STACK_VERSION_PLACEHOLDER not in name:
       return name
     package_delimiter = '-' if OSCheck.is_ubuntu_family() else '_'
-    package_regex = name.replace(STACK_VERSION_PLACEHOLDER, '(\d|{0})+'.format(package_delimiter))
+    package_regex = name.replace(STACK_VERSION_PLACEHOLDER, '(\d|{0})+'.format(package_delimiter))
+ "$"
     for package in available_packages_in_repos:
       if re.match(package_regex, package):
         return package
+    Logger.warning("No package found for {0}({1})".format(name, package_regex))
 
 
   def format_package_name(self, name, repo_version=None):

http://git-wip-us.apache.org/repos/asf/ambari/blob/890a5f58/ambari-server/src/test/python/custom_actions/TestInstallPackages.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/custom_actions/TestInstallPackages.py b/ambari-server/src/test/python/custom_actions/TestInstallPackages.py
index de2cced..a946fdd 100644
--- a/ambari-server/src/test/python/custom_actions/TestInstallPackages.py
+++ b/ambari-server/src/test/python/custom_actions/TestInstallPackages.py
@@ -149,7 +149,6 @@ class TestInstallPackages(RMFTestCase):
       self.assertResourceCalled('Package', 'ambari-log4j', action=["upgrade"], retry_count=5,
retry_on_repo_unavailability=False)
       self.assertNoMoreResources()
 
-  @patch("resource_management.libraries.functions.list_ambari_managed_repos.list_ambari_managed_repos")
   @patch("resource_management.core.providers.get_provider")
   @patch("resource_management.libraries.script.Script.put_structured_out")
   @patch("resource_management.libraries.functions.stack_select.get_stack_versions")
@@ -161,7 +160,7 @@ class TestInstallPackages(RMFTestCase):
                             write_actual_version_to_history_file_mock,
                             read_actual_version_from_history_file_mock,
                             stack_versions_mock,
-                            put_structured_out_mock, get_provider, list_ambari_managed_repos_mock):
+                            put_structured_out_mock, get_provider):
     stack_versions_mock.side_effect = [
       [],  # before installation attempt
       [VERSION_STUB]
@@ -176,9 +175,8 @@ class TestInstallPackages(RMFTestCase):
     from resource_management.core.providers.package.yumrpm import YumProvider
     provider = YumProvider(None)
     with patch.object(provider, "_lookup_packages") as lookup_packages:
-      lookup_packages.side_effect = TestInstallPackages._add_packages
+      lookup_packages.side_effect = TestInstallPackages._add_packages_available
       get_provider.return_value = provider
-      list_ambari_managed_repos_mock.return_value=[]
       self.executeScript("scripts/install_packages.py",
                          classname="InstallPackages",
                          command="actionexecute",
@@ -580,7 +578,7 @@ class TestInstallPackages(RMFTestCase):
     from resource_management.core.providers.package.yumrpm import YumProvider
     provider = YumProvider(None)
     with patch.object(provider, "_lookup_packages") as lookup_packages:
-      lookup_packages.side_effect = TestInstallPackages._add_packages
+      lookup_packages.side_effect = TestInstallPackages._add_packages_available
       get_provider.return_value = provider
       list_ambari_managed_repos_mock.return_value = []
       self.executeScript("scripts/install_packages.py",
@@ -615,7 +613,7 @@ class TestInstallPackages(RMFTestCase):
 
       command_json['repositoryFile']['repoVersion'] = VERSION_STUB
 
-      lookup_packages.side_effect = TestInstallPackages._add_packages
+      lookup_packages.side_effect = TestInstallPackages._add_packages_available
       list_ambari_managed_repos_mock.return_value = []
       self.executeScript("scripts/install_packages.py",
                          classname="InstallPackages",
@@ -664,7 +662,7 @@ class TestInstallPackages(RMFTestCase):
     from resource_management.core.providers.package.yumrpm import YumProvider
     provider = YumProvider(None)
     with patch.object(provider, "_lookup_packages") as lookup_packages:
-      lookup_packages.side_effect = TestInstallPackages._add_packages
+      lookup_packages.side_effect = TestInstallPackages._add_packages_available
       get_provider.return_value = provider
       list_ambari_managed_repos_mock.return_value = []
 
@@ -766,7 +764,7 @@ class TestInstallPackages(RMFTestCase):
 
       command_json['repositoryFile']['repoVersion'] = VERSION_STUB
 
-      lookup_packages.side_effect = TestInstallPackages._add_packages
+      lookup_packages.side_effect = TestInstallPackages._add_packages_available
       list_ambari_managed_repos_mock.return_value = []
       try:
         self.executeScript("scripts/install_packages.py",
@@ -816,7 +814,7 @@ class TestInstallPackages(RMFTestCase):
     from resource_management.core.providers.package.yumrpm import YumProvider
     provider = YumProvider(None)
     with patch.object(provider, "_lookup_packages") as lookup_packages:
-      lookup_packages.side_effect = TestInstallPackages._add_packages
+      lookup_packages.side_effect = TestInstallPackages._add_packages_available
       get_provider.return_value = provider
       list_ambari_managed_repos_mock.return_value = []
       self.executeScript("scripts/install_packages.py",
@@ -851,7 +849,7 @@ class TestInstallPackages(RMFTestCase):
 
       command_json['repositoryFile']['repoVersion'] = VERSION_STUB_WITHOUT_BUILD_NUMBER
 
-      lookup_packages.side_effect = TestInstallPackages._add_packages
+      lookup_packages.side_effect = TestInstallPackages._add_packages_available
       list_ambari_managed_repos_mock.return_value = []
       self.executeScript("scripts/install_packages.py",
                          classname="InstallPackages",
@@ -896,7 +894,7 @@ class TestInstallPackages(RMFTestCase):
     from resource_management.core.providers.package.yumrpm import YumProvider
     provider = YumProvider(None)
     with patch.object(provider, "_lookup_packages") as lookup_packages:
-      lookup_packages.side_effect = TestInstallPackages._add_packages
+      lookup_packages.side_effect = TestInstallPackages._add_packages_available
       get_provider.return_value = provider
       list_ambari_managed_repos_mock.return_value = []
       self.executeScript("scripts/install_packages.py",
@@ -931,7 +929,7 @@ class TestInstallPackages(RMFTestCase):
 
       command_json['roleParams']['repository_version'] = '2.2.0.1-500'  # User specified
wrong build number
 
-      lookup_packages.side_effect = TestInstallPackages._add_packages
+      lookup_packages.side_effect = TestInstallPackages._add_packages_available
       list_ambari_managed_repos_mock.return_value = []
       self.executeScript("scripts/install_packages.py",
                          classname="InstallPackages",
@@ -980,7 +978,7 @@ class TestInstallPackages(RMFTestCase):
     from resource_management.core.providers.package.yumrpm import YumProvider
     provider = YumProvider(None)
     with patch.object(provider, "_lookup_packages") as lookup_packages:
-      lookup_packages.side_effect = TestInstallPackages._add_packages
+      lookup_packages.side_effect = TestInstallPackages._add_packages_available
       get_provider.return_value = provider
       list_ambari_managed_repos_mock.return_value = []
       try:
@@ -1020,7 +1018,7 @@ class TestInstallPackages(RMFTestCase):
 
       command_json['roleParams']['repository_version'] = VERSION_STUB
 
-      lookup_packages.side_effect = TestInstallPackages._add_packages
+      lookup_packages.side_effect = TestInstallPackages._add_packages_available
       list_ambari_managed_repos_mock.return_value = []
       try:
         self.executeScript("scripts/install_packages.py",
@@ -1070,7 +1068,7 @@ class TestInstallPackages(RMFTestCase):
     from resource_management.core.providers.package.yumrpm import YumProvider
     provider = YumProvider(None)
     with patch.object(provider, "_lookup_packages") as lookup_packages:
-      lookup_packages.side_effect = TestInstallPackages._add_packages
+      lookup_packages.side_effect = TestInstallPackages._add_packages_available
       get_provider.return_value = provider
       list_ambari_managed_repos_mock.return_value = []
       self.executeScript("scripts/install_packages.py",
@@ -1106,7 +1104,7 @@ class TestInstallPackages(RMFTestCase):
       command_json['roleParams']['repository_version'] = VERSION_STUB
       command_json['roleParams']['repository_version_id'] = '2'
 
-      lookup_packages.side_effect = TestInstallPackages._add_packages
+      lookup_packages.side_effect = TestInstallPackages._add_packages_available
       list_ambari_managed_repos_mock.return_value = []
       self.executeScript("scripts/install_packages.py",
                          classname="InstallPackages",


Mime
View raw message