Merge lp:~registry/charms/precise/apache2/apache-apt-update into lp:charms/apache2

Proposed by Chris Johnston
Status: Merged
Merged at revision: 54
Proposed branch: lp:~registry/charms/precise/apache2/apache-apt-update
Merge into: lp:charms/apache2
Diff against target: 56 lines (+9/-3)
2 files modified
hooks/hooks.py (+2/-0)
hooks/tests/test_balancer_hook.py (+7/-3)
To merge this branch: bzr merge lp:~registry/charms/precise/apache2/apache-apt-update
Reviewer Review Type Date Requested Status
Marco Ceppi (community) Approve
Celso Providelo (community) Approve
Review via email: mp+222846@code.launchpad.net

Commit message

Run apt-get update prior to apt-get install

Description of the change

The charm isn't running apt-get update prior to installing packages, so sometimes apt-get install fails.

To post a comment you must log in.
Revision history for this message
Celso Providelo (cprov) :
review: Approve
Revision history for this message
Marco Ceppi (marcoceppi) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/hooks.py'
2--- hooks/hooks.py 2014-02-08 15:03:11 +0000
3+++ hooks/hooks.py 2014-06-11 17:25:08 +0000
4@@ -21,6 +21,7 @@
5 unit_get
6 )
7 from charmhelpers.contrib.charmsupport import nrpe
8+from charmhelpers.fetch import apt_update
9
10 ###############################################################################
11 # Global variables
12@@ -196,6 +197,7 @@
13 def install_hook():
14 if not os.path.exists(default_apache2_service_config_dir):
15 os.mkdir(default_apache2_service_config_dir, 0600)
16+ apt_update(fatal=True)
17 apt_get_install("python-jinja2")
18 install_status = apt_get_install("apache2")
19 if install_status == 0:
20
21=== modified file 'hooks/tests/test_balancer_hook.py'
22--- hooks/tests/test_balancer_hook.py 2014-01-16 12:33:28 +0000
23+++ hooks/tests/test_balancer_hook.py 2014-06-11 17:25:08 +0000
24@@ -502,7 +502,9 @@
25 @patch('os.mkdir')
26 @patch('hooks.apt_get_install')
27 @patch('hooks.log', MagicMock())
28- def test_installs_hook(self, apt_get_install, mkdir, exists, config_get):
29+ @patch('hooks.apt_update')
30+ def test_installs_hook(
31+ self, apt_update, apt_get_install, mkdir, exists, config_get):
32 exists.return_value = self.not_a_dir
33 config_get.return_value = None
34 apt_get_install.return_value = 'some result'
35@@ -523,8 +525,9 @@
36 @patch('os.mkdir')
37 @patch('hooks.apt_get_install')
38 @patch('hooks.log', MagicMock())
39+ @patch('hooks.apt_update')
40 def test_install_hook_installs_extra_packages(
41- self, apt_get_install, mkdir, exists, config_get):
42+ self, apt_update, apt_get_install, mkdir, exists, config_get):
43 exists.return_value = self.dir_exists
44 config_get.return_value = "extra"
45 apt_get_install.return_value = 'some result'
46@@ -543,8 +546,9 @@
47 @patch('os.mkdir')
48 @patch('hooks.apt_get_install')
49 @patch('hooks.log', MagicMock())
50+ @patch('hooks.apt_update')
51 def test_doesnt_create_dir_to_install_hooks_if_not_needed(
52- self, apt_get_install, mkdir, exists, config_get):
53+ self, apt_update, apt_get_install, mkdir, exists, config_get):
54 exists.return_value = self.dir_exists
55 config_get.return_value = None
56 apt_get_install.return_value = 'some result'

Subscribers

People subscribed via source and target branches