Merge lp:~evarlast/charms/trusty/apache2/trunk into lp:charms/trusty/apache2
- Trusty Tahr (14.04)
- trunk
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 69 |
Proposed branch: | lp:~evarlast/charms/trusty/apache2/trunk |
Merge into: | lp:charms/trusty/apache2 |
Diff against target: |
192 lines (+69/-10) 5 files modified
Makefile (+14/-3) config.yaml (+13/-0) hooks/hooks.py (+28/-1) hooks/tests/test_balancer_hook.py (+13/-6) hooks/tests/test_config_changed.py (+1/-0) |
To merge this branch: | bzr merge lp:~evarlast/charms/trusty/apache2/trunk |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Kevin W Monroe | Approve | ||
Jay R. Wren (community) | Needs Resubmitting | ||
Andrew McLeod (community) | Needs Fixing | ||
Adam Israel (community) | Needs Fixing | ||
Review Queue (community) | automated testing | Needs Fixing | |
Review via email: mp+278220@code.launchpad.net |
Commit message
Description of the change
Add apt config options to allow apache2 to be installed from a PPA. This enabled use of http2 supporting apache.
- 69. By Jay R. Wren
-
do not enable http2 by default
Review Queue (review-queue) wrote : | # |
Review Queue (review-queue) wrote : | # |
This item has failed automated testing! Results available here http://
Andrew McLeod (admcleod) wrote : | # |
Hi Jay,
In order to confirm your changes are fully functional, I've attempted to run bundletester (bundletester -e $AWS -l DEBUG -vF) on this.
It appears that there are initial failures related to apt-source, but because of the 'F' I see that there are also older issues related to assert_called_once (see: https:/
Unfortunately because tests are failing (as noted by the automated testing also) I can't approve this - however, perhaps they're passing for you? If so can you tell me more about your environment so I can try to replicate it - I'm using trusty.
Thanks!
Andrew
Andrew McLeod (admcleod) wrote : | # |
Jay,
I've just seen another RQ item from you where you've fixed some of those assert_called_once errors, but still failing on the following:
http://
I've put this same pastebin in your other RQ item.
Andrew
Adam Israel (aisrael) wrote : | # |
Hi Jay,
Just following up from our conversation on IRC yesterday. There are some failing tests here that are in the upstream, but new failing tests are introduced with this merge. Specifically:
=======
ERROR: tests.test_
-------
_StringException: Traceback (most recent call last):
File "/tmp/bundletes
return func(*args, **keywargs)
File "/tmp/bundletes
result = hooks.install_
File "/tmp/bundletes
open(
TypeError: expected a character buffer object
=======
ERROR: tests.test_
-------
_StringException: Traceback (most recent call last):
File "/tmp/bundletes
return func(*args, **keywargs)
File "/tmp/bundletes
hooks.
File "/tmp/bundletes
apt_source = config_
KeyError: 'apt-source'
- 70. By Jay R. Wren
-
fix tests which I broke
Jay R. Wren (evarlast) wrote : | # |
Thanks for this. I think I have fixed the required tests.
Please take another look.
Haw Loeung (hloeung) wrote : | # |
These are pretty bad defaults. We're adding the http://
I think the defaults for apt-key-id and apt-source should be empty.
Jay R. Wren (evarlast) wrote : | # |
Indeed! I intended them to be empty. Thank Haw.
- 71. By Jay R. Wren
-
default apt-key-id and apt-source to empty string
Andrew McLeod (admcleod) wrote : | # |
Hi Jay,
There are still tests failing (http://
Jay R. Wren (evarlast) wrote : | # |
Maybe someone can help me out with what changes in this MR cause these
tests to fail?
On Thu, Feb 11, 2016 at 6:01 PM, Andrew McLeod
<email address hidden> wrote:
> Review: Needs Fixing
>
> Hi Jay,
>
> There are still tests failing (http://
> --
> https:/
> You are the owner of lp:~evarlast/charms/trusty/apache2/trunk.
Kevin W Monroe (kwmonroe) wrote : | # |
Hey Jay - it's likely that nothing you did in this MP caused these failures. In fact, I'm quite certain that the 'assert_
That said, I agree with Andrew's desire to get tests passing before committing updates to a charm as important as apache2. If you have ideas on how to fix these test issues (even though you didn't introduce them), that would be much appreciated. If not, please at least hit the 'affects me too' on bug [0] to raise the heat.
Meanwhile, I'll try to poke on a test refactor to get around the assert_called_once errors, but we'll still need to dig into the other failures Andrew found in his latest pastebin.
[0] - https:/
Kevin W Monroe (kwmonroe) wrote : | # |
Hey Jay! I didn't realize when I pointed you at bug 1511474 that you already fixed it way back in November (which made it in with your add-logs-interface merge to apache2 today [0]).
That clears up all the apache2 errors that weren't your fault, but we're not out of the woods yet :) 'make test' with these changes merged into the new apache2 trunk branch yields:
=======
ERROR: tests.test_
-------
_StringException: Traceback (most recent call last):
File "/tmp/bundletes
return func(*args, **keywargs)
File "/tmp/bundletes
hooks.
File "/tmp/bundletes
old_apt_source = open('config.
IOError: [Errno 2] No such file or directory: 'config.apt-source'
This happens because install_hook() is the only place config.apt-source is written, and we're not invoking that in test_config_
...
relationsh
config_data = config_get()
+ apt_source = config_
+ try:
+ old_apt_source = open('config.
+ except IOError:
+ # File may not exist if install hook hasn't run (unlikely) or during
+ # ./hooks/
+ # assume if this file DNE, our old apt source == current apt config.
+ old_apt_source = apt_source
...
In the same method, do you need to write the new repo config to the config.apt-source file? Altering your diff like:
+ if old_apt_source != apt_source:
+ subprocess.
+ old_apt_source])
+ add_source(
+ open('config.
Otherwise, I don't think your "old_apt_source != apt_source" test will be accurate after changing that config.
One last morsel of awesome, test_config_
- }
+ "apt-source": "",
+ })
I know this MP has been a long time coming, and I *really* appreciate the fixes to apache2/trunk that you didn't cause. I think we're close with this one, but I want to get your input on these last few concerns of mine. Thanks!!
[0] - https:/
Kevin W Monroe (kwmonroe) : | # |
- 72. By Jay R. Wren
-
fix config changed handling of apt-source
Jay R. Wren (evarlast) wrote : | # |
Great catch @kevin.
I've updated to include suggested fixes.
- 73. By Jay R. Wren
-
merge parent
- 74. By Jay R. Wren
-
i knew that was bug
Kevin W Monroe (kwmonroe) wrote : | # |
Thanks for the updates Jay! Tests pass and I verified apt config settings are honored during both install and config-changed.
This has been merged into trusty/apache2. An updated charm should hit the store in about an hour. Thanks again for your patience during this review!
Preview Diff
1 | === modified file 'Makefile' | |||
2 | --- Makefile 2015-11-23 19:12:12 +0000 | |||
3 | +++ Makefile 2016-02-25 16:17:14 +0000 | |||
4 | @@ -17,8 +17,16 @@ | |||
5 | 17 | @(charm proof $(PWD) || [ $$? -eq 100 ]) && echo OK | 17 | @(charm proof $(PWD) || [ $$? -eq 100 ]) && echo OK |
6 | 18 | @test `cat revision` = 0 && rm revision | 18 | @test `cat revision` = 0 && rm revision |
7 | 19 | 19 | ||
10 | 20 | .venv: | 20 | /usr/bin/apt: |
11 | 21 | sudo apt-get install -y python-apt python-virtualenv python-jinja2 python-openssl | 21 | sudo apt-get install -y python-apt |
12 | 22 | |||
13 | 23 | /usr/bin/virtualenv: | ||
14 | 24 | sudo apt-get install -y python-virtualenv | ||
15 | 25 | |||
16 | 26 | /usr/lib/python2.7/dist-packages/jinja2: | ||
17 | 27 | sudo apt-get install -y python-jinja2 | ||
18 | 28 | |||
19 | 29 | .venv: /usr/bin/apt /usr/bin/virtualenv /usr/lib/python2.7/dist-packages/jinja2 | ||
20 | 22 | virtualenv .venv --system-site-packages | 30 | virtualenv .venv --system-site-packages |
21 | 23 | .venv/bin/pip install -I nose testtools mock pyyaml | 31 | .venv/bin/pip install -I nose testtools mock pyyaml |
22 | 24 | 32 | ||
23 | @@ -42,4 +50,7 @@ | |||
24 | 42 | -d hooks/charmhelpers | 50 | -d hooks/charmhelpers |
25 | 43 | @echo Do not forget to commit the updated files if any. | 51 | @echo Do not forget to commit the updated files if any. |
26 | 44 | 52 | ||
28 | 45 | .PHONY: revision proof .venv test lint sourcedeps charm-payload | 53 | clean: |
29 | 54 | rm -rf .venv | ||
30 | 55 | |||
31 | 56 | .PHONY: revision proof test lint sourcedeps charm-payload | ||
32 | 46 | 57 | ||
33 | === modified file 'config.yaml' | |||
34 | --- config.yaml 2015-08-11 19:06:25 +0000 | |||
35 | +++ config.yaml 2016-02-25 16:17:14 +0000 | |||
36 | @@ -193,3 +193,16 @@ | |||
37 | 193 | type: string | 193 | type: string |
38 | 194 | description: Comma seperated list of OpenID providers for authentication. | 194 | description: Comma seperated list of OpenID providers for authentication. |
39 | 195 | default: "" | 195 | default: "" |
40 | 196 | apt-key-id: | ||
41 | 197 | type: string | ||
42 | 198 | default: "" | ||
43 | 199 | description: A PGP key id. This is used with PPA and the source | ||
44 | 200 | option to import a PGP public key for verifying repository signatures. | ||
45 | 201 | This value must match the PPA for apt-source. | ||
46 | 202 | apt-source: | ||
47 | 203 | type: string | ||
48 | 204 | default: "" | ||
49 | 205 | description: From where to install packages. This is the PPA source line. | ||
50 | 206 | Note that due to a bug in software-properties add-apt-repository cannot | ||
51 | 207 | add the ondrej/apache2 ppa, so the default value here is a full | ||
52 | 208 | sources line. | ||
53 | 196 | 209 | ||
54 | === modified file 'hooks/hooks.py' | |||
55 | --- hooks/hooks.py 2016-02-18 18:08:34 +0000 | |||
56 | +++ hooks/hooks.py 2016-02-25 16:17:14 +0000 | |||
57 | @@ -25,7 +25,7 @@ | |||
58 | 25 | unit_get | 25 | unit_get |
59 | 26 | ) | 26 | ) |
60 | 27 | from charmhelpers.contrib.charmsupport import nrpe | 27 | from charmhelpers.contrib.charmsupport import nrpe |
62 | 28 | from charmhelpers.fetch import apt_update | 28 | from charmhelpers.fetch import apt_update, add_source |
63 | 29 | 29 | ||
64 | 30 | ############################################################################### | 30 | ############################################################################### |
65 | 31 | # Global variables | 31 | # Global variables |
66 | @@ -289,6 +289,12 @@ | |||
67 | 289 | 289 | ||
68 | 290 | 290 | ||
69 | 291 | def install_hook(): | 291 | def install_hook(): |
70 | 292 | apt_source = config_get('apt-source') or '' | ||
71 | 293 | apt_key_id = config_get('apt-key-id') or False | ||
72 | 294 | open('config.apt-source', 'w').write(apt_source) | ||
73 | 295 | if apt_source and apt_key_id: | ||
74 | 296 | print apt_source + " and " + apt_key_id | ||
75 | 297 | add_source(apt_source, apt_key_id) | ||
76 | 292 | if not os.path.exists(default_apache2_service_config_dir): | 298 | if not os.path.exists(default_apache2_service_config_dir): |
77 | 293 | os.mkdir(default_apache2_service_config_dir, 0600) | 299 | os.mkdir(default_apache2_service_config_dir, 0600) |
78 | 294 | apt_update(fatal=True) | 300 | apt_update(fatal=True) |
79 | @@ -301,6 +307,15 @@ | |||
80 | 301 | ensure_package_status(service_affecting_packages, | 307 | ensure_package_status(service_affecting_packages, |
81 | 302 | config_get('package_status')) | 308 | config_get('package_status')) |
82 | 303 | ensure_extra_packages() | 309 | ensure_extra_packages() |
83 | 310 | # the apache2 deb does not yet have http2 module in mods-available. Add it. | ||
84 | 311 | open('/etc/apache2/mods-available/http2.load', 'w').write( | ||
85 | 312 | 'LoadModule http2_module /usr/lib/apache2/modules/mod_http2.so') | ||
86 | 313 | open('/etc/apache2/mods-available/http2.conf', 'w').write( | ||
87 | 314 | '''<IfModule http2_module> | ||
88 | 315 | ProtocolsHonorOrder On | ||
89 | 316 | Protocols h2 http/1.1 | ||
90 | 317 | </IfModule> | ||
91 | 318 | ''') | ||
92 | 304 | return install_status | 319 | return install_status |
93 | 305 | 320 | ||
94 | 306 | 321 | ||
95 | @@ -585,6 +600,18 @@ | |||
96 | 585 | relationship_data = {} | 600 | relationship_data = {} |
97 | 586 | config_data = config_get() | 601 | config_data = config_get() |
98 | 587 | 602 | ||
99 | 603 | apt_source = config_data['apt-source'] | ||
100 | 604 | old_apt_source = '' | ||
101 | 605 | try: | ||
102 | 606 | old_apt_source = open('config.apt-source', 'r').read() | ||
103 | 607 | except: | ||
104 | 608 | pass | ||
105 | 609 | if old_apt_source != apt_source: | ||
106 | 610 | subprocess.check_call(['add-apt-repository', '--yes', '-r', | ||
107 | 611 | old_apt_source]) | ||
108 | 612 | add_source(apt_source, config_data['apt-key-id']) | ||
109 | 613 | open('config.apt-source', 'w').write(apt_source) | ||
110 | 614 | |||
111 | 588 | ensure_package_status(service_affecting_packages, | 615 | ensure_package_status(service_affecting_packages, |
112 | 589 | config_data['package_status']) | 616 | config_data['package_status']) |
113 | 590 | ensure_extra_packages() | 617 | ensure_extra_packages() |
114 | 591 | 618 | ||
115 | === modified file 'hooks/tests/test_balancer_hook.py' | |||
116 | --- hooks/tests/test_balancer_hook.py 2014-12-29 22:59:20 +0000 | |||
117 | +++ hooks/tests/test_balancer_hook.py 2016-02-25 16:17:14 +0000 | |||
118 | @@ -497,6 +497,7 @@ | |||
119 | 497 | if os.path.exists(self.log_path): | 497 | if os.path.exists(self.log_path): |
120 | 498 | os.remove(self.log_path) | 498 | os.remove(self.log_path) |
121 | 499 | 499 | ||
122 | 500 | @patch('hooks.open') | ||
123 | 500 | @patch('hooks.config_get') | 501 | @patch('hooks.config_get') |
124 | 501 | @patch('os.path.exists') | 502 | @patch('os.path.exists') |
125 | 502 | @patch('os.mkdir') | 503 | @patch('os.mkdir') |
126 | @@ -504,7 +505,8 @@ | |||
127 | 504 | @patch('hooks.log', MagicMock()) | 505 | @patch('hooks.log', MagicMock()) |
128 | 505 | @patch('hooks.apt_update') | 506 | @patch('hooks.apt_update') |
129 | 506 | def test_installs_hook( | 507 | def test_installs_hook( |
131 | 507 | self, apt_update, apt_get_install, mkdir, exists, config_get): | 508 | self, apt_update, apt_get_install, mkdir, exists, config_get, |
132 | 509 | open): | ||
133 | 508 | exists.return_value = self.not_a_dir | 510 | exists.return_value = self.not_a_dir |
134 | 509 | config_get.return_value = None | 511 | config_get.return_value = None |
135 | 510 | apt_get_install.return_value = 'some result' | 512 | apt_get_install.return_value = 'some result' |
136 | @@ -523,19 +525,22 @@ | |||
137 | 523 | call('apache2'), | 525 | call('apache2'), |
138 | 524 | ]) | 526 | ]) |
139 | 525 | 527 | ||
141 | 526 | @patch('hooks.config_get') | 528 | @patch('hooks.open') |
142 | 527 | @patch('os.path.exists') | 529 | @patch('os.path.exists') |
143 | 528 | @patch('os.mkdir') | 530 | @patch('os.mkdir') |
144 | 529 | @patch('hooks.apt_get_install') | 531 | @patch('hooks.apt_get_install') |
145 | 530 | @patch('hooks.log', MagicMock()) | 532 | @patch('hooks.log', MagicMock()) |
146 | 531 | @patch('hooks.apt_update') | 533 | @patch('hooks.apt_update') |
147 | 532 | def test_install_hook_installs_extra_packages( | 534 | def test_install_hook_installs_extra_packages( |
149 | 533 | self, apt_update, apt_get_install, mkdir, exists, config_get): | 535 | self, apt_update, apt_get_install, mkdir, exists, |
150 | 536 | open): | ||
151 | 534 | exists.return_value = self.dir_exists | 537 | exists.return_value = self.dir_exists |
153 | 535 | config_get.return_value = "extra" | 538 | c = {'extra_packages': 'extra', 'apt-source': '', 'apt-key-id': ''} |
154 | 539 | config_get = MagicMock(wraps=c.get) | ||
155 | 536 | apt_get_install.return_value = 'some result' | 540 | apt_get_install.return_value = 'some result' |
156 | 537 | 541 | ||
158 | 538 | result = hooks.install_hook() | 542 | with patch('hooks.config_get', config_get): |
159 | 543 | result = hooks.install_hook() | ||
160 | 539 | 544 | ||
161 | 540 | self.assertEqual(result, 'some result') | 545 | self.assertEqual(result, 'some result') |
162 | 541 | apt_get_install.assert_has_calls([ | 546 | apt_get_install.assert_has_calls([ |
163 | @@ -547,6 +552,7 @@ | |||
164 | 547 | call('extra'), | 552 | call('extra'), |
165 | 548 | ]) | 553 | ]) |
166 | 549 | 554 | ||
167 | 555 | @patch('hooks.open') | ||
168 | 550 | @patch('hooks.config_get') | 556 | @patch('hooks.config_get') |
169 | 551 | @patch('os.path.exists') | 557 | @patch('os.path.exists') |
170 | 552 | @patch('os.mkdir') | 558 | @patch('os.mkdir') |
171 | @@ -554,7 +560,8 @@ | |||
172 | 554 | @patch('hooks.log', MagicMock()) | 560 | @patch('hooks.log', MagicMock()) |
173 | 555 | @patch('hooks.apt_update') | 561 | @patch('hooks.apt_update') |
174 | 556 | def test_doesnt_create_dir_to_install_hooks_if_not_needed( | 562 | def test_doesnt_create_dir_to_install_hooks_if_not_needed( |
176 | 557 | self, apt_update, apt_get_install, mkdir, exists, config_get): | 563 | self, apt_update, apt_get_install, mkdir, exists, config_get, |
177 | 564 | open): | ||
178 | 558 | exists.return_value = self.dir_exists | 565 | exists.return_value = self.dir_exists |
179 | 559 | config_get.return_value = None | 566 | config_get.return_value = None |
180 | 560 | apt_get_install.return_value = 'some result' | 567 | apt_get_install.return_value = 'some result' |
181 | 561 | 568 | ||
182 | === modified file 'hooks/tests/test_config_changed.py' | |||
183 | --- hooks/tests/test_config_changed.py 2015-11-23 19:12:12 +0000 | |||
184 | +++ hooks/tests/test_config_changed.py 2016-02-25 16:17:14 +0000 | |||
185 | @@ -67,6 +67,7 @@ | |||
186 | 67 | "servername": "foobar", | 67 | "servername": "foobar", |
187 | 68 | "vhost_http_template": "", | 68 | "vhost_http_template": "", |
188 | 69 | "vhost_https_template": "", | 69 | "vhost_https_template": "", |
189 | 70 | "apt-source": "", | ||
190 | 70 | }) | 71 | }) |
191 | 71 | base = patch.object(hooks, 'default_apache_base_dir', self.dirname) | 72 | base = patch.object(hooks, 'default_apache_base_dir', self.dirname) |
192 | 72 | config22 = patch.object(hooks, 'default_apache22_config_dir', | 73 | config22 = patch.object(hooks, 'default_apache22_config_dir', |
This item has failed automated testing! Results available here http:// juju-ci. vapour. ws:8080/ job/charm- bundle- test-lxc/ 1486/