Merge lp:~hopem/charms/trusty/cinder/ceph-broker into lp:~openstack-charmers-archive/charms/trusty/cinder/next

Proposed by Edward Hope-Morley
Status: Merged
Merged at revision: 61
Proposed branch: lp:~hopem/charms/trusty/cinder/ceph-broker
Merge into: lp:~openstack-charmers-archive/charms/trusty/cinder/next
Diff against target: 330 lines (+130/-50)
6 files modified
hooks/charmhelpers/contrib/storage/linux/ceph.py (+43/-0)
hooks/cinder_hooks.py (+36/-15)
hooks/cinder_utils.py (+0/-12)
unit_tests/test_cinder_hooks.py (+51/-7)
unit_tests/test_cinder_utils.py (+0/-14)
unit_tests/test_cluster_hooks.py (+0/-2)
To merge this branch: bzr merge lp:~hopem/charms/trusty/cinder/ceph-broker
Reviewer Review Type Date Requested Status
James Page Needs Resubmitting
Review via email: mp+241084@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Ryan Beisner (1chb1n) wrote :

UOSCI bot says:
charm_lint_check #932 cinder-next for hopem mp241084
    LINT OK: passed

LINT Results (max last 5 lines):
  I: config.yaml: option ssl_ca has no default value
  I: config.yaml: option config-flags has no default value
  I: config.yaml: option ssl_cert has no default value
  I: config.yaml: option os-internal-network has no default value
  I: config.yaml: option os-public-network has no default value

Full lint test output: http://paste.ubuntu.com/8868314/
Build: http://10.98.191.181:8080/job/charm_lint_check/932/

Revision history for this message
Ryan Beisner (1chb1n) wrote :

UOSCI bot says:
charm_unit_test #767 cinder-next for hopem mp241084
    UNIT OK: passed

UNIT Results (max last 5 lines):
  hooks/cinder_hooks 204 13 94% 99-100, 115, 122, 269-274, 279-280, 299-300
  hooks/cinder_utils 169 14 92% 186, 398-403, 440-452
  TOTAL 425 33 92%
  Ran 84 tests in 5.409s
  OK

Full unit test output: http://paste.ubuntu.com/8868316/
Build: http://10.98.191.181:8080/job/charm_unit_test/767/

Revision history for this message
Ryan Beisner (1chb1n) wrote :

UOSCI bot says:
charm_amulet_test #350 cinder-next for hopem mp241084
    AMULET FAIL: amulet-test failed

AMULET Results (max last 5 lines):
  juju-test.conductor DEBUG : Calling "juju destroy-environment -y osci-sv05"
  WARNING cannot delete security group "juju-osci-sv05-0". Used by another environment?
  juju-test INFO : Results: 2 passed, 1 failed, 0 errored
  ERROR subprocess encountered error code 1
  make: *** [test] Error 1

Full amulet test output: http://paste.ubuntu.com/8868565/
Build: http://10.98.191.181:8080/job/charm_amulet_test/350/

Revision history for this message
Ryan Beisner (1chb1n) wrote :

UOSCI bot says:
charm_lint_check #933 cinder-next for hopem mp241084
    LINT OK: passed

LINT Results (max last 5 lines):
  I: config.yaml: option ssl_ca has no default value
  I: config.yaml: option config-flags has no default value
  I: config.yaml: option ssl_cert has no default value
  I: config.yaml: option os-internal-network has no default value
  I: config.yaml: option os-public-network has no default value

Full lint test output: http://paste.ubuntu.com/8868686/
Build: http://10.98.191.181:8080/job/charm_lint_check/933/

Revision history for this message
Ryan Beisner (1chb1n) wrote :

UOSCI bot says:
charm_unit_test #768 cinder-next for hopem mp241084
    UNIT OK: passed

UNIT Results (max last 5 lines):
  hooks/cinder_hooks 204 13 94% 99-100, 115, 122, 269-274, 279-280, 299-300
  hooks/cinder_utils 169 14 92% 186, 398-403, 440-452
  TOTAL 425 33 92%
  Ran 84 tests in 5.462s
  OK

Full unit test output: http://paste.ubuntu.com/8868688/
Build: http://10.98.191.181:8080/job/charm_unit_test/768/

Revision history for this message
Ryan Beisner (1chb1n) wrote :

UOSCI bot says:
charm_amulet_test #351 cinder-next for hopem mp241084
    AMULET OK: passed

AMULET Results (max last 5 lines):
  juju-test.conductor.15-basic-trusty-icehouse RESULT :
  juju-test.conductor DEBUG : Tearing down osci-sv07 juju environment
  juju-test.conductor DEBUG : Calling "juju destroy-environment -y osci-sv07"
  WARNING cannot delete security group "juju-osci-sv07-0". Used by another environment?
  juju-test INFO : Results: 3 passed, 0 failed, 0 errored

Full amulet test output: http://paste.ubuntu.com/8868852/
Build: http://10.98.191.181:8080/job/charm_amulet_test/351/

Revision history for this message
Ryan Beisner (1chb1n) wrote :

UOSCI bot says:
charm_lint_check #934 cinder-next for hopem mp241084
    LINT OK: passed

LINT Results (max last 5 lines):
  I: config.yaml: option ssl_ca has no default value
  I: config.yaml: option config-flags has no default value
  I: config.yaml: option ssl_cert has no default value
  I: config.yaml: option os-internal-network has no default value
  I: config.yaml: option os-public-network has no default value

Full lint test output: http://paste.ubuntu.com/8870110/
Build: http://10.98.191.181:8080/job/charm_lint_check/934/

Revision history for this message
Ryan Beisner (1chb1n) wrote :

UOSCI bot says:
charm_unit_test #769 cinder-next for hopem mp241084
    UNIT FAIL: unit-test failed

UNIT Results (max last 5 lines):
  hooks/cinder_utils 169 14 92% 186, 398-403, 440-452
  TOTAL 427 37 91%
  Ran 84 tests in 5.261s
  FAILED (failures=1)
  make: *** [unit_test] Error 1

Full unit test output: http://paste.ubuntu.com/8870111/
Build: http://10.98.191.181:8080/job/charm_unit_test/769/

Revision history for this message
Ryan Beisner (1chb1n) wrote :

UOSCI bot says:
charm_amulet_test #352 cinder-next for hopem mp241084
    AMULET FAIL: amulet-test failed

AMULET Results (max last 5 lines):
  juju-test.conductor DEBUG : Calling "juju destroy-environment -y osci-sv07"
  WARNING cannot delete security group "juju-osci-sv07-0". Used by another environment?
  juju-test INFO : Results: 2 passed, 1 failed, 0 errored
  ERROR subprocess encountered error code 1
  make: *** [test] Error 1

Full amulet test output: http://paste.ubuntu.com/8870403/
Build: http://10.98.191.181:8080/job/charm_amulet_test/352/

Revision history for this message
Ryan Beisner (1chb1n) wrote :

UOSCI bot says:
charm_lint_check #973 cinder-next for hopem mp241084
    LINT OK: passed

LINT Results (max last 5 lines):
  I: config.yaml: option ssl_ca has no default value
  I: config.yaml: option config-flags has no default value
  I: config.yaml: option ssl_cert has no default value
  I: config.yaml: option os-internal-network has no default value
  I: config.yaml: option os-public-network has no default value

Full lint test output: http://paste.ubuntu.com/8903852/
Build: http://10.98.191.181:8080/job/charm_lint_check/973/

Revision history for this message
Ryan Beisner (1chb1n) wrote :

UOSCI bot says:
charm_unit_test #808 cinder-next for hopem mp241084
    UNIT OK: passed

UNIT Results (max last 5 lines):
  hooks/cinder_hooks 208 6 97% 104-105, 120, 127, 311-312
  hooks/cinder_utils 169 14 92% 186, 398-403, 440-452
  TOTAL 429 26 94%
  Ran 86 tests in 5.534s
  OK

Full unit test output: http://paste.ubuntu.com/8903855/
Build: http://10.98.191.181:8080/job/charm_unit_test/808/

Revision history for this message
Ryan Beisner (1chb1n) wrote :

UOSCI bot says:
charm_amulet_test #354 cinder-next for hopem mp241084
    AMULET FAIL: amulet-test failed

AMULET Results (max last 5 lines):
  juju-test.conductor DEBUG : Calling "juju destroy-environment -y osci-sv05"
  WARNING cannot delete security group "juju-osci-sv05-0". Used by another environment?
  juju-test INFO : Results: 1 passed, 2 failed, 0 errored
  ERROR subprocess encountered error code 2
  make: *** [test] Error 2

Full amulet test output: http://paste.ubuntu.com/8904109/
Build: http://10.98.191.181:8080/job/charm_amulet_test/354/

63. By Edward Hope-Morley

added ceph broker wrappers

64. By Edward Hope-Morley

added broker wrappers

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

UOSCI bot says:
charm_lint_check #1136 cinder-next for hopem mp241084
    LINT OK: passed

LINT Results (max last 5 lines):
  I: config.yaml: option ssl_ca has no default value
  I: config.yaml: option config-flags has no default value
  I: config.yaml: option ssl_cert has no default value
  I: config.yaml: option os-internal-network has no default value
  I: config.yaml: option os-public-network has no default value

Full lint test output: http://paste.ubuntu.com/9107805/
Build: http://10.98.191.181:8080/job/charm_lint_check/1136/

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

UOSCI bot says:
charm_unit_test #970 cinder-next for hopem mp241084
    UNIT OK: passed

UNIT Results (max last 5 lines):
  hooks/cinder_hooks 209 6 97% 107-108, 123, 130, 316-317
  hooks/cinder_utils 169 14 92% 186, 398-403, 440-452
  TOTAL 430 26 94%
  Ran 86 tests in 7.411s
  OK

Full unit test output: http://paste.ubuntu.com/9107808/
Build: http://10.98.191.181:8080/job/charm_unit_test/970/

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

UOSCI bot says:
charm_amulet_test #478 cinder-next for hopem mp241084
    AMULET FAIL: amulet-test failed

AMULET Results (max last 5 lines):
  subprocess.CalledProcessError: Command '['juju-deployer', '-W', '-L', '-c', '/tmp/amulet-juju-deployer-oTOPfc.json', '-e', 'osci-sv07', '-t', '1000', 'osci-sv07']' returned non-zero exit status 1
  WARNING cannot delete security group "juju-osci-sv07-0". Used by another environment?
  juju-test INFO : Results: 1 passed, 2 failed, 0 errored
  ERROR subprocess encountered error code 2
  make: *** [test] Error 2

Full amulet test output: http://paste.ubuntu.com/9108356/
Build: http://10.98.191.181:8080/job/charm_amulet_test/478/

65. By Edward Hope-Morley

don't stop/start cinder-volume on broker op

66. By Edward Hope-Morley

don't stop/start cinder-volume on broker op

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

UOSCI bot says:
charm_lint_check #1163 cinder-next for hopem mp241084
    LINT OK: passed

LINT Results (max last 5 lines):
  I: config.yaml: option ssl_ca has no default value
  I: config.yaml: option config-flags has no default value
  I: config.yaml: option ssl_cert has no default value
  I: config.yaml: option os-internal-network has no default value
  I: config.yaml: option os-public-network has no default value

Full lint test output: http://paste.ubuntu.com/9133387/
Build: http://10.98.191.181:8080/job/charm_lint_check/1163/

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

UOSCI bot says:
charm_unit_test #997 cinder-next for hopem mp241084
    UNIT OK: passed

UNIT Results (max last 5 lines):
  hooks/cinder_hooks 205 6 97% 105-106, 121, 128, 309-310
  hooks/cinder_utils 169 14 92% 186, 398-403, 440-452
  TOTAL 426 26 94%
  Ran 86 tests in 5.420s
  OK

Full unit test output: http://paste.ubuntu.com/9133390/
Build: http://10.98.191.181:8080/job/charm_unit_test/997/

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

UOSCI bot says:
charm_amulet_test #505 cinder-next for hopem mp241084
    AMULET FAIL: amulet-test failed

AMULET Results (max last 5 lines):
  WARNING cannot delete security group "juju-osci-sv07". Used by another environment?
  WARNING cannot delete security group "juju-osci-sv07-0". Used by another environment?
  juju-test INFO : Results: 0 passed, 1 failed, 2 errored
  ERROR subprocess encountered error code 1
  make: *** [test] Error 1

Full amulet test output: http://paste.ubuntu.com/9133990/
Build: http://10.98.191.181:8080/job/charm_amulet_test/505/

Revision history for this message
James Page (james-page) :
review: Needs Resubmitting
67. By Edward Hope-Morley

synced /next

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

charm_unit_test #191 cinder-next for hopem mp241084
    UNIT FAIL: unit-test failed

UNIT Results (max last 2 lines):
  FAILED (errors=2, failures=8)
  make: *** [unit_test] Error 1

Full unit test output: http://paste.ubuntu.com/9527068/
Build: http://10.245.162.77:8080/job/charm_unit_test/191/

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

charm_lint_check #157 cinder-next for hopem mp241084
    LINT OK: passed

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

68. By Edward Hope-Morley

synced ch

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

charm_amulet_test #171 cinder-next for hopem mp241084
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
  ERROR subprocess encountered error code 1
  make: *** [test] Error 1

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

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

charm_lint_check #168 cinder-next for hopem mp241084
    LINT OK: passed

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

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

charm_unit_test #202 cinder-next for hopem mp241084
    UNIT OK: passed

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

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

charm_amulet_test #182 cinder-next for hopem mp241084
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
  ERROR subprocess encountered error code 124
  make: *** [test] Error 124

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/charmhelpers/contrib/storage/linux/ceph.py'
2--- hooks/charmhelpers/contrib/storage/linux/ceph.py 2014-12-15 09:57:32 +0000
3+++ hooks/charmhelpers/contrib/storage/linux/ceph.py 2014-12-15 10:42:12 +0000
4@@ -372,3 +372,46 @@
5 return None
6 else:
7 return None
8+
9+
10+class CephBrokerRq(object):
11+ """Ceph broker request.
12+
13+ Multiple operations can be added to a request and sent to the Ceph broker
14+ to be executed.
15+
16+ Request is json-encoded for sending over the wire.
17+
18+ The API is versioned and defaults to version 1.
19+ """
20+ def __init__(self, api_version=1):
21+ self.api_version = api_version
22+ self.ops = []
23+
24+ def add_op_create_pool(self, name, replica_count=3):
25+ self.ops.append({'op': 'create-pool', 'name': name,
26+ 'replicas': replica_count})
27+
28+ @property
29+ def request(self):
30+ return json.dumps({'api-version': self.api_version, 'ops': self.ops})
31+
32+
33+class CephBrokerRsp(object):
34+ """Ceph broker response.
35+
36+ Response is json-decoded and contents provided as methods/properties.
37+
38+ The API is versioned and defaults to version 1.
39+ """
40+ def __init__(self, encoded_rsp):
41+ self.api_version = None
42+ self.rsp = json.loads(encoded_rsp)
43+
44+ @property
45+ def exit_code(self):
46+ return self.rsp.get('exit-code')
47+
48+ @property
49+ def exit_msg(self):
50+ return self.rsp.get('stderr')
51
52=== modified file 'hooks/cinder_hooks.py'
53--- hooks/cinder_hooks.py 2014-10-09 19:51:49 +0000
54+++ hooks/cinder_hooks.py 2014-12-15 10:42:12 +0000
55@@ -1,5 +1,4 @@
56 #!/usr/bin/python
57-
58 import os
59 import sys
60 import uuid
61@@ -9,7 +8,6 @@
62 from cinder_utils import (
63 determine_packages,
64 do_openstack_upgrade,
65- ensure_ceph_pool,
66 juju_log,
67 migrate_database,
68 configure_lvm_storage,
69@@ -37,6 +35,7 @@
70 unit_get,
71 log,
72 ERROR,
73+ INFO
74 )
75
76 from charmhelpers.fetch import (
77@@ -44,14 +43,21 @@
78 apt_update
79 )
80
81-from charmhelpers.core.host import lsb_release, restart_on_change
82+from charmhelpers.core.host import (
83+ lsb_release,
84+ restart_on_change,
85+)
86
87 from charmhelpers.contrib.openstack.utils import (
88 configure_installation_source,
89 openstack_upgrade_available,
90 sync_db_with_multi_ipv6_addresses)
91
92-from charmhelpers.contrib.storage.linux.ceph import ensure_ceph_keyring
93+from charmhelpers.contrib.storage.linux.ceph import (
94+ ensure_ceph_keyring,
95+ CephBrokerRq,
96+ CephBrokerRsp,
97+)
98
99 from charmhelpers.contrib.hahelpers.cluster import (
100 eligible_leader,
101@@ -254,23 +260,38 @@
102
103 @hooks.hook('ceph-relation-changed')
104 @restart_on_change(restart_map())
105-def ceph_changed():
106+def ceph_changed(relation_id=None):
107 if 'ceph' not in CONFIGS.complete_contexts():
108 juju_log('ceph relation incomplete. Peer not ready?')
109 return
110- svc = service_name()
111- if not ensure_ceph_keyring(service=svc,
112+
113+ service = service_name()
114+ if not ensure_ceph_keyring(service=service,
115 user='cinder', group='cinder'):
116 juju_log('Could not create ceph keyring: peer not ready?')
117 return
118- CONFIGS.write(CINDER_CONF)
119- CONFIGS.write(ceph_config_file())
120- set_ceph_env_variables(service=svc)
121-
122- if eligible_leader(CLUSTER_RES):
123- _config = config()
124- ensure_ceph_pool(service=svc,
125- replicas=_config['ceph-osd-replication-count'])
126+
127+ settings = relation_get(rid=relation_id)
128+ if settings and 'broker_rsp' in settings:
129+ rsp = CephBrokerRsp(settings['broker_rsp'])
130+ # Non-zero return code implies failure
131+ if rsp.exit_code:
132+ log("Ceph broker request failed (rc=%s, msg=%s)" %
133+ (rsp.exit_code, rsp.exit_msg), level=ERROR)
134+ return
135+
136+ log("Ceph broker request succeeded (rc=%s, msg=%s)" %
137+ (rsp.exit_code, rsp.exit_msg), level=INFO)
138+ set_ceph_env_variables(service=service)
139+ CONFIGS.write(CINDER_CONF)
140+ CONFIGS.write(ceph_config_file())
141+ else:
142+ rq = CephBrokerRq()
143+ replicas = config('ceph-osd-replication-count')
144+ rq.add_op_create_pool(name=service, replica_count=replicas)
145+ for rid in relation_ids('ceph'):
146+ relation_set(relation_id=rid, broker_req=rq.request)
147+ log("Request(s) sent to Ceph broker (rid=%s)" % (rid))
148
149
150 @hooks.hook('cluster-relation-joined')
151
152=== modified file 'hooks/cinder_utils.py'
153--- hooks/cinder_utils.py 2014-12-15 09:57:32 +0000
154+++ hooks/cinder_utils.py 2014-12-15 10:42:12 +0000
155@@ -27,11 +27,6 @@
156 lsb_release
157 )
158
159-from charmhelpers.contrib.storage.linux.ceph import (
160- create_pool as ceph_create_pool,
161- pool_exists as ceph_pool_exists,
162-)
163-
164 from charmhelpers.contrib.openstack.alternatives import install_alternative
165 from charmhelpers.contrib.hahelpers.cluster import (
166 eligible_leader,
167@@ -411,13 +406,6 @@
168 subprocess.check_call(cmd)
169
170
171-def ensure_ceph_pool(service, replicas):
172- 'Creates a ceph pool for service if one does not exist'
173- # TODO(Ditto about moving somewhere sharable)
174- if not ceph_pool_exists(service=service, name=service):
175- ceph_create_pool(service=service, name=service, replicas=replicas)
176-
177-
178 def set_ceph_env_variables(service):
179 # XXX: Horrid kludge to make cinder-volume use
180 # a different ceph username than admin
181
182=== modified file 'unit_tests/test_cinder_hooks.py'
183--- unit_tests/test_cinder_hooks.py 2014-10-14 15:59:34 +0000
184+++ unit_tests/test_cinder_hooks.py 2014-12-15 10:42:12 +0000
185@@ -1,10 +1,14 @@
186-from mock import MagicMock, patch, call
187+import json
188+from mock import (
189+ MagicMock,
190+ patch,
191+ call
192+)
193
194 import cinder_utils as utils
195-
196 from test_utils import (
197 CharmTestCase,
198- RESTART_MAP,
199+ RESTART_MAP
200 )
201
202 # Need to do some early patching to get the module loaded.
203@@ -31,7 +35,6 @@
204 'determine_packages',
205 'do_openstack_upgrade',
206 'ensure_ceph_keyring',
207- 'ensure_ceph_pool',
208 'juju_log',
209 'log',
210 'lsb_release',
211@@ -362,22 +365,64 @@
212 m = 'ceph relation incomplete. Peer not ready?'
213 self.juju_log.assert_called_with(m)
214
215- def test_ceph_changed(self):
216+ @patch("cinder_hooks.relation_set")
217+ @patch("cinder_hooks.relation_get")
218+ def test_ceph_changed_broker_send_rq(self, mock_relation_get,
219+ mock_relation_set):
220+ self.CONFIGS.complete_contexts.return_value = ['ceph']
221+ self.service_name.return_value = 'cinder'
222+ self.ensure_ceph_keyring.return_value = True
223+ self.ceph_config_file.return_value = '/var/lib/charm/cinder/ceph.conf'
224+ self.relation_ids.return_value = ['ceph:0']
225+ hooks.hooks.execute(['hooks/ceph-relation-changed'])
226+ self.ensure_ceph_keyring.assert_called_with(service='cinder',
227+ user='cinder',
228+ group='cinder')
229+ req = {'api-version': 1,
230+ 'ops': [{"op": "create-pool", "name": "cinder", "replicas": 3}]}
231+ broker_dict = json.dumps(req)
232+ mock_relation_set.assert_called_with(broker_req=broker_dict,
233+ relation_id='ceph:0')
234+ for c in [call('/var/lib/charm/cinder/ceph.conf'),
235+ call('/etc/cinder/cinder.conf')]:
236+ self.assertNotIn(c, self.CONFIGS.write.call_args_list)
237+ self.assertFalse(self.set_ceph_env_variables.called)
238+
239+ @patch("cinder_hooks.relation_get", autospec=True)
240+ def test_ceph_changed_broker_success(self, mock_relation_get):
241 'It ensures ceph assets created on ceph changed'
242 self.CONFIGS.complete_contexts.return_value = ['ceph']
243 self.service_name.return_value = 'cinder'
244 self.ensure_ceph_keyring.return_value = True
245 self.ceph_config_file.return_value = '/var/lib/charm/cinder/ceph.conf'
246+ mock_relation_get.return_value = {'broker_rsp':
247+ json.dumps({'exit-code': 0})}
248 hooks.hooks.execute(['hooks/ceph-relation-changed'])
249 self.ensure_ceph_keyring.assert_called_with(service='cinder',
250 user='cinder',
251 group='cinder')
252- self.ensure_ceph_pool.assert_called_with(service='cinder', replicas=3)
253 for c in [call('/var/lib/charm/cinder/ceph.conf'),
254 call('/etc/cinder/cinder.conf')]:
255 self.assertIn(c, self.CONFIGS.write.call_args_list)
256 self.set_ceph_env_variables.assert_called_with(service='cinder')
257
258+ @patch("cinder_hooks.relation_get", autospec=True)
259+ def test_ceph_changed_broker_nonzero_rc(self, mock_relation_get):
260+ self.CONFIGS.complete_contexts.return_value = ['ceph']
261+ self.service_name.return_value = 'cinder'
262+ self.ensure_ceph_keyring.return_value = True
263+ self.ceph_config_file.return_value = '/var/lib/charm/cinder/ceph.conf'
264+ mock_relation_get.return_value = {'broker_rsp':
265+ json.dumps({'exit-code': 1})}
266+ hooks.hooks.execute(['hooks/ceph-relation-changed'])
267+ self.ensure_ceph_keyring.assert_called_with(service='cinder',
268+ user='cinder',
269+ group='cinder')
270+ for c in [call('/var/lib/charm/cinder/ceph.conf'),
271+ call('/etc/cinder/cinder.conf')]:
272+ self.assertNotIn(c, self.CONFIGS.write.call_args_list)
273+ self.assertFalse(self.set_ceph_env_variables.called)
274+
275 def test_ceph_changed_no_keys(self):
276 'It ensures ceph assets created on ceph changed'
277 self.CONFIGS.complete_contexts.return_value = ['ceph']
278@@ -395,7 +440,6 @@
279 self.service_name.return_value = 'cinder'
280 self.ensure_ceph_keyring.return_value = True
281 hooks.hooks.execute(['hooks/ceph-relation-changed'])
282- self.assertFalse(self.ensure_ceph_pool.called)
283
284
285 class TestDepartedHooks(CharmTestCase):
286
287=== modified file 'unit_tests/test_cinder_utils.py'
288--- unit_tests/test_cinder_utils.py 2014-11-29 14:58:42 +0000
289+++ unit_tests/test_cinder_utils.py 2014-12-15 10:42:12 +0000
290@@ -19,8 +19,6 @@
291 'umount',
292 'mkdir',
293 # ceph utils
294- 'ceph_create_pool',
295- 'ceph_pool_exists',
296 # storage_utils
297 'create_lvm_physical_volume',
298 'create_lvm_volume_group',
299@@ -401,18 +399,6 @@
300 cinder_utils.migrate_database()
301 check_call.assert_called_with(['cinder-manage', 'db', 'sync'])
302
303- def test_ensure_ceph_pool(self):
304- self.ceph_pool_exists.return_value = False
305- cinder_utils.ensure_ceph_pool(service='cinder', replicas=3)
306- self.ceph_create_pool.assert_called_with(service='cinder',
307- name='cinder',
308- replicas=3)
309-
310- def test_ensure_ceph_pool_already_exists(self):
311- self.ceph_pool_exists.return_value = True
312- cinder_utils.ensure_ceph_pool(service='cinder', replicas=3)
313- self.assertFalse(self.ceph_create_pool.called)
314-
315 @patch('os.path.exists')
316 def test_register_configs_apache(self, exists):
317 exists.return_value = False
318
319=== modified file 'unit_tests/test_cluster_hooks.py'
320--- unit_tests/test_cluster_hooks.py 2014-10-01 22:07:44 +0000
321+++ unit_tests/test_cluster_hooks.py 2014-12-15 10:42:12 +0000
322@@ -26,8 +26,6 @@
323 TO_PATCH = [
324 # cinder_utils
325 'determine_packages',
326- 'ensure_ceph_keyring',
327- 'ensure_ceph_pool',
328 'juju_log',
329 'lsb_release',
330 'migrate_database',

Subscribers

People subscribed via source and target branches