Merge lp:~billy-olsen/charms/trusty/nova-compute/lp1512908-backport into lp:~openstack-charmers-archive/charms/trusty/nova-compute/trunk

Proposed by Billy Olsen
Status: Merged
Merged at revision: 142
Proposed branch: lp:~billy-olsen/charms/trusty/nova-compute/lp1512908-backport
Merge into: lp:~openstack-charmers-archive/charms/trusty/nova-compute/trunk
Diff against target: 132 lines (+46/-13)
2 files modified
hooks/nova_compute_context.py (+10/-1)
unit_tests/test_nova_compute_contexts.py (+36/-12)
To merge this branch: bzr merge lp:~billy-olsen/charms/trusty/nova-compute/lp1512908-backport
Reviewer Review Type Date Requested Status
Liam Young (community) Approve
Review via email: mp+277205@code.launchpad.net

Description of the change

This is a backport of gnuoy's change for bug #1512908

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

charm_lint_check #13429 nova-compute for billy-olsen mp277205
    LINT OK: passed

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

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

charm_unit_test #12563 nova-compute for billy-olsen mp277205
    UNIT OK: passed

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

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

charm_amulet_test #7840 nova-compute for billy-olsen mp277205
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [functional_test] Error 1
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/13236803/
Build: http://10.245.162.77:8080/job/charm_amulet_test/7840/

Revision history for this message
Liam Young (gnuoy) wrote :

Approved.

Ran amulet tests by hand:

juju-test INFO : Results: 10 passed, 1 failed, 0 errored

The failed one was trusty-kilo-git which seemed to be an undercloud issue which I don't think should block this.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/nova_compute_context.py'
2--- hooks/nova_compute_context.py 2015-10-22 13:23:10 +0000
3+++ hooks/nova_compute_context.py 2015-11-11 00:24:06 +0000
4@@ -2,6 +2,7 @@
5 import os
6 import platform
7
8+from charmhelpers.core.unitdata import kv
9 from charmhelpers.contrib.openstack import context
10 from charmhelpers.core.host import service_running, service_start
11 from charmhelpers.fetch import apt_install, filter_installed_packages
12@@ -134,7 +135,15 @@
13 if config('hugepages'):
14 ctxt['hugepages'] = True
15
16- ctxt['host_uuid'] = '%s' % uuid.uuid4()
17+ db = kv()
18+ if db.get('host_uuid'):
19+ ctxt['host_uuid'] = db.get('host_uuid')
20+ else:
21+ host_uuid = str(uuid.uuid4())
22+ db.set('host_uuid', host_uuid)
23+ db.flush()
24+ ctxt['host_uuid'] = host_uuid
25+
26 return ctxt
27
28
29
30=== modified file 'unit_tests/test_nova_compute_contexts.py'
31--- unit_tests/test_nova_compute_contexts.py 2015-10-22 13:23:10 +0000
32+++ unit_tests/test_nova_compute_contexts.py 2015-11-11 00:24:06 +0000
33@@ -10,6 +10,7 @@
34 TO_PATCH = [
35 'apt_install',
36 'filter_installed_packages',
37+ 'kv',
38 'relation_ids',
39 'relation_get',
40 'related_units',
41@@ -58,6 +59,23 @@
42 print '[juju test log (%s)] %s' % (level, msg)
43
44
45+class FakeUnitdata(object):
46+
47+ def __init__(self, **kwargs):
48+ self.unit_data = {}
49+ for name, value in kwargs.items():
50+ self.unit_data[name] = value
51+
52+ def get(self, key, default=None, record=False):
53+ return self.unit_data.get(key)
54+
55+ def set(self, key, value):
56+ self.unit_data[key] = value
57+
58+ def flush(self):
59+ pass
60+
61+
62 class NovaComputeContextTests(CharmTestCase):
63
64 def setUp(self):
65@@ -65,6 +83,7 @@
66 self.relation_get.side_effect = self.test_relation.get
67 self.config.side_effect = self.test_config.get
68 self.log.side_effect = fake_log
69+ self.host_uuid = 'e46e530d-18ae-4a67-9ff0-e6e2ba7c60a7'
70
71 def test_cloud_compute_context_no_relation(self):
72 self.relation_ids.return_value = []
73@@ -173,34 +192,31 @@
74 with patch.object(qplugin, '_ensure_packages'):
75 self.assertEquals({}, qplugin())
76
77- @patch.object(context.uuid, 'uuid4')
78- def test_libvirt_bin_context_no_migration(self, mock_uuid):
79+ def test_libvirt_bin_context_no_migration(self):
80+ self.kv.return_value = FakeUnitdata(**{'host_uuid': self.host_uuid})
81 self.test_config.set('enable-live-migration', False)
82- mock_uuid.return_value = 'e46e530d-18ae-4a67-9ff0-e6e2ba7c60a7'
83 libvirt = context.NovaComputeLibvirtContext()
84
85 self.assertEqual(
86 {'libvirtd_opts': '-d',
87 'arch': platform.machine(),
88 'listen_tls': 0,
89- 'host_uuid': 'e46e530d-18ae-4a67-9ff0-e6e2ba7c60a7'}, libvirt())
90+ 'host_uuid': self.host_uuid}, libvirt())
91
92- @patch.object(context.uuid, 'uuid4')
93- def test_libvirt_bin_context_migration_tcp_listen(self, mock_uuid):
94+ def test_libvirt_bin_context_migration_tcp_listen(self):
95+ self.kv.return_value = FakeUnitdata(**{'host_uuid': self.host_uuid})
96 self.test_config.set('enable-live-migration', True)
97- mock_uuid.return_value = 'e46e530d-18ae-4a67-9ff0-e6e2ba7c60a7'
98 libvirt = context.NovaComputeLibvirtContext()
99
100 self.assertEqual(
101 {'libvirtd_opts': '-d -l',
102 'arch': platform.machine(),
103 'listen_tls': 0,
104- 'host_uuid': 'e46e530d-18ae-4a67-9ff0-e6e2ba7c60a7'}, libvirt())
105+ 'host_uuid': self.host_uuid}, libvirt())
106
107- @patch.object(context.uuid, 'uuid4')
108- def test_libvirt_disk_cachemodes(self, mock_uuid):
109+ def test_libvirt_disk_cachemodes(self):
110+ self.kv.return_value = FakeUnitdata(**{'host_uuid': self.host_uuid})
111 self.test_config.set('disk-cachemodes', 'file=unsafe,block=none')
112- mock_uuid.return_value = 'e46e530d-18ae-4a67-9ff0-e6e2ba7c60a7'
113 libvirt = context.NovaComputeLibvirtContext()
114
115 self.assertEqual(
116@@ -208,7 +224,15 @@
117 'disk_cachemodes': 'file=unsafe,block=none',
118 'arch': platform.machine(),
119 'listen_tls': 0,
120- 'host_uuid': 'e46e530d-18ae-4a67-9ff0-e6e2ba7c60a7'}, libvirt())
121+ 'host_uuid': self.host_uuid}, libvirt())
122+
123+ @patch.object(context.uuid, 'uuid4')
124+ def test_libvirt_new_uuid(self, mock_uuid):
125+ self.kv.return_value = FakeUnitdata()
126+ mock_uuid.return_value = '73874c1c-ba48-406d-8d99-ac185d83b9bc'
127+ libvirt = context.NovaComputeLibvirtContext()
128+ self.assertEqual(libvirt()['host_uuid'],
129+ '73874c1c-ba48-406d-8d99-ac185d83b9bc')
130
131 @patch.object(context.NeutronComputeContext, 'network_manager')
132 @patch.object(context.NeutronComputeContext, 'plugin')

Subscribers

People subscribed via source and target branches