Merge lp:~ddellav/charms/trusty/nova-compute/upgrade-action into lp:~openstack-charmers-archive/charms/trusty/nova-compute/next
- Trusty Tahr (14.04)
- upgrade-action
- Merge into next
Status: | Merged |
---|---|
Merged at revision: | 174 |
Proposed branch: | lp:~ddellav/charms/trusty/nova-compute/upgrade-action |
Merge into: | lp:~openstack-charmers-archive/charms/trusty/nova-compute/next |
Diff against target: |
482 lines (+222/-33) 14 files modified
actions.yaml (+2/-0) actions/openstack_upgrade.py (+32/-0) config.yaml (+10/-0) hooks/charmhelpers/contrib/network/ip.py (+5/-3) hooks/charmhelpers/contrib/openstack/amulet/utils.py (+1/-1) hooks/charmhelpers/contrib/openstack/context.py (+15/-4) hooks/charmhelpers/contrib/openstack/neutron.py (+3/-3) hooks/charmhelpers/core/hookenv.py (+32/-0) hooks/nova_compute_hooks.py (+2/-2) hooks/nova_compute_utils.py (+1/-3) tests/charmhelpers/contrib/amulet/utils.py (+47/-16) tests/charmhelpers/contrib/openstack/amulet/utils.py (+1/-1) unit_tests/test_actions_openstack_upgrade.py (+62/-0) unit_tests/test_nova_compute_hooks.py (+9/-0) |
To merge this branch: | bzr merge lp:~ddellav/charms/trusty/nova-compute/upgrade-action |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Corey Bryant (community) | Approve | ||
Review via email: mp+273560@code.launchpad.net |
Commit message
Description of the change
Adding charmhelpers-based upgrade action to nova-compute.
uosci-testing-bot (uosci-testing-bot) wrote : | # |
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #10584 nova-compute-next for ddellav mp273560
UNIT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #10585 nova-compute-next for ddellav mp273560
UNIT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #11394 nova-compute-next for ddellav mp273560
LINT OK: passed
Build: http://
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #7141 nova-compute-next for ddellav mp273560
AMULET FAIL: amulet-test failed
AMULET Results (max last 2 lines):
make: *** [test] Error 1
ERROR:root:Make target returned non-zero.
Full amulet test output: http://
Build: http://
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #7140 nova-compute-next for ddellav mp273560
AMULET FAIL: amulet-test failed
AMULET Results (max last 2 lines):
make: *** [test] Error 1
ERROR:root:Make target returned non-zero.
Full amulet test output: http://
Build: http://
Corey Bryant (corey.bryant) wrote : | # |
Reviewed and tested successfully. I approve. Just waiting on amulet tests to pass before landing.
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #11425 nova-compute-next for ddellav mp273560
LINT OK: passed
Build: http://
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #10616 nova-compute-next for ddellav mp273560
UNIT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #7168 nova-compute-next for ddellav mp273560
AMULET FAIL: amulet-test failed
AMULET Results (max last 2 lines):
make: *** [test] Error 124
ERROR:root:Make target returned non-zero.
Full amulet test output: http://
Build: http://
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #10733 nova-compute-next for ddellav mp273560
UNIT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #11542 nova-compute-next for ddellav mp273560
LINT OK: passed
Build: http://
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #7243 nova-compute-next for ddellav mp273560
AMULET FAIL: amulet-test failed
AMULET Results (max last 2 lines):
make: *** [test] Error 1
ERROR:root:Make target returned non-zero.
Full amulet test output: http://
Build: http://
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #7258 nova-compute-next for ddellav mp273560
AMULET FAIL: amulet-test failed
AMULET Results (max last 2 lines):
make: *** [test] Error 1
ERROR:root:Make target returned non-zero.
Full amulet test output: http://
Build: http://
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #10797 nova-compute-next for ddellav mp273560
UNIT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #11608 nova-compute-next for ddellav mp273560
LINT OK: passed
Build: http://
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #11618 nova-compute-next for ddellav mp273560
LINT OK: passed
Build: http://
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #10807 nova-compute-next for ddellav mp273560
UNIT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #7266 nova-compute-next for ddellav mp273560
AMULET FAIL: amulet-test failed
AMULET Results (max last 2 lines):
make: *** [test] Error 1
ERROR:root:Make target returned non-zero.
Full amulet test output: http://
Build: http://
Corey Bryant (corey.bryant) wrote : | # |
The amulet failure is not related. Something is wrong with kilo deploying from source. So I'm going to merge this.
Preview Diff
1 | === modified file 'actions.yaml' |
2 | --- actions.yaml 2015-04-15 14:21:42 +0000 |
3 | +++ actions.yaml 2015-10-08 15:08:00 +0000 |
4 | @@ -1,2 +1,4 @@ |
5 | git-reinstall: |
6 | description: Reinstall nova-compute from the openstack-origin-git repositories. |
7 | +openstack-upgrade: |
8 | + description: Perform openstack upgrades. Config option action-managed-upgrade must be set to True. |
9 | |
10 | === added symlink 'actions/openstack-upgrade' |
11 | === target is u'openstack_upgrade.py' |
12 | === added file 'actions/openstack_upgrade.py' |
13 | --- actions/openstack_upgrade.py 1970-01-01 00:00:00 +0000 |
14 | +++ actions/openstack_upgrade.py 2015-10-08 15:08:00 +0000 |
15 | @@ -0,0 +1,32 @@ |
16 | +#!/usr/bin/python |
17 | +import sys |
18 | + |
19 | +sys.path.append('hooks/') |
20 | + |
21 | +from charmhelpers.contrib.openstack.utils import ( |
22 | + do_action_openstack_upgrade, |
23 | +) |
24 | + |
25 | +from nova_compute_utils import do_openstack_upgrade |
26 | + |
27 | +from nova_compute_hooks import ( |
28 | + config_changed, |
29 | + CONFIGS |
30 | +) |
31 | + |
32 | + |
33 | +def openstack_upgrade(): |
34 | + """Upgrade packages to config-set Openstack version. |
35 | + |
36 | + If the charm was installed from source we cannot upgrade it. |
37 | + For backwards compatibility a config flag must be set for this |
38 | + code to run, otherwise a full service level upgrade will fire |
39 | + on config-changed.""" |
40 | + |
41 | + if (do_action_openstack_upgrade('nova-common', |
42 | + do_openstack_upgrade, |
43 | + CONFIGS)): |
44 | + config_changed() |
45 | + |
46 | +if __name__ == '__main__': |
47 | + openstack_upgrade() |
48 | |
49 | === modified file 'config.yaml' |
50 | --- config.yaml 2015-10-02 09:40:38 +0000 |
51 | +++ config.yaml 2015-10-08 15:08:00 +0000 |
52 | @@ -265,3 +265,13 @@ |
53 | description: | |
54 | The pecentage of system memory to use for hugepages eg '10%' or the total |
55 | number of 2M hugepages - eg "1024". |
56 | + action-managed-upgrade: |
57 | + type: boolean |
58 | + default: False |
59 | + description: | |
60 | + If True enables openstack upgrades for this charm via juju actions. |
61 | + You will still need to set openstack-origin to the new repository but |
62 | + instead of an upgrade running automatically across all units, it will |
63 | + wait for you to execute the openstack-upgrade action for this charm on |
64 | + each unit. If False it will revert to existing behavior of upgrading |
65 | + all units on config change. |
66 | |
67 | === modified file 'hooks/charmhelpers/contrib/network/ip.py' |
68 | --- hooks/charmhelpers/contrib/network/ip.py 2015-09-02 15:03:16 +0000 |
69 | +++ hooks/charmhelpers/contrib/network/ip.py 2015-10-08 15:08:00 +0000 |
70 | @@ -23,7 +23,7 @@ |
71 | from functools import partial |
72 | |
73 | from charmhelpers.core.hookenv import unit_get |
74 | -from charmhelpers.fetch import apt_install |
75 | +from charmhelpers.fetch import apt_install, apt_update |
76 | from charmhelpers.core.hookenv import ( |
77 | log, |
78 | WARNING, |
79 | @@ -32,13 +32,15 @@ |
80 | try: |
81 | import netifaces |
82 | except ImportError: |
83 | - apt_install('python-netifaces') |
84 | + apt_update(fatal=True) |
85 | + apt_install('python-netifaces', fatal=True) |
86 | import netifaces |
87 | |
88 | try: |
89 | import netaddr |
90 | except ImportError: |
91 | - apt_install('python-netaddr') |
92 | + apt_update(fatal=True) |
93 | + apt_install('python-netaddr', fatal=True) |
94 | import netaddr |
95 | |
96 | |
97 | |
98 | === modified file 'hooks/charmhelpers/contrib/openstack/amulet/utils.py' |
99 | --- hooks/charmhelpers/contrib/openstack/amulet/utils.py 2015-09-28 07:56:16 +0000 |
100 | +++ hooks/charmhelpers/contrib/openstack/amulet/utils.py 2015-10-08 15:08:00 +0000 |
101 | @@ -752,7 +752,7 @@ |
102 | self.log.debug('SSL is enabled @{}:{} ' |
103 | '({})'.format(host, port, unit_name)) |
104 | return True |
105 | - elif not port and not conf_ssl: |
106 | + elif not conf_ssl: |
107 | self.log.debug('SSL not enabled @{}:{} ' |
108 | '({})'.format(host, port, unit_name)) |
109 | return False |
110 | |
111 | === modified file 'hooks/charmhelpers/contrib/openstack/context.py' |
112 | --- hooks/charmhelpers/contrib/openstack/context.py 2015-09-28 07:56:16 +0000 |
113 | +++ hooks/charmhelpers/contrib/openstack/context.py 2015-10-08 15:08:00 +0000 |
114 | @@ -14,6 +14,7 @@ |
115 | # You should have received a copy of the GNU Lesser General Public License |
116 | # along with charm-helpers. If not, see <http://www.gnu.org/licenses/>. |
117 | |
118 | +import glob |
119 | import json |
120 | import os |
121 | import re |
122 | @@ -1363,7 +1364,7 @@ |
123 | normalized.update({port: port for port in resolved |
124 | if port in ports}) |
125 | if resolved: |
126 | - return {bridge: normalized[port] for port, bridge in |
127 | + return {normalized[port]: bridge for port, bridge in |
128 | six.iteritems(portmap) if port in normalized.keys()} |
129 | |
130 | return None |
131 | @@ -1374,12 +1375,22 @@ |
132 | def __call__(self): |
133 | ctxt = {} |
134 | mappings = super(PhyNICMTUContext, self).__call__() |
135 | - if mappings and mappings.values(): |
136 | - ports = mappings.values() |
137 | + if mappings and mappings.keys(): |
138 | + ports = sorted(mappings.keys()) |
139 | napi_settings = NeutronAPIContext()() |
140 | mtu = napi_settings.get('network_device_mtu') |
141 | + all_ports = set() |
142 | + # If any of ports is a vlan device, its underlying device must have |
143 | + # mtu applied first. |
144 | + for port in ports: |
145 | + for lport in glob.glob("/sys/class/net/%s/lower_*" % port): |
146 | + lport = os.path.basename(lport) |
147 | + all_ports.add(lport.split('_')[1]) |
148 | + |
149 | + all_ports = list(all_ports) |
150 | + all_ports.extend(ports) |
151 | if mtu: |
152 | - ctxt["devs"] = '\\n'.join(ports) |
153 | + ctxt["devs"] = '\\n'.join(all_ports) |
154 | ctxt['mtu'] = mtu |
155 | |
156 | return ctxt |
157 | |
158 | === modified file 'hooks/charmhelpers/contrib/openstack/neutron.py' |
159 | --- hooks/charmhelpers/contrib/openstack/neutron.py 2015-08-25 17:40:00 +0000 |
160 | +++ hooks/charmhelpers/contrib/openstack/neutron.py 2015-10-08 15:08:00 +0000 |
161 | @@ -310,10 +310,10 @@ |
162 | def parse_data_port_mappings(mappings, default_bridge='br-data'): |
163 | """Parse data port mappings. |
164 | |
165 | - Mappings must be a space-delimited list of port:bridge mappings. |
166 | + Mappings must be a space-delimited list of bridge:port. |
167 | |
168 | - Returns dict of the form {port:bridge} where port may be an mac address or |
169 | - interface name. |
170 | + Returns dict of the form {port:bridge} where ports may be mac addresses or |
171 | + interface names. |
172 | """ |
173 | |
174 | # NOTE(dosaboy): we use rvalue for key to allow multiple values to be |
175 | |
176 | === modified file 'hooks/charmhelpers/core/hookenv.py' |
177 | --- hooks/charmhelpers/core/hookenv.py 2015-09-28 07:56:16 +0000 |
178 | +++ hooks/charmhelpers/core/hookenv.py 2015-10-08 15:08:00 +0000 |
179 | @@ -623,6 +623,38 @@ |
180 | return unit_get('private-address') |
181 | |
182 | |
183 | +@cached |
184 | +def storage_get(attribute="", storage_id=""): |
185 | + """Get storage attributes""" |
186 | + _args = ['storage-get', '--format=json'] |
187 | + if storage_id: |
188 | + _args.extend(('-s', storage_id)) |
189 | + if attribute: |
190 | + _args.append(attribute) |
191 | + try: |
192 | + return json.loads(subprocess.check_output(_args).decode('UTF-8')) |
193 | + except ValueError: |
194 | + return None |
195 | + |
196 | + |
197 | +@cached |
198 | +def storage_list(storage_name=""): |
199 | + """List the storage IDs for the unit""" |
200 | + _args = ['storage-list', '--format=json'] |
201 | + if storage_name: |
202 | + _args.append(storage_name) |
203 | + try: |
204 | + return json.loads(subprocess.check_output(_args).decode('UTF-8')) |
205 | + except ValueError: |
206 | + return None |
207 | + except OSError as e: |
208 | + import errno |
209 | + if e.errno == errno.ENOENT: |
210 | + # storage-list does not exist |
211 | + return [] |
212 | + raise |
213 | + |
214 | + |
215 | class UnregisteredHookError(Exception): |
216 | """Raised when an undefined hook is called""" |
217 | pass |
218 | |
219 | === modified file 'hooks/nova_compute_hooks.py' |
220 | --- hooks/nova_compute_hooks.py 2015-10-07 20:45:02 +0000 |
221 | +++ hooks/nova_compute_hooks.py 2015-10-08 15:08:00 +0000 |
222 | @@ -117,10 +117,10 @@ |
223 | if config_value_changed('openstack-origin-git'): |
224 | status_set('maintenance', 'Running Git install') |
225 | git_install(config('openstack-origin-git')) |
226 | - else: |
227 | + elif not config('action-managed-upgrade'): |
228 | if openstack_upgrade_available('nova-common'): |
229 | status_set('maintenance', 'Running openstack upgrade') |
230 | - CONFIGS = do_openstack_upgrade() |
231 | + do_openstack_upgrade(CONFIGS) |
232 | |
233 | sysctl_dict = config('sysctl') |
234 | if sysctl_dict: |
235 | |
236 | === modified file 'hooks/nova_compute_utils.py' |
237 | --- hooks/nova_compute_utils.py 2015-10-03 00:00:02 +0000 |
238 | +++ hooks/nova_compute_utils.py 2015-10-08 15:08:00 +0000 |
239 | @@ -537,7 +537,7 @@ |
240 | _keys.write('{}\n'.format(authorized_keys[index])) |
241 | |
242 | |
243 | -def do_openstack_upgrade(): |
244 | +def do_openstack_upgrade(configs): |
245 | # NOTE(jamespage) horrible hack to make utils forget a cached value |
246 | import charmhelpers.contrib.openstack.utils as utils |
247 | utils.os_rel = None |
248 | @@ -557,10 +557,8 @@ |
249 | apt_install(determine_packages(), fatal=True) |
250 | |
251 | # Regenerate configs in full for new release |
252 | - configs = register_configs() |
253 | configs.write_all() |
254 | [service_restart(s) for s in services()] |
255 | - return configs |
256 | |
257 | |
258 | def import_keystone_ca_cert(): |
259 | |
260 | === modified file 'tests/charmhelpers/contrib/amulet/utils.py' |
261 | --- tests/charmhelpers/contrib/amulet/utils.py 2015-09-28 07:56:16 +0000 |
262 | +++ tests/charmhelpers/contrib/amulet/utils.py 2015-10-08 15:08:00 +0000 |
263 | @@ -326,7 +326,7 @@ |
264 | |
265 | def service_restarted_since(self, sentry_unit, mtime, service, |
266 | pgrep_full=None, sleep_time=20, |
267 | - retry_count=2, retry_sleep_time=30): |
268 | + retry_count=30, retry_sleep_time=10): |
269 | """Check if service was been started after a given time. |
270 | |
271 | Args: |
272 | @@ -334,8 +334,9 @@ |
273 | mtime (float): The epoch time to check against |
274 | service (string): service name to look for in process table |
275 | pgrep_full: [Deprecated] Use full command line search mode with pgrep |
276 | - sleep_time (int): Seconds to sleep before looking for process |
277 | - retry_count (int): If service is not found, how many times to retry |
278 | + sleep_time (int): Initial sleep time (s) before looking for file |
279 | + retry_sleep_time (int): Time (s) to sleep between retries |
280 | + retry_count (int): If file is not found, how many times to retry |
281 | |
282 | Returns: |
283 | bool: True if service found and its start time it newer than mtime, |
284 | @@ -359,11 +360,12 @@ |
285 | pgrep_full) |
286 | self.log.debug('Attempt {} to get {} proc start time on {} ' |
287 | 'OK'.format(tries, service, unit_name)) |
288 | - except IOError: |
289 | + except IOError as e: |
290 | # NOTE(beisner) - race avoidance, proc may not exist yet. |
291 | # https://bugs.launchpad.net/charm-helpers/+bug/1474030 |
292 | self.log.debug('Attempt {} to get {} proc start time on {} ' |
293 | - 'failed'.format(tries, service, unit_name)) |
294 | + 'failed\n{}'.format(tries, service, |
295 | + unit_name, e)) |
296 | time.sleep(retry_sleep_time) |
297 | tries += 1 |
298 | |
299 | @@ -383,35 +385,62 @@ |
300 | return False |
301 | |
302 | def config_updated_since(self, sentry_unit, filename, mtime, |
303 | - sleep_time=20): |
304 | + sleep_time=20, retry_count=30, |
305 | + retry_sleep_time=10): |
306 | """Check if file was modified after a given time. |
307 | |
308 | Args: |
309 | sentry_unit (sentry): The sentry unit to check the file mtime on |
310 | filename (string): The file to check mtime of |
311 | mtime (float): The epoch time to check against |
312 | - sleep_time (int): Seconds to sleep before looking for process |
313 | + sleep_time (int): Initial sleep time (s) before looking for file |
314 | + retry_sleep_time (int): Time (s) to sleep between retries |
315 | + retry_count (int): If file is not found, how many times to retry |
316 | |
317 | Returns: |
318 | bool: True if file was modified more recently than mtime, False if |
319 | - file was modified before mtime, |
320 | + file was modified before mtime, or if file not found. |
321 | """ |
322 | - self.log.debug('Checking %s updated since %s' % (filename, mtime)) |
323 | + unit_name = sentry_unit.info['unit_name'] |
324 | + self.log.debug('Checking that %s updated since %s on ' |
325 | + '%s' % (filename, mtime, unit_name)) |
326 | time.sleep(sleep_time) |
327 | - file_mtime = self._get_file_mtime(sentry_unit, filename) |
328 | + file_mtime = None |
329 | + tries = 0 |
330 | + while tries <= retry_count and not file_mtime: |
331 | + try: |
332 | + file_mtime = self._get_file_mtime(sentry_unit, filename) |
333 | + self.log.debug('Attempt {} to get {} file mtime on {} ' |
334 | + 'OK'.format(tries, filename, unit_name)) |
335 | + except IOError as e: |
336 | + # NOTE(beisner) - race avoidance, file may not exist yet. |
337 | + # https://bugs.launchpad.net/charm-helpers/+bug/1474030 |
338 | + self.log.debug('Attempt {} to get {} file mtime on {} ' |
339 | + 'failed\n{}'.format(tries, filename, |
340 | + unit_name, e)) |
341 | + time.sleep(retry_sleep_time) |
342 | + tries += 1 |
343 | + |
344 | + if not file_mtime: |
345 | + self.log.warn('Could not determine file mtime, assuming ' |
346 | + 'file does not exist') |
347 | + return False |
348 | + |
349 | if file_mtime >= mtime: |
350 | self.log.debug('File mtime is newer than provided mtime ' |
351 | - '(%s >= %s)' % (file_mtime, mtime)) |
352 | + '(%s >= %s) on %s (OK)' % (file_mtime, |
353 | + mtime, unit_name)) |
354 | return True |
355 | else: |
356 | - self.log.warn('File mtime %s is older than provided mtime %s' |
357 | - % (file_mtime, mtime)) |
358 | + self.log.warn('File mtime is older than provided mtime' |
359 | + '(%s < on %s) on %s' % (file_mtime, |
360 | + mtime, unit_name)) |
361 | return False |
362 | |
363 | def validate_service_config_changed(self, sentry_unit, mtime, service, |
364 | filename, pgrep_full=None, |
365 | - sleep_time=20, retry_count=2, |
366 | - retry_sleep_time=30): |
367 | + sleep_time=20, retry_count=30, |
368 | + retry_sleep_time=10): |
369 | """Check service and file were updated after mtime |
370 | |
371 | Args: |
372 | @@ -456,7 +485,9 @@ |
373 | sentry_unit, |
374 | filename, |
375 | mtime, |
376 | - sleep_time=0) |
377 | + sleep_time=sleep_time, |
378 | + retry_count=retry_count, |
379 | + retry_sleep_time=retry_sleep_time) |
380 | |
381 | return service_restart and config_update |
382 | |
383 | |
384 | === modified file 'tests/charmhelpers/contrib/openstack/amulet/utils.py' |
385 | --- tests/charmhelpers/contrib/openstack/amulet/utils.py 2015-09-28 07:56:16 +0000 |
386 | +++ tests/charmhelpers/contrib/openstack/amulet/utils.py 2015-10-08 15:08:00 +0000 |
387 | @@ -752,7 +752,7 @@ |
388 | self.log.debug('SSL is enabled @{}:{} ' |
389 | '({})'.format(host, port, unit_name)) |
390 | return True |
391 | - elif not port and not conf_ssl: |
392 | + elif not conf_ssl: |
393 | self.log.debug('SSL not enabled @{}:{} ' |
394 | '({})'.format(host, port, unit_name)) |
395 | return False |
396 | |
397 | === added file 'unit_tests/test_actions_openstack_upgrade.py' |
398 | --- unit_tests/test_actions_openstack_upgrade.py 1970-01-01 00:00:00 +0000 |
399 | +++ unit_tests/test_actions_openstack_upgrade.py 2015-10-08 15:08:00 +0000 |
400 | @@ -0,0 +1,62 @@ |
401 | +from mock import patch |
402 | +import os |
403 | + |
404 | +os.environ['JUJU_UNIT_NAME'] = 'nova_compute' |
405 | + |
406 | +with patch('charmhelpers.core.hookenv.config') as config: |
407 | + config.return_value = 'nova' |
408 | + import nova_compute_utils as utils # noqa |
409 | + |
410 | +with patch('nova_compute_utils.restart_map'): |
411 | + with patch('nova_compute_utils.register_configs'): |
412 | + import openstack_upgrade |
413 | + |
414 | +from test_utils import ( |
415 | + CharmTestCase |
416 | +) |
417 | + |
418 | +TO_PATCH = [ |
419 | + 'config_changed', |
420 | + 'do_openstack_upgrade' |
421 | +] |
422 | + |
423 | + |
424 | +class TestNovaComputeUpgradeActions(CharmTestCase): |
425 | + |
426 | + def setUp(self): |
427 | + super(TestNovaComputeUpgradeActions, self).setUp(openstack_upgrade, |
428 | + TO_PATCH) |
429 | + |
430 | + @patch('charmhelpers.contrib.openstack.utils.config') |
431 | + @patch('charmhelpers.contrib.openstack.utils.action_set') |
432 | + @patch('charmhelpers.contrib.openstack.utils.git_install_requested') |
433 | + @patch('charmhelpers.contrib.openstack.utils.openstack_upgrade_available') |
434 | + @patch('charmhelpers.contrib.openstack.utils.juju_log') |
435 | + def test_openstack_upgrade_true(self, log, upgrade_avail, git_requested, |
436 | + action_set, config): |
437 | + |
438 | + git_requested.return_value = False |
439 | + upgrade_avail.return_value = True |
440 | + config.return_value = True |
441 | + |
442 | + openstack_upgrade.openstack_upgrade() |
443 | + |
444 | + self.assertTrue(self.do_openstack_upgrade.called) |
445 | + self.assertTrue(self.config_changed.called) |
446 | + |
447 | + @patch('charmhelpers.contrib.openstack.utils.config') |
448 | + @patch('charmhelpers.contrib.openstack.utils.action_set') |
449 | + @patch('charmhelpers.contrib.openstack.utils.git_install_requested') # noqa |
450 | + @patch('charmhelpers.contrib.openstack.utils.openstack_upgrade_available') # noqa |
451 | + @patch('charmhelpers.contrib.openstack.utils.juju_log') |
452 | + def test_openstack_upgrade_false(self, log, upgrade_avail, git_requested, |
453 | + action_set, config): |
454 | + |
455 | + git_requested.return_value = False |
456 | + upgrade_avail.return_value = True |
457 | + config.return_value = False |
458 | + |
459 | + openstack_upgrade.openstack_upgrade() |
460 | + |
461 | + self.assertFalse(self.do_openstack_upgrade.called) |
462 | + self.assertFalse(self.config_changed.called) |
463 | |
464 | === modified file 'unit_tests/test_nova_compute_hooks.py' |
465 | --- unit_tests/test_nova_compute_hooks.py 2015-10-06 09:04:58 +0000 |
466 | +++ unit_tests/test_nova_compute_hooks.py 2015-10-08 15:08:00 +0000 |
467 | @@ -115,6 +115,15 @@ |
468 | hooks.config_changed() |
469 | self.assertTrue(self.do_openstack_upgrade.called) |
470 | |
471 | + @patch.object(hooks, 'git_install_requested') |
472 | + def test_config_changed_with_openstack_upgrade_action(self, git_requested): |
473 | + git_requested.return_value = False |
474 | + self.openstack_upgrade_available.return_value = True |
475 | + self.test_config.set('action-managed-upgrade', True) |
476 | + |
477 | + hooks.config_changed() |
478 | + self.assertFalse(self.do_openstack_upgrade.called) |
479 | + |
480 | @patch.object(hooks, 'compute_joined') |
481 | def test_config_changed_with_migration(self, compute_joined): |
482 | self.git_install_requested.return_value = False |
charm_lint_check #11392 nova-compute-next for ddellav mp273560
LINT OK: passed
Build: http:// 10.245. 162.77: 8080/job/ charm_lint_ check/11392/