Merge lp:~ddellav/charms/trusty/nova-compute/upgrade-action into lp:~openstack-charmers-archive/charms/trusty/nova-compute/next

Proposed by David Della Vecchia
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
Reviewer Review Type Date Requested Status
Corey Bryant (community) Approve
Review via email: mp+273560@code.launchpad.net

Description of the change

Adding charmhelpers-based upgrade action to nova-compute.

To post a comment you must log in.
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

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/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #10584 nova-compute-next for ddellav mp273560
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/10584/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #10585 nova-compute-next for ddellav mp273560
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/10585/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #11394 nova-compute-next for ddellav mp273560
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/11394/

Revision history for this message
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://paste.ubuntu.com/12698231/
Build: http://10.245.162.77:8080/job/charm_amulet_test/7141/

Revision history for this message
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://paste.ubuntu.com/12698727/
Build: http://10.245.162.77:8080/job/charm_amulet_test/7140/

Revision history for this message
Corey Bryant (corey.bryant) wrote :

Reviewed and tested successfully. I approve. Just waiting on amulet tests to pass before landing.

review: Approve
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #11425 nova-compute-next for ddellav mp273560
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/11425/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #10616 nova-compute-next for ddellav mp273560
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/10616/

Revision history for this message
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://paste.ubuntu.com/12700486/
Build: http://10.245.162.77:8080/job/charm_amulet_test/7168/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #10733 nova-compute-next for ddellav mp273560
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/10733/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #11542 nova-compute-next for ddellav mp273560
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/11542/

Revision history for this message
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://paste.ubuntu.com/12718961/
Build: http://10.245.162.77:8080/job/charm_amulet_test/7243/

Revision history for this message
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://paste.ubuntu.com/12720684/
Build: http://10.245.162.77:8080/job/charm_amulet_test/7258/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #10797 nova-compute-next for ddellav mp273560
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/10797/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #11608 nova-compute-next for ddellav mp273560
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/11608/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #11618 nova-compute-next for ddellav mp273560
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/11618/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #10807 nova-compute-next for ddellav mp273560
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/10807/

Revision history for this message
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://paste.ubuntu.com/12724034/
Build: http://10.245.162.77:8080/job/charm_amulet_test/7266/

Revision history for this message
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

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'actions.yaml'
--- actions.yaml 2015-04-15 14:21:42 +0000
+++ actions.yaml 2015-10-08 15:08:00 +0000
@@ -1,2 +1,4 @@
1git-reinstall:1git-reinstall:
2 description: Reinstall nova-compute from the openstack-origin-git repositories.2 description: Reinstall nova-compute from the openstack-origin-git repositories.
3openstack-upgrade:
4 description: Perform openstack upgrades. Config option action-managed-upgrade must be set to True.
35
=== added symlink 'actions/openstack-upgrade'
=== target is u'openstack_upgrade.py'
=== added file 'actions/openstack_upgrade.py'
--- actions/openstack_upgrade.py 1970-01-01 00:00:00 +0000
+++ actions/openstack_upgrade.py 2015-10-08 15:08:00 +0000
@@ -0,0 +1,32 @@
1#!/usr/bin/python
2import sys
3
4sys.path.append('hooks/')
5
6from charmhelpers.contrib.openstack.utils import (
7 do_action_openstack_upgrade,
8)
9
10from nova_compute_utils import do_openstack_upgrade
11
12from nova_compute_hooks import (
13 config_changed,
14 CONFIGS
15)
16
17
18def openstack_upgrade():
19 """Upgrade packages to config-set Openstack version.
20
21 If the charm was installed from source we cannot upgrade it.
22 For backwards compatibility a config flag must be set for this
23 code to run, otherwise a full service level upgrade will fire
24 on config-changed."""
25
26 if (do_action_openstack_upgrade('nova-common',
27 do_openstack_upgrade,
28 CONFIGS)):
29 config_changed()
30
31if __name__ == '__main__':
32 openstack_upgrade()
033
=== modified file 'config.yaml'
--- config.yaml 2015-10-02 09:40:38 +0000
+++ config.yaml 2015-10-08 15:08:00 +0000
@@ -265,3 +265,13 @@
265 description: |265 description: |
266 The pecentage of system memory to use for hugepages eg '10%' or the total266 The pecentage of system memory to use for hugepages eg '10%' or the total
267 number of 2M hugepages - eg "1024".267 number of 2M hugepages - eg "1024".
268 action-managed-upgrade:
269 type: boolean
270 default: False
271 description: |
272 If True enables openstack upgrades for this charm via juju actions.
273 You will still need to set openstack-origin to the new repository but
274 instead of an upgrade running automatically across all units, it will
275 wait for you to execute the openstack-upgrade action for this charm on
276 each unit. If False it will revert to existing behavior of upgrading
277 all units on config change.
268278
=== modified file 'hooks/charmhelpers/contrib/network/ip.py'
--- hooks/charmhelpers/contrib/network/ip.py 2015-09-02 15:03:16 +0000
+++ hooks/charmhelpers/contrib/network/ip.py 2015-10-08 15:08:00 +0000
@@ -23,7 +23,7 @@
23from functools import partial23from functools import partial
2424
25from charmhelpers.core.hookenv import unit_get25from charmhelpers.core.hookenv import unit_get
26from charmhelpers.fetch import apt_install26from charmhelpers.fetch import apt_install, apt_update
27from charmhelpers.core.hookenv import (27from charmhelpers.core.hookenv import (
28 log,28 log,
29 WARNING,29 WARNING,
@@ -32,13 +32,15 @@
32try:32try:
33 import netifaces33 import netifaces
34except ImportError:34except ImportError:
35 apt_install('python-netifaces')35 apt_update(fatal=True)
36 apt_install('python-netifaces', fatal=True)
36 import netifaces37 import netifaces
3738
38try:39try:
39 import netaddr40 import netaddr
40except ImportError:41except ImportError:
41 apt_install('python-netaddr')42 apt_update(fatal=True)
43 apt_install('python-netaddr', fatal=True)
42 import netaddr44 import netaddr
4345
4446
4547
=== modified file 'hooks/charmhelpers/contrib/openstack/amulet/utils.py'
--- hooks/charmhelpers/contrib/openstack/amulet/utils.py 2015-09-28 07:56:16 +0000
+++ hooks/charmhelpers/contrib/openstack/amulet/utils.py 2015-10-08 15:08:00 +0000
@@ -752,7 +752,7 @@
752 self.log.debug('SSL is enabled @{}:{} '752 self.log.debug('SSL is enabled @{}:{} '
753 '({})'.format(host, port, unit_name))753 '({})'.format(host, port, unit_name))
754 return True754 return True
755 elif not port and not conf_ssl:755 elif not conf_ssl:
756 self.log.debug('SSL not enabled @{}:{} '756 self.log.debug('SSL not enabled @{}:{} '
757 '({})'.format(host, port, unit_name))757 '({})'.format(host, port, unit_name))
758 return False758 return False
759759
=== modified file 'hooks/charmhelpers/contrib/openstack/context.py'
--- hooks/charmhelpers/contrib/openstack/context.py 2015-09-28 07:56:16 +0000
+++ hooks/charmhelpers/contrib/openstack/context.py 2015-10-08 15:08:00 +0000
@@ -14,6 +14,7 @@
14# You should have received a copy of the GNU Lesser General Public License14# You should have received a copy of the GNU Lesser General Public License
15# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.15# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
1616
17import glob
17import json18import json
18import os19import os
19import re20import re
@@ -1363,7 +1364,7 @@
1363 normalized.update({port: port for port in resolved1364 normalized.update({port: port for port in resolved
1364 if port in ports})1365 if port in ports})
1365 if resolved:1366 if resolved:
1366 return {bridge: normalized[port] for port, bridge in1367 return {normalized[port]: bridge for port, bridge in
1367 six.iteritems(portmap) if port in normalized.keys()}1368 six.iteritems(portmap) if port in normalized.keys()}
13681369
1369 return None1370 return None
@@ -1374,12 +1375,22 @@
1374 def __call__(self):1375 def __call__(self):
1375 ctxt = {}1376 ctxt = {}
1376 mappings = super(PhyNICMTUContext, self).__call__()1377 mappings = super(PhyNICMTUContext, self).__call__()
1377 if mappings and mappings.values():1378 if mappings and mappings.keys():
1378 ports = mappings.values()1379 ports = sorted(mappings.keys())
1379 napi_settings = NeutronAPIContext()()1380 napi_settings = NeutronAPIContext()()
1380 mtu = napi_settings.get('network_device_mtu')1381 mtu = napi_settings.get('network_device_mtu')
1382 all_ports = set()
1383 # If any of ports is a vlan device, its underlying device must have
1384 # mtu applied first.
1385 for port in ports:
1386 for lport in glob.glob("/sys/class/net/%s/lower_*" % port):
1387 lport = os.path.basename(lport)
1388 all_ports.add(lport.split('_')[1])
1389
1390 all_ports = list(all_ports)
1391 all_ports.extend(ports)
1381 if mtu:1392 if mtu:
1382 ctxt["devs"] = '\\n'.join(ports)1393 ctxt["devs"] = '\\n'.join(all_ports)
1383 ctxt['mtu'] = mtu1394 ctxt['mtu'] = mtu
13841395
1385 return ctxt1396 return ctxt
13861397
=== modified file 'hooks/charmhelpers/contrib/openstack/neutron.py'
--- hooks/charmhelpers/contrib/openstack/neutron.py 2015-08-25 17:40:00 +0000
+++ hooks/charmhelpers/contrib/openstack/neutron.py 2015-10-08 15:08:00 +0000
@@ -310,10 +310,10 @@
310def parse_data_port_mappings(mappings, default_bridge='br-data'):310def parse_data_port_mappings(mappings, default_bridge='br-data'):
311 """Parse data port mappings.311 """Parse data port mappings.
312312
313 Mappings must be a space-delimited list of port:bridge mappings.313 Mappings must be a space-delimited list of bridge:port.
314314
315 Returns dict of the form {port:bridge} where port may be an mac address or315 Returns dict of the form {port:bridge} where ports may be mac addresses or
316 interface name.316 interface names.
317 """317 """
318318
319 # NOTE(dosaboy): we use rvalue for key to allow multiple values to be319 # NOTE(dosaboy): we use rvalue for key to allow multiple values to be
320320
=== modified file 'hooks/charmhelpers/core/hookenv.py'
--- hooks/charmhelpers/core/hookenv.py 2015-09-28 07:56:16 +0000
+++ hooks/charmhelpers/core/hookenv.py 2015-10-08 15:08:00 +0000
@@ -623,6 +623,38 @@
623 return unit_get('private-address')623 return unit_get('private-address')
624624
625625
626@cached
627def storage_get(attribute="", storage_id=""):
628 """Get storage attributes"""
629 _args = ['storage-get', '--format=json']
630 if storage_id:
631 _args.extend(('-s', storage_id))
632 if attribute:
633 _args.append(attribute)
634 try:
635 return json.loads(subprocess.check_output(_args).decode('UTF-8'))
636 except ValueError:
637 return None
638
639
640@cached
641def storage_list(storage_name=""):
642 """List the storage IDs for the unit"""
643 _args = ['storage-list', '--format=json']
644 if storage_name:
645 _args.append(storage_name)
646 try:
647 return json.loads(subprocess.check_output(_args).decode('UTF-8'))
648 except ValueError:
649 return None
650 except OSError as e:
651 import errno
652 if e.errno == errno.ENOENT:
653 # storage-list does not exist
654 return []
655 raise
656
657
626class UnregisteredHookError(Exception):658class UnregisteredHookError(Exception):
627 """Raised when an undefined hook is called"""659 """Raised when an undefined hook is called"""
628 pass660 pass
629661
=== modified file 'hooks/nova_compute_hooks.py'
--- hooks/nova_compute_hooks.py 2015-10-07 20:45:02 +0000
+++ hooks/nova_compute_hooks.py 2015-10-08 15:08:00 +0000
@@ -117,10 +117,10 @@
117 if config_value_changed('openstack-origin-git'):117 if config_value_changed('openstack-origin-git'):
118 status_set('maintenance', 'Running Git install')118 status_set('maintenance', 'Running Git install')
119 git_install(config('openstack-origin-git'))119 git_install(config('openstack-origin-git'))
120 else:120 elif not config('action-managed-upgrade'):
121 if openstack_upgrade_available('nova-common'):121 if openstack_upgrade_available('nova-common'):
122 status_set('maintenance', 'Running openstack upgrade')122 status_set('maintenance', 'Running openstack upgrade')
123 CONFIGS = do_openstack_upgrade()123 do_openstack_upgrade(CONFIGS)
124124
125 sysctl_dict = config('sysctl')125 sysctl_dict = config('sysctl')
126 if sysctl_dict:126 if sysctl_dict:
127127
=== modified file 'hooks/nova_compute_utils.py'
--- hooks/nova_compute_utils.py 2015-10-03 00:00:02 +0000
+++ hooks/nova_compute_utils.py 2015-10-08 15:08:00 +0000
@@ -537,7 +537,7 @@
537 _keys.write('{}\n'.format(authorized_keys[index]))537 _keys.write('{}\n'.format(authorized_keys[index]))
538538
539539
540def do_openstack_upgrade():540def do_openstack_upgrade(configs):
541 # NOTE(jamespage) horrible hack to make utils forget a cached value541 # NOTE(jamespage) horrible hack to make utils forget a cached value
542 import charmhelpers.contrib.openstack.utils as utils542 import charmhelpers.contrib.openstack.utils as utils
543 utils.os_rel = None543 utils.os_rel = None
@@ -557,10 +557,8 @@
557 apt_install(determine_packages(), fatal=True)557 apt_install(determine_packages(), fatal=True)
558558
559 # Regenerate configs in full for new release559 # Regenerate configs in full for new release
560 configs = register_configs()
561 configs.write_all()560 configs.write_all()
562 [service_restart(s) for s in services()]561 [service_restart(s) for s in services()]
563 return configs
564562
565563
566def import_keystone_ca_cert():564def import_keystone_ca_cert():
567565
=== modified file 'tests/charmhelpers/contrib/amulet/utils.py'
--- tests/charmhelpers/contrib/amulet/utils.py 2015-09-28 07:56:16 +0000
+++ tests/charmhelpers/contrib/amulet/utils.py 2015-10-08 15:08:00 +0000
@@ -326,7 +326,7 @@
326326
327 def service_restarted_since(self, sentry_unit, mtime, service,327 def service_restarted_since(self, sentry_unit, mtime, service,
328 pgrep_full=None, sleep_time=20,328 pgrep_full=None, sleep_time=20,
329 retry_count=2, retry_sleep_time=30):329 retry_count=30, retry_sleep_time=10):
330 """Check if service was been started after a given time.330 """Check if service was been started after a given time.
331331
332 Args:332 Args:
@@ -334,8 +334,9 @@
334 mtime (float): The epoch time to check against334 mtime (float): The epoch time to check against
335 service (string): service name to look for in process table335 service (string): service name to look for in process table
336 pgrep_full: [Deprecated] Use full command line search mode with pgrep336 pgrep_full: [Deprecated] Use full command line search mode with pgrep
337 sleep_time (int): Seconds to sleep before looking for process337 sleep_time (int): Initial sleep time (s) before looking for file
338 retry_count (int): If service is not found, how many times to retry338 retry_sleep_time (int): Time (s) to sleep between retries
339 retry_count (int): If file is not found, how many times to retry
339340
340 Returns:341 Returns:
341 bool: True if service found and its start time it newer than mtime,342 bool: True if service found and its start time it newer than mtime,
@@ -359,11 +360,12 @@
359 pgrep_full)360 pgrep_full)
360 self.log.debug('Attempt {} to get {} proc start time on {} '361 self.log.debug('Attempt {} to get {} proc start time on {} '
361 'OK'.format(tries, service, unit_name))362 'OK'.format(tries, service, unit_name))
362 except IOError:363 except IOError as e:
363 # NOTE(beisner) - race avoidance, proc may not exist yet.364 # NOTE(beisner) - race avoidance, proc may not exist yet.
364 # https://bugs.launchpad.net/charm-helpers/+bug/1474030365 # https://bugs.launchpad.net/charm-helpers/+bug/1474030
365 self.log.debug('Attempt {} to get {} proc start time on {} '366 self.log.debug('Attempt {} to get {} proc start time on {} '
366 'failed'.format(tries, service, unit_name))367 'failed\n{}'.format(tries, service,
368 unit_name, e))
367 time.sleep(retry_sleep_time)369 time.sleep(retry_sleep_time)
368 tries += 1370 tries += 1
369371
@@ -383,35 +385,62 @@
383 return False385 return False
384386
385 def config_updated_since(self, sentry_unit, filename, mtime,387 def config_updated_since(self, sentry_unit, filename, mtime,
386 sleep_time=20):388 sleep_time=20, retry_count=30,
389 retry_sleep_time=10):
387 """Check if file was modified after a given time.390 """Check if file was modified after a given time.
388391
389 Args:392 Args:
390 sentry_unit (sentry): The sentry unit to check the file mtime on393 sentry_unit (sentry): The sentry unit to check the file mtime on
391 filename (string): The file to check mtime of394 filename (string): The file to check mtime of
392 mtime (float): The epoch time to check against395 mtime (float): The epoch time to check against
393 sleep_time (int): Seconds to sleep before looking for process396 sleep_time (int): Initial sleep time (s) before looking for file
397 retry_sleep_time (int): Time (s) to sleep between retries
398 retry_count (int): If file is not found, how many times to retry
394399
395 Returns:400 Returns:
396 bool: True if file was modified more recently than mtime, False if401 bool: True if file was modified more recently than mtime, False if
397 file was modified before mtime,402 file was modified before mtime, or if file not found.
398 """403 """
399 self.log.debug('Checking %s updated since %s' % (filename, mtime))404 unit_name = sentry_unit.info['unit_name']
405 self.log.debug('Checking that %s updated since %s on '
406 '%s' % (filename, mtime, unit_name))
400 time.sleep(sleep_time)407 time.sleep(sleep_time)
401 file_mtime = self._get_file_mtime(sentry_unit, filename)408 file_mtime = None
409 tries = 0
410 while tries <= retry_count and not file_mtime:
411 try:
412 file_mtime = self._get_file_mtime(sentry_unit, filename)
413 self.log.debug('Attempt {} to get {} file mtime on {} '
414 'OK'.format(tries, filename, unit_name))
415 except IOError as e:
416 # NOTE(beisner) - race avoidance, file may not exist yet.
417 # https://bugs.launchpad.net/charm-helpers/+bug/1474030
418 self.log.debug('Attempt {} to get {} file mtime on {} '
419 'failed\n{}'.format(tries, filename,
420 unit_name, e))
421 time.sleep(retry_sleep_time)
422 tries += 1
423
424 if not file_mtime:
425 self.log.warn('Could not determine file mtime, assuming '
426 'file does not exist')
427 return False
428
402 if file_mtime >= mtime:429 if file_mtime >= mtime:
403 self.log.debug('File mtime is newer than provided mtime '430 self.log.debug('File mtime is newer than provided mtime '
404 '(%s >= %s)' % (file_mtime, mtime))431 '(%s >= %s) on %s (OK)' % (file_mtime,
432 mtime, unit_name))
405 return True433 return True
406 else:434 else:
407 self.log.warn('File mtime %s is older than provided mtime %s'435 self.log.warn('File mtime is older than provided mtime'
408 % (file_mtime, mtime))436 '(%s < on %s) on %s' % (file_mtime,
437 mtime, unit_name))
409 return False438 return False
410439
411 def validate_service_config_changed(self, sentry_unit, mtime, service,440 def validate_service_config_changed(self, sentry_unit, mtime, service,
412 filename, pgrep_full=None,441 filename, pgrep_full=None,
413 sleep_time=20, retry_count=2,442 sleep_time=20, retry_count=30,
414 retry_sleep_time=30):443 retry_sleep_time=10):
415 """Check service and file were updated after mtime444 """Check service and file were updated after mtime
416445
417 Args:446 Args:
@@ -456,7 +485,9 @@
456 sentry_unit,485 sentry_unit,
457 filename,486 filename,
458 mtime,487 mtime,
459 sleep_time=0)488 sleep_time=sleep_time,
489 retry_count=retry_count,
490 retry_sleep_time=retry_sleep_time)
460491
461 return service_restart and config_update492 return service_restart and config_update
462493
463494
=== modified file 'tests/charmhelpers/contrib/openstack/amulet/utils.py'
--- tests/charmhelpers/contrib/openstack/amulet/utils.py 2015-09-28 07:56:16 +0000
+++ tests/charmhelpers/contrib/openstack/amulet/utils.py 2015-10-08 15:08:00 +0000
@@ -752,7 +752,7 @@
752 self.log.debug('SSL is enabled @{}:{} '752 self.log.debug('SSL is enabled @{}:{} '
753 '({})'.format(host, port, unit_name))753 '({})'.format(host, port, unit_name))
754 return True754 return True
755 elif not port and not conf_ssl:755 elif not conf_ssl:
756 self.log.debug('SSL not enabled @{}:{} '756 self.log.debug('SSL not enabled @{}:{} '
757 '({})'.format(host, port, unit_name))757 '({})'.format(host, port, unit_name))
758 return False758 return False
759759
=== added file 'unit_tests/test_actions_openstack_upgrade.py'
--- unit_tests/test_actions_openstack_upgrade.py 1970-01-01 00:00:00 +0000
+++ unit_tests/test_actions_openstack_upgrade.py 2015-10-08 15:08:00 +0000
@@ -0,0 +1,62 @@
1from mock import patch
2import os
3
4os.environ['JUJU_UNIT_NAME'] = 'nova_compute'
5
6with patch('charmhelpers.core.hookenv.config') as config:
7 config.return_value = 'nova'
8 import nova_compute_utils as utils # noqa
9
10with patch('nova_compute_utils.restart_map'):
11 with patch('nova_compute_utils.register_configs'):
12 import openstack_upgrade
13
14from test_utils import (
15 CharmTestCase
16)
17
18TO_PATCH = [
19 'config_changed',
20 'do_openstack_upgrade'
21]
22
23
24class TestNovaComputeUpgradeActions(CharmTestCase):
25
26 def setUp(self):
27 super(TestNovaComputeUpgradeActions, self).setUp(openstack_upgrade,
28 TO_PATCH)
29
30 @patch('charmhelpers.contrib.openstack.utils.config')
31 @patch('charmhelpers.contrib.openstack.utils.action_set')
32 @patch('charmhelpers.contrib.openstack.utils.git_install_requested')
33 @patch('charmhelpers.contrib.openstack.utils.openstack_upgrade_available')
34 @patch('charmhelpers.contrib.openstack.utils.juju_log')
35 def test_openstack_upgrade_true(self, log, upgrade_avail, git_requested,
36 action_set, config):
37
38 git_requested.return_value = False
39 upgrade_avail.return_value = True
40 config.return_value = True
41
42 openstack_upgrade.openstack_upgrade()
43
44 self.assertTrue(self.do_openstack_upgrade.called)
45 self.assertTrue(self.config_changed.called)
46
47 @patch('charmhelpers.contrib.openstack.utils.config')
48 @patch('charmhelpers.contrib.openstack.utils.action_set')
49 @patch('charmhelpers.contrib.openstack.utils.git_install_requested') # noqa
50 @patch('charmhelpers.contrib.openstack.utils.openstack_upgrade_available') # noqa
51 @patch('charmhelpers.contrib.openstack.utils.juju_log')
52 def test_openstack_upgrade_false(self, log, upgrade_avail, git_requested,
53 action_set, config):
54
55 git_requested.return_value = False
56 upgrade_avail.return_value = True
57 config.return_value = False
58
59 openstack_upgrade.openstack_upgrade()
60
61 self.assertFalse(self.do_openstack_upgrade.called)
62 self.assertFalse(self.config_changed.called)
063
=== modified file 'unit_tests/test_nova_compute_hooks.py'
--- unit_tests/test_nova_compute_hooks.py 2015-10-06 09:04:58 +0000
+++ unit_tests/test_nova_compute_hooks.py 2015-10-08 15:08:00 +0000
@@ -115,6 +115,15 @@
115 hooks.config_changed()115 hooks.config_changed()
116 self.assertTrue(self.do_openstack_upgrade.called)116 self.assertTrue(self.do_openstack_upgrade.called)
117117
118 @patch.object(hooks, 'git_install_requested')
119 def test_config_changed_with_openstack_upgrade_action(self, git_requested):
120 git_requested.return_value = False
121 self.openstack_upgrade_available.return_value = True
122 self.test_config.set('action-managed-upgrade', True)
123
124 hooks.config_changed()
125 self.assertFalse(self.do_openstack_upgrade.called)
126
118 @patch.object(hooks, 'compute_joined')127 @patch.object(hooks, 'compute_joined')
119 def test_config_changed_with_migration(self, compute_joined):128 def test_config_changed_with_migration(self, compute_joined):
120 self.git_install_requested.return_value = False129 self.git_install_requested.return_value = False

Subscribers

People subscribed via source and target branches