You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by dm...@apache.org on 2015/02/19 12:37:18 UTC
ambari git commit: AMBARI-9699. RU - Distribute repositories failed
during "Install Packages" in Ubuntu12 (dlysnichenko)
Repository: ambari
Updated Branches:
refs/heads/trunk 0c6ca6bb4 -> 3e50e06a2
AMBARI-9699. RU - Distribute repositories failed during "Install Packages" in Ubuntu12 (dlysnichenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/3e50e06a
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/3e50e06a
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/3e50e06a
Branch: refs/heads/trunk
Commit: 3e50e06a24c96d595e5edb015c37ae46723c5560
Parents: 0c6ca6b
Author: Lisnichenko Dmitro <dl...@hortonworks.com>
Authored: Thu Feb 19 13:36:18 2015 +0200
Committer: Lisnichenko Dmitro <dl...@hortonworks.com>
Committed: Thu Feb 19 13:36:18 2015 +0200
----------------------------------------------------------------------
.../TestRepositoryResource.py | 40 ++++++++++++++++++++
.../libraries/providers/repository.py | 2 +-
2 files changed, 41 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/3e50e06a/ambari-agent/src/test/python/resource_management/TestRepositoryResource.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/resource_management/TestRepositoryResource.py b/ambari-agent/src/test/python/resource_management/TestRepositoryResource.py
index 72fc8a3..37a9584 100644
--- a/ambari-agent/src/test/python/resource_management/TestRepositoryResource.py
+++ b/ambari-agent/src/test/python/resource_management/TestRepositoryResource.py
@@ -154,6 +154,46 @@ class TestRepositoryResource(TestCase):
self.assertEqual(checked_call_mock.call_args_list[0][0][0], ['apt-get', 'update', '-qq', '-o', 'Dir::Etc::sourcelist=sources.list.d/HDP.list', '-o', 'APT::Get::List-Cleanup=0'])
self.assertEqual(execute_command_item, 'apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 123ABCD')
+ @patch("resource_management.libraries.providers.repository.checked_call")
+ @patch.object(tempfile, "NamedTemporaryFile")
+ @patch("resource_management.libraries.providers.repository.Execute")
+ @patch("resource_management.libraries.providers.repository.File")
+ @patch("os.path.isfile", new=MagicMock(return_value=True))
+ @patch("filecmp.cmp", new=MagicMock(return_value=False))
+ @patch.object(System, "os_release_name", new='precise')
+ @patch.object(System, "os_family", new='ubuntu')
+ def test_create_repo_ubuntu_gpg_key_wrong_output(self, file_mock, execute_mock,
+ tempfile_mock, checked_call_mock):
+ """
+ Checks that GPG key is extracted from output without \r sign
+ """
+ tempfile_mock.return_value = MagicMock(spec=file)
+ tempfile_mock.return_value.__enter__.return_value.name = "/tmp/1.txt"
+ checked_call_mock.return_value = 0, "The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 123ABCD\r\n"
+
+ with Environment('/') as env:
+ with patch.object(repository,"Template", new=DummyTemplate.create(DEBIAN_DEFAUTL_TEMPLATE)):
+ Repository('HDP',
+ base_url='http://download.base_url.org/rpm/',
+ repo_file_name='HDP',
+ repo_template = "dummy.j2",
+ components = ['a','b','c']
+ )
+
+ call_content = file_mock.call_args_list[0]
+ template_name = call_content[0][0]
+ template_content = call_content[1]['content']
+
+ self.assertEquals(template_name, '/tmp/1.txt')
+ self.assertEquals(template_content, 'deb http://download.base_url.org/rpm/ a b c\n')
+
+ copy_item = str(file_mock.call_args_list[1])
+ self.assertEqual(copy_item, "call('/etc/apt/sources.list.d/HDP.list', content=StaticFile('/tmp/1.txt'))")
+ execute_command_item = execute_mock.call_args_list[0][0][0]
+
+ self.assertEqual(checked_call_mock.call_args_list[0][0][0], ['apt-get', 'update', '-qq', '-o', 'Dir::Etc::sourcelist=sources.list.d/HDP.list', '-o', 'APT::Get::List-Cleanup=0'])
+ self.assertEqual(execute_command_item, 'apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 123ABCD')
+
@patch.object(tempfile, "NamedTemporaryFile")
@patch("resource_management.libraries.providers.repository.Execute")
@patch("resource_management.libraries.providers.repository.File")
http://git-wip-us.apache.org/repos/asf/ambari/blob/3e50e06a/ambari-common/src/main/python/resource_management/libraries/providers/repository.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/libraries/providers/repository.py b/ambari-common/src/main/python/resource_management/libraries/providers/repository.py
index cca9f4d..9bd89ec 100644
--- a/ambari-common/src/main/python/resource_management/libraries/providers/repository.py
+++ b/ambari-common/src/main/python/resource_management/libraries/providers/repository.py
@@ -68,7 +68,7 @@ class UbuntuRepositoryProvider(Provider):
package_type = "deb"
repo_dir = "/etc/apt/sources.list.d"
update_cmd = ['apt-get', 'update', '-qq', '-o', 'Dir::Etc::sourcelist=sources.list.d/{repo_file_name}', '-o', 'APT::Get::List-Cleanup=0']
- missing_pkey_regex = "The following signatures couldn't be verified because the public key is not available: NO_PUBKEY (.+)"
+ missing_pkey_regex = "The following signatures couldn't be verified because the public key is not available: NO_PUBKEY ([A-Z0-9]+)"
add_pkey_cmd = "apt-key adv --recv-keys --keyserver keyserver.ubuntu.com {pkey}"
def action_create(self):