52.3.1
by yolanda.robla at canonical
added postgresql support |
1 |
from mock import call, patch, MagicMock |
2 |
import os |
|
73.2.35
by Edward Hope-Morley
synced charm-helpers |
3 |
import json |
96.1.4
by Edward Hope-Morley
Fixed a few race issues and switched to using decorators |
4 |
import uuid |
88.4.18
by Corey Bryant
Add deploy from source action support and various fixups after rebase |
5 |
import yaml |
52.3.1
by yolanda.robla at canonical
added postgresql support |
6 |
|
7 |
from test_utils import CharmTestCase |
|
8 |
||
9 |
os.environ['JUJU_UNIT_NAME'] = 'keystone' |
|
10 |
with patch('charmhelpers.core.hookenv.config') as config: |
|
11 |
config.return_value = 'keystone' |
|
12 |
import keystone_utils as utils |
|
13 |
||
14 |
_reg = utils.register_configs |
|
15 |
_map = utils.restart_map |
|
16 |
||
17 |
utils.register_configs = MagicMock() |
|
18 |
utils.restart_map = MagicMock() |
|
19 |
||
20 |
import keystone_hooks as hooks |
|
52.4.1
by yolanda.robla at canonical
added unit testing |
21 |
from charmhelpers.contrib import unison |
52.3.1
by yolanda.robla at canonical
added postgresql support |
22 |
|
23 |
utils.register_configs = _reg |
|
24 |
utils.restart_map = _map |
|
25 |
||
26 |
TO_PATCH = [ |
|
27 |
# charmhelpers.core.hookenv
|
|
28 |
'Hooks', |
|
29 |
'config', |
|
30 |
'is_relation_made', |
|
31 |
'log', |
|
76.1.2
by Liam Young
Add unit tests for db_changed hook processing allowed_units |
32 |
'local_unit', |
52.4.5
by yolanda.robla at canonical
mocking extra calls |
33 |
'filter_installed_packages', |
52.3.1
by yolanda.robla at canonical
added postgresql support |
34 |
'relation_ids', |
35 |
'relation_set', |
|
36 |
'relation_get', |
|
52.4.1
by yolanda.robla at canonical
added unit testing |
37 |
'related_units', |
52.3.1
by yolanda.robla at canonical
added postgresql support |
38 |
'unit_get', |
52.4.1
by yolanda.robla at canonical
added unit testing |
39 |
'peer_echo', |
52.3.1
by yolanda.robla at canonical
added postgresql support |
40 |
# charmhelpers.core.host
|
41 |
'apt_install', |
|
42 |
'apt_update', |
|
43 |
'restart_on_change', |
|
44 |
# charmhelpers.contrib.openstack.utils
|
|
45 |
'configure_installation_source', |
|
96.1.12
by Edward Hope-Morley
validate echoed peer data |
46 |
# charmhelpers.contrib.openstack.ip
|
47 |
'resolve_address', |
|
52.3.1
by yolanda.robla at canonical
added postgresql support |
48 |
# charmhelpers.contrib.hahelpers.cluster_utils
|
96.1.1
by Edward Hope-Morley
[hopem,r=] |
49 |
'is_elected_leader', |
68.2.18
by james.page at ubuntu
Align ha-joined hook with other charms |
50 |
'get_hacluster_config', |
52.3.1
by yolanda.robla at canonical
added postgresql support |
51 |
# keystone_utils
|
52 |
'restart_map', |
|
53 |
'register_configs', |
|
54 |
'do_openstack_upgrade', |
|
52.4.1
by yolanda.robla at canonical
added unit testing |
55 |
'openstack_upgrade_available', |
56 |
'save_script_rc', |
|
52.3.1
by yolanda.robla at canonical
added postgresql support |
57 |
'migrate_database', |
52.4.1
by yolanda.robla at canonical
added unit testing |
58 |
'ensure_initial_admin', |
59 |
'add_service_to_keystone', |
|
96.1.4
by Edward Hope-Morley
Fixed a few race issues and switched to using decorators |
60 |
'synchronize_ca_if_changed', |
87.3.11
by Liam Young
Fix unit tests |
61 |
'update_nrpe_config', |
52.3.1
by yolanda.robla at canonical
added postgresql support |
62 |
# other
|
63 |
'check_call', |
|
64 |
'execd_preinstall', |
|
52.4.1
by yolanda.robla at canonical
added unit testing |
65 |
'mkdir', |
66 |
'os', |
|
68.2.15
by james.page at ubuntu
Add support for multi-vip clustering, update unit tests |
67 |
# ip
|
68 |
'get_iface_for_address', |
|
68.2.16
by james.page at ubuntu
Tidy lint |
69 |
'get_netmask_for_address', |
79.1.15
by james.page at ubuntu
Use internal address for haproxy if set, call cluster_joined on config-change hook |
70 |
'get_address_in_network', |
88.4.11
by Corey Bryant
Unit tests for deploy from git. |
71 |
'git_install', |
52.3.1
by yolanda.robla at canonical
added postgresql support |
72 |
]
|
73 |
||
74 |
||
75 |
class KeystoneRelationTests(CharmTestCase): |
|
76 |
||
77 |
def setUp(self): |
|
78 |
super(KeystoneRelationTests, self).setUp(hooks, TO_PATCH) |
|
79 |
self.config.side_effect = self.test_config.get |
|
52.4.1
by yolanda.robla at canonical
added unit testing |
80 |
self.ssh_user = 'juju_keystone' |
52.3.1
by yolanda.robla at canonical
added postgresql support |
81 |
|
88.4.11
by Corey Bryant
Unit tests for deploy from git. |
82 |
@patch.object(utils, 'git_install_requested') |
83 |
def test_install_hook(self, git_requested): |
|
84 |
git_requested.return_value = False |
|
52.4.1
by yolanda.robla at canonical
added unit testing |
85 |
repo = 'cloud:precise-grizzly' |
86 |
self.test_config.set('openstack-origin', repo) |
|
87 |
hooks.install() |
|
88.4.11
by Corey Bryant
Unit tests for deploy from git. |
88 |
self.assertTrue(self.execd_preinstall.called) |
52.4.1
by yolanda.robla at canonical
added unit testing |
89 |
self.configure_installation_source.assert_called_with(repo) |
90 |
self.assertTrue(self.apt_update.called) |
|
52.2.29
by James Page
Final tidy |
91 |
self.apt_install.assert_called_with( |
92 |
['haproxy', 'unison', 'python-keystoneclient', |
|
93 |
'uuid', 'python-mysqldb', 'openssl', 'apache2', |
|
92.1.2
by Ryan Beisner
update unit test |
94 |
'pwgen', 'python-six', 'keystone', 'python-psycopg2'], fatal=True) |
88.4.48
by Corey Bryant
unit test updates |
95 |
self.git_install.assert_called_with(None) |
88.4.11
by Corey Bryant
Unit tests for deploy from git. |
96 |
|
97 |
@patch.object(utils, 'git_install_requested') |
|
98 |
def test_install_hook_git(self, git_requested): |
|
99 |
git_requested.return_value = True |
|
88.4.18
by Corey Bryant
Add deploy from source action support and various fixups after rebase |
100 |
repo = 'cloud:trusty-juno' |
101 |
openstack_origin_git = { |
|
88.4.29
by Corey Bryant
mock updates |
102 |
'repositories': [ |
88.4.34
by Corey Bryant
Fix lint errors |
103 |
{'name': 'requirements', |
104 |
'repository': 'git://git.openstack.org/openstack/requirements', # noqa |
|
105 |
'branch': 'stable/juno'}, |
|
106 |
{'name': 'keystone', |
|
107 |
'repository': 'git://git.openstack.org/openstack/keystone', |
|
108 |
'branch': 'stable/juno'} |
|
88.4.29
by Corey Bryant
mock updates |
109 |
],
|
110 |
'directory': '/mnt/openstack-git', |
|
88.4.18
by Corey Bryant
Add deploy from source action support and various fixups after rebase |
111 |
}
|
88.4.29
by Corey Bryant
mock updates |
112 |
projects_yaml = yaml.dump(openstack_origin_git) |
88.4.11
by Corey Bryant
Unit tests for deploy from git. |
113 |
self.test_config.set('openstack-origin', repo) |
88.4.29
by Corey Bryant
mock updates |
114 |
self.test_config.set('openstack-origin-git', projects_yaml) |
88.4.11
by Corey Bryant
Unit tests for deploy from git. |
115 |
hooks.install() |
52.4.1
by yolanda.robla at canonical
added unit testing |
116 |
self.assertTrue(self.execd_preinstall.called) |
88.4.11
by Corey Bryant
Unit tests for deploy from git. |
117 |
self.configure_installation_source.assert_called_with(repo) |
118 |
self.assertTrue(self.apt_update.called) |
|
119 |
self.apt_install.assert_called_with( |
|
176
by Corey Bryant
Unit test updates |
120 |
['haproxy', 'unison', 'python-setuptools', 'python-keystoneclient', |
180
by Corey Bryant
Add libssl-dev to base git pkgs |
121 |
'uuid', 'python-mysqldb', 'libmysqlclient-dev', 'libssl-dev', |
122 |
'openssl', 'libffi-dev', 'apache2', 'python-pip', 'pwgen', |
|
186
by Corey Bryant
Add libyaml-dev as base git package |
123 |
'python-six', 'libxslt1-dev', 'python-psycopg2', 'libyaml-dev', |
124 |
'zlib1g-dev', 'python-dev', 'libxml2-dev'], |
|
143.1.1
by Corey Bryant
Change default mkdir permissions to 755 for deploy from source |
125 |
fatal=True) |
88.4.29
by Corey Bryant
mock updates |
126 |
self.git_install.assert_called_with(projects_yaml) |
52.3.1
by yolanda.robla at canonical
added postgresql support |
127 |
|
73.2.33
by Edward Hope-Morley
fixed db_joined() and unit tests |
128 |
mod_ch_openstack_utils = 'charmhelpers.contrib.openstack.utils' |
129 |
||
130 |
@patch.object(hooks, 'config') |
|
131 |
@patch('%s.config' % (mod_ch_openstack_utils)) |
|
132 |
@patch('%s.relation_set' % (mod_ch_openstack_utils)) |
|
133 |
@patch('%s.relation_ids' % (mod_ch_openstack_utils)) |
|
134 |
@patch('%s.get_ipv6_addr' % (mod_ch_openstack_utils)) |
|
135 |
@patch('%s.sync_db_with_multi_ipv6_addresses' % (mod_ch_openstack_utils)) |
|
136 |
def test_db_joined(self, mock_sync_db_with_multi, mock_get_ipv6_addr, |
|
137 |
mock_relation_ids, mock_relation_set, mock_config, |
|
138 |
mock_hooks_config): |
|
139 |
||
140 |
cfg_dict = {'prefer-ipv6': False, |
|
141 |
'database': 'keystone', |
|
142 |
'database-user': 'keystone'} |
|
143 |
||
144 |
class mock_cls_config(): |
|
145 |
def __call__(self, key): |
|
146 |
return cfg_dict[key] |
|
147 |
||
148 |
cfg = mock_cls_config() |
|
149 |
mock_hooks_config.side_effect = cfg |
|
150 |
mock_config.side_effect = cfg |
|
151 |
||
152 |
self.is_relation_made.return_value = False |
|
52.3.1
by yolanda.robla at canonical
added postgresql support |
153 |
self.unit_get.return_value = 'keystone.foohost.com' |
154 |
hooks.db_joined() |
|
155 |
self.relation_set.assert_called_with(database='keystone', |
|
156 |
username='keystone', |
|
157 |
hostname='keystone.foohost.com') |
|
158 |
self.unit_get.assert_called_with('private-address') |
|
159 |
||
73.2.33
by Edward Hope-Morley
fixed db_joined() and unit tests |
160 |
cfg_dict['prefer-ipv6'] = True |
161 |
mock_hooks_config.side_effect = mock_cls_config() |
|
162 |
mock_relation_ids.return_value = ['shared-db'] |
|
163 |
mock_get_ipv6_addr.return_value = ['keystone.foohost.com'] |
|
164 |
self.is_relation_made.return_value = False |
|
165 |
hooks.db_joined() |
|
73.2.35
by Edward Hope-Morley
synced charm-helpers |
166 |
|
167 |
hosts = json.dumps(['keystone.foohost.com']) |
|
73.2.33
by Edward Hope-Morley
fixed db_joined() and unit tests |
168 |
mock_relation_set.assert_called_with(relation_id='shared-db', |
169 |
database='keystone', |
|
170 |
username='keystone', |
|
73.2.35
by Edward Hope-Morley
synced charm-helpers |
171 |
hostname=hosts) |
73.2.33
by Edward Hope-Morley
fixed db_joined() and unit tests |
172 |
|
52.3.1
by yolanda.robla at canonical
added postgresql support |
173 |
def test_postgresql_db_joined(self): |
174 |
self.unit_get.return_value = 'keystone.foohost.com' |
|
175 |
self.is_relation_made.return_value = False |
|
176 |
hooks.pgsql_db_joined() |
|
177 |
self.relation_set.assert_called_with(database='keystone'), |
|
178 |
||
179 |
def test_db_joined_with_postgresql(self): |
|
180 |
self.is_relation_made.return_value = True |
|
181 |
||
182 |
with self.assertRaises(Exception) as context: |
|
183 |
hooks.db_joined() |
|
52.4.1
by yolanda.robla at canonical
added unit testing |
184 |
self.assertEqual( |
185 |
context.exception.message, |
|
52.3.1
by yolanda.robla at canonical
added postgresql support |
186 |
'Attempting to associate a mysql database when there '
|
52.4.1
by yolanda.robla at canonical
added unit testing |
187 |
'is already associated a postgresql one') |
52.3.1
by yolanda.robla at canonical
added postgresql support |
188 |
|
189 |
def test_postgresql_joined_with_db(self): |
|
190 |
self.is_relation_made.return_value = True |
|
191 |
||
192 |
with self.assertRaises(Exception) as context: |
|
193 |
hooks.pgsql_db_joined() |
|
52.4.1
by yolanda.robla at canonical
added unit testing |
194 |
self.assertEqual( |
195 |
context.exception.message, |
|
52.3.1
by yolanda.robla at canonical
added postgresql support |
196 |
'Attempting to associate a postgresql database when there '
|
52.4.1
by yolanda.robla at canonical
added unit testing |
197 |
'is already associated a mysql one') |
52.3.1
by yolanda.robla at canonical
added postgresql support |
198 |
|
96.1.4
by Edward Hope-Morley
Fixed a few race issues and switched to using decorators |
199 |
@patch('keystone_utils.log') |
96.1.13
by Edward Hope-Morley
add sync-master stickiness back into the mix |
200 |
@patch('keystone_utils.ensure_ssl_cert_master') |
52.3.1
by yolanda.robla at canonical
added postgresql support |
201 |
@patch.object(hooks, 'CONFIGS') |
96.1.11
by Edward Hope-Morley
add leader protection to cluster-changed hook |
202 |
def test_db_changed_missing_relation_data(self, configs, |
96.1.13
by Edward Hope-Morley
add sync-master stickiness back into the mix |
203 |
mock_ensure_ssl_cert_master, |
96.1.4
by Edward Hope-Morley
Fixed a few race issues and switched to using decorators |
204 |
mock_log): |
96.1.13
by Edward Hope-Morley
add sync-master stickiness back into the mix |
205 |
mock_ensure_ssl_cert_master.return_value = False |
52.3.1
by yolanda.robla at canonical
added postgresql support |
206 |
configs.complete_contexts = MagicMock() |
207 |
configs.complete_contexts.return_value = [] |
|
208 |
hooks.db_changed() |
|
209 |
self.log.assert_called_with( |
|
210 |
'shared-db relation incomplete. Peer not ready?'
|
|
211 |
)
|
|
212 |
||
96.1.10
by Edward Hope-Morley
tests passing and cleanup |
213 |
@patch('keystone_utils.log') |
96.1.13
by Edward Hope-Morley
add sync-master stickiness back into the mix |
214 |
@patch('keystone_utils.ensure_ssl_cert_master') |
52.3.1
by yolanda.robla at canonical
added postgresql support |
215 |
@patch.object(hooks, 'CONFIGS') |
96.1.10
by Edward Hope-Morley
tests passing and cleanup |
216 |
def test_postgresql_db_changed_missing_relation_data(self, configs, |
96.1.13
by Edward Hope-Morley
add sync-master stickiness back into the mix |
217 |
mock_ensure_leader, |
96.1.10
by Edward Hope-Morley
tests passing and cleanup |
218 |
mock_log): |
96.1.13
by Edward Hope-Morley
add sync-master stickiness back into the mix |
219 |
mock_ensure_leader.return_value = False |
52.3.1
by yolanda.robla at canonical
added postgresql support |
220 |
configs.complete_contexts = MagicMock() |
221 |
configs.complete_contexts.return_value = [] |
|
222 |
hooks.pgsql_db_changed() |
|
223 |
self.log.assert_called_with( |
|
224 |
'pgsql-db relation incomplete. Peer not ready?'
|
|
225 |
)
|
|
226 |
||
76.1.2
by Liam Young
Add unit tests for db_changed hook processing allowed_units |
227 |
def _shared_db_test(self, configs, unit_name): |
228 |
self.relation_get.return_value = 'keystone/0 keystone/3' |
|
229 |
self.local_unit.return_value = unit_name |
|
52.3.1
by yolanda.robla at canonical
added postgresql support |
230 |
configs.complete_contexts = MagicMock() |
231 |
configs.complete_contexts.return_value = ['shared-db'] |
|
232 |
configs.write = MagicMock() |
|
233 |
hooks.db_changed() |
|
234 |
||
235 |
def _postgresql_db_test(self, configs): |
|
236 |
configs.complete_contexts = MagicMock() |
|
237 |
configs.complete_contexts.return_value = ['pgsql-db'] |
|
238 |
configs.write = MagicMock() |
|
239 |
hooks.pgsql_db_changed() |
|
52.4.1
by yolanda.robla at canonical
added unit testing |
240 |
|
120.1.3
by Edward Hope-Morley
more |
241 |
@patch.object(hooks, 'is_db_initialised') |
109.1.1
by Edward Hope-Morley
[hopem, r=] |
242 |
@patch.object(hooks, 'is_db_ready') |
96.1.4
by Edward Hope-Morley
Fixed a few race issues and switched to using decorators |
243 |
@patch('keystone_utils.log') |
96.1.13
by Edward Hope-Morley
add sync-master stickiness back into the mix |
244 |
@patch('keystone_utils.ensure_ssl_cert_master') |
52.4.1
by yolanda.robla at canonical
added unit testing |
245 |
@patch.object(hooks, 'CONFIGS') |
246 |
@patch.object(hooks, 'identity_changed') |
|
96.1.4
by Edward Hope-Morley
Fixed a few race issues and switched to using decorators |
247 |
def test_db_changed_allowed(self, identity_changed, configs, |
96.1.13
by Edward Hope-Morley
add sync-master stickiness back into the mix |
248 |
mock_ensure_ssl_cert_master, |
120.1.3
by Edward Hope-Morley
more |
249 |
mock_log, mock_is_db_ready, |
250 |
mock_is_db_initialised): |
|
251 |
mock_is_db_initialised.return_value = True |
|
109.1.1
by Edward Hope-Morley
[hopem, r=] |
252 |
mock_is_db_ready.return_value = True |
96.1.13
by Edward Hope-Morley
add sync-master stickiness back into the mix |
253 |
mock_ensure_ssl_cert_master.return_value = False |
52.4.1
by yolanda.robla at canonical
added unit testing |
254 |
self.relation_ids.return_value = ['identity-service:0'] |
255 |
self.related_units.return_value = ['unit/0'] |
|
256 |
||
76.1.2
by Liam Young
Add unit tests for db_changed hook processing allowed_units |
257 |
self._shared_db_test(configs, 'keystone/3') |
52.4.1
by yolanda.robla at canonical
added unit testing |
258 |
self.assertEquals([call('/etc/keystone/keystone.conf')], |
259 |
configs.write.call_args_list) |
|
260 |
self.migrate_database.assert_called_with() |
|
52.4.8
by yolanda.robla at canonical
changing assert_called |
261 |
self.assertTrue(self.ensure_initial_admin.called) |
52.2.29
by James Page
Final tidy |
262 |
identity_changed.assert_called_with( |
263 |
relation_id='identity-service:0', |
|
264 |
remote_unit='unit/0') |
|
52.4.1
by yolanda.robla at canonical
added unit testing |
265 |
|
109.1.1
by Edward Hope-Morley
[hopem, r=] |
266 |
@patch.object(hooks, 'is_db_ready') |
96.1.4
by Edward Hope-Morley
Fixed a few race issues and switched to using decorators |
267 |
@patch('keystone_utils.log') |
96.1.13
by Edward Hope-Morley
add sync-master stickiness back into the mix |
268 |
@patch('keystone_utils.ensure_ssl_cert_master') |
52.4.1
by yolanda.robla at canonical
added unit testing |
269 |
@patch.object(hooks, 'CONFIGS') |
270 |
@patch.object(hooks, 'identity_changed') |
|
96.1.4
by Edward Hope-Morley
Fixed a few race issues and switched to using decorators |
271 |
def test_db_changed_not_allowed(self, identity_changed, configs, |
109.1.1
by Edward Hope-Morley
[hopem, r=] |
272 |
mock_ensure_ssl_cert_master, mock_log, |
273 |
mock_is_db_ready): |
|
274 |
mock_is_db_ready.return_value = False |
|
96.1.13
by Edward Hope-Morley
add sync-master stickiness back into the mix |
275 |
mock_ensure_ssl_cert_master.return_value = False |
76.1.2
by Liam Young
Add unit tests for db_changed hook processing allowed_units |
276 |
self.relation_ids.return_value = ['identity-service:0'] |
277 |
self.related_units.return_value = ['unit/0'] |
|
278 |
||
279 |
self._shared_db_test(configs, 'keystone/2') |
|
280 |
self.assertEquals([call('/etc/keystone/keystone.conf')], |
|
281 |
configs.write.call_args_list) |
|
282 |
self.assertFalse(self.migrate_database.called) |
|
283 |
self.assertFalse(self.ensure_initial_admin.called) |
|
284 |
self.assertFalse(identity_changed.called) |
|
285 |
||
96.1.4
by Edward Hope-Morley
Fixed a few race issues and switched to using decorators |
286 |
@patch('keystone_utils.log') |
96.1.13
by Edward Hope-Morley
add sync-master stickiness back into the mix |
287 |
@patch('keystone_utils.ensure_ssl_cert_master') |
120.1.3
by Edward Hope-Morley
more |
288 |
@patch.object(hooks, 'is_db_initialised') |
116.1.1
by Edward Hope-Morley
add more is_db_ready() protection |
289 |
@patch.object(hooks, 'is_db_ready') |
76.1.2
by Liam Young
Add unit tests for db_changed hook processing allowed_units |
290 |
@patch.object(hooks, 'CONFIGS') |
291 |
@patch.object(hooks, 'identity_changed') |
|
96.1.4
by Edward Hope-Morley
Fixed a few race issues and switched to using decorators |
292 |
def test_postgresql_db_changed(self, identity_changed, configs, |
120.1.3
by Edward Hope-Morley
more |
293 |
mock_is_db_ready, mock_is_db_initialised, |
96.1.13
by Edward Hope-Morley
add sync-master stickiness back into the mix |
294 |
mock_ensure_ssl_cert_master, mock_log): |
120.1.3
by Edward Hope-Morley
more |
295 |
mock_is_db_initialised.return_value = True |
116.1.1
by Edward Hope-Morley
add more is_db_ready() protection |
296 |
mock_is_db_ready.return_value = True |
96.1.13
by Edward Hope-Morley
add sync-master stickiness back into the mix |
297 |
mock_ensure_ssl_cert_master.return_value = False |
52.4.1
by yolanda.robla at canonical
added unit testing |
298 |
self.relation_ids.return_value = ['identity-service:0'] |
299 |
self.related_units.return_value = ['unit/0'] |
|
300 |
||
301 |
self._postgresql_db_test(configs) |
|
302 |
self.assertEquals([call('/etc/keystone/keystone.conf')], |
|
303 |
configs.write.call_args_list) |
|
304 |
self.migrate_database.assert_called_with() |
|
52.4.8
by yolanda.robla at canonical
changing assert_called |
305 |
self.assertTrue(self.ensure_initial_admin.called) |
52.2.29
by James Page
Final tidy |
306 |
identity_changed.assert_called_with( |
307 |
relation_id='identity-service:0', |
|
308 |
remote_unit='unit/0') |
|
52.4.1
by yolanda.robla at canonical
added unit testing |
309 |
|
88.4.11
by Corey Bryant
Unit tests for deploy from git. |
310 |
@patch.object(hooks, 'git_install_requested') |
96.1.10
by Edward Hope-Morley
tests passing and cleanup |
311 |
@patch('keystone_utils.log') |
96.1.13
by Edward Hope-Morley
add sync-master stickiness back into the mix |
312 |
@patch('keystone_utils.ensure_ssl_cert_master') |
114.6.5
by Edward Hope-Morley
more |
313 |
@patch.object(hooks, 'ensure_pki_dir_permissions') |
114.6.4
by Edward Hope-Morley
more |
314 |
@patch.object(hooks, 'ensure_ssl_dir') |
114.6.2
by Edward Hope-Morley
[hopem,r=] |
315 |
@patch.object(hooks, 'is_pki_enabled') |
316 |
@patch.object(hooks, 'is_ssl_cert_master') |
|
125.1.1
by Edward Hope-Morley
[hopem,r=] |
317 |
@patch.object(hooks, 'send_ssl_sync_request') |
120.1.3
by Edward Hope-Morley
more |
318 |
@patch.object(hooks, 'is_db_initialised') |
116.1.1
by Edward Hope-Morley
add more is_db_ready() protection |
319 |
@patch.object(hooks, 'is_db_ready') |
96.1.10
by Edward Hope-Morley
tests passing and cleanup |
320 |
@patch.object(hooks, 'peer_units') |
96.1.1
by Edward Hope-Morley
[hopem,r=] |
321 |
@patch.object(hooks, 'ensure_permissions') |
87.5.7
by Liam Young
Fix unit tests |
322 |
@patch.object(hooks, 'admin_relation_changed') |
79.1.15
by james.page at ubuntu
Use internal address for haproxy if set, call cluster_joined on config-change hook |
323 |
@patch.object(hooks, 'cluster_joined') |
52.4.1
by yolanda.robla at canonical
added unit testing |
324 |
@patch.object(unison, 'ensure_user') |
325 |
@patch.object(unison, 'get_homedir') |
|
326 |
@patch.object(hooks, 'CONFIGS') |
|
327 |
@patch.object(hooks, 'identity_changed') |
|
328 |
@patch.object(hooks, 'configure_https') |
|
114.6.2
by Edward Hope-Morley
[hopem,r=] |
329 |
def test_config_changed_no_upgrade_leader(self, configure_https, |
330 |
identity_changed, |
|
331 |
configs, get_homedir, |
|
332 |
ensure_user, |
|
333 |
cluster_joined, |
|
334 |
admin_relation_changed, |
|
335 |
ensure_permissions, |
|
336 |
mock_peer_units, |
|
337 |
mock_is_db_ready, |
|
338 |
mock_is_db_initialised, |
|
114.6.13
by Edward Hope-Morley
synced /next |
339 |
mock_send_ssl_sync_request, |
114.6.2
by Edward Hope-Morley
[hopem,r=] |
340 |
mock_is_ssl_cert_master, |
341 |
mock_is_pki_enabled, |
|
114.6.4
by Edward Hope-Morley
more |
342 |
mock_ensure_ssl_dir, |
114.6.5
by Edward Hope-Morley
more |
343 |
mock_ensure_pki_dir_permissions, |
114.6.2
by Edward Hope-Morley
[hopem,r=] |
344 |
mock_ensure_ssl_cert_master, |
88.4.28
by Corey Bryant
Merge next branch |
345 |
mock_log, git_requested): |
88.4.29
by Corey Bryant
mock updates |
346 |
git_requested.return_value = False |
114.6.2
by Edward Hope-Morley
[hopem,r=] |
347 |
mock_is_pki_enabled.return_value = True |
348 |
mock_is_ssl_cert_master.return_value = True |
|
349 |
mock_is_db_initialised.return_value = True |
|
350 |
mock_is_db_ready.return_value = True |
|
351 |
self.openstack_upgrade_available.return_value = False |
|
352 |
self.is_elected_leader.return_value = True |
|
353 |
# avoid having to mock syncer
|
|
354 |
mock_ensure_ssl_cert_master.return_value = False |
|
355 |
mock_peer_units.return_value = [] |
|
356 |
self.relation_ids.return_value = ['identity-service:0'] |
|
357 |
self.related_units.return_value = ['unit/0'] |
|
358 |
||
359 |
hooks.config_changed() |
|
360 |
ensure_user.assert_called_with(user=self.ssh_user, group='keystone') |
|
361 |
get_homedir.assert_called_with(self.ssh_user) |
|
362 |
||
363 |
self.save_script_rc.assert_called_with() |
|
364 |
configure_https.assert_called_with() |
|
365 |
self.assertTrue(configs.write_all.called) |
|
366 |
||
367 |
self.assertTrue(self.ensure_initial_admin.called) |
|
368 |
self.log.assert_called_with( |
|
369 |
'Firing identity_changed hook for all related services.') |
|
370 |
identity_changed.assert_called_with( |
|
371 |
relation_id='identity-service:0', |
|
372 |
remote_unit='unit/0') |
|
373 |
admin_relation_changed.assert_called_with('identity-service:0') |
|
374 |
||
88.4.11
by Corey Bryant
Unit tests for deploy from git. |
375 |
@patch.object(hooks, 'git_install_requested') |
114.6.2
by Edward Hope-Morley
[hopem,r=] |
376 |
@patch('keystone_utils.log') |
377 |
@patch('keystone_utils.ensure_ssl_cert_master') |
|
114.6.7
by Edward Hope-Morley
fix race |
378 |
@patch.object(hooks, 'update_all_identity_relation_units') |
114.6.5
by Edward Hope-Morley
more |
379 |
@patch.object(hooks, 'ensure_pki_dir_permissions') |
114.6.4
by Edward Hope-Morley
more |
380 |
@patch.object(hooks, 'ensure_ssl_dir') |
114.6.2
by Edward Hope-Morley
[hopem,r=] |
381 |
@patch.object(hooks, 'is_pki_enabled') |
114.6.7
by Edward Hope-Morley
fix race |
382 |
@patch.object(hooks, 'peer_units') |
114.6.2
by Edward Hope-Morley
[hopem,r=] |
383 |
@patch.object(hooks, 'is_ssl_cert_master') |
384 |
@patch.object(hooks, 'ensure_permissions') |
|
385 |
@patch.object(hooks, 'cluster_joined') |
|
386 |
@patch.object(unison, 'ensure_user') |
|
387 |
@patch.object(unison, 'get_homedir') |
|
388 |
@patch.object(hooks, 'CONFIGS') |
|
389 |
@patch.object(hooks, 'identity_changed') |
|
390 |
@patch.object(hooks, 'configure_https') |
|
114.6.5
by Edward Hope-Morley
more |
391 |
def test_config_changed_no_upgrade_not_leader(self, configure_https, |
392 |
identity_changed, |
|
393 |
configs, get_homedir, |
|
394 |
ensure_user, cluster_joined, |
|
395 |
ensure_permissions, |
|
396 |
mock_is_ssl_cert_master, |
|
114.6.7
by Edward Hope-Morley
fix race |
397 |
mock_peer_units, |
114.6.5
by Edward Hope-Morley
more |
398 |
mock_is_pki_enabled, |
399 |
mock_ensure_ssl_dir, |
|
400 |
mock_ensure_pki_permissions, |
|
114.6.7
by Edward Hope-Morley
fix race |
401 |
mock_update_all_id_rel_units, |
114.6.5
by Edward Hope-Morley
more |
402 |
mock_ensure_ssl_cert_master, |
88.4.28
by Corey Bryant
Merge next branch |
403 |
mock_log, git_requested): |
88.4.29
by Corey Bryant
mock updates |
404 |
git_requested.return_value = False |
114.6.2
by Edward Hope-Morley
[hopem,r=] |
405 |
mock_is_pki_enabled.return_value = True |
406 |
mock_is_ssl_cert_master.return_value = True |
|
114.6.7
by Edward Hope-Morley
fix race |
407 |
mock_peer_units.return_value = [] |
52.4.1
by yolanda.robla at canonical
added unit testing |
408 |
self.openstack_upgrade_available.return_value = False |
96.1.1
by Edward Hope-Morley
[hopem,r=] |
409 |
self.is_elected_leader.return_value = False |
96.1.13
by Edward Hope-Morley
add sync-master stickiness back into the mix |
410 |
mock_ensure_ssl_cert_master.return_value = False |
52.4.1
by yolanda.robla at canonical
added unit testing |
411 |
|
412 |
hooks.config_changed() |
|
413 |
ensure_user.assert_called_with(user=self.ssh_user, group='keystone') |
|
414 |
get_homedir.assert_called_with(self.ssh_user) |
|
415 |
||
416 |
self.save_script_rc.assert_called_with() |
|
417 |
configure_https.assert_called_with() |
|
418 |
self.assertTrue(configs.write_all.called) |
|
419 |
||
420 |
self.assertFalse(self.migrate_database.called) |
|
421 |
self.assertFalse(self.ensure_initial_admin.called) |
|
422 |
self.assertFalse(identity_changed.called) |
|
423 |
||
88.4.11
by Corey Bryant
Unit tests for deploy from git. |
424 |
@patch.object(hooks, 'git_install_requested') |
96.1.10
by Edward Hope-Morley
tests passing and cleanup |
425 |
@patch('keystone_utils.log') |
96.1.13
by Edward Hope-Morley
add sync-master stickiness back into the mix |
426 |
@patch('keystone_utils.ensure_ssl_cert_master') |
114.6.5
by Edward Hope-Morley
more |
427 |
@patch.object(hooks, 'ensure_pki_dir_permissions') |
114.6.4
by Edward Hope-Morley
more |
428 |
@patch.object(hooks, 'ensure_ssl_dir') |
114.6.2
by Edward Hope-Morley
[hopem,r=] |
429 |
@patch.object(hooks, 'is_pki_enabled') |
430 |
@patch.object(hooks, 'is_ssl_cert_master') |
|
125.1.1
by Edward Hope-Morley
[hopem,r=] |
431 |
@patch.object(hooks, 'send_ssl_sync_request') |
120.1.3
by Edward Hope-Morley
more |
432 |
@patch.object(hooks, 'is_db_initialised') |
116.1.1
by Edward Hope-Morley
add more is_db_ready() protection |
433 |
@patch.object(hooks, 'is_db_ready') |
96.1.10
by Edward Hope-Morley
tests passing and cleanup |
434 |
@patch.object(hooks, 'peer_units') |
96.1.1
by Edward Hope-Morley
[hopem,r=] |
435 |
@patch.object(hooks, 'ensure_permissions') |
87.5.7
by Liam Young
Fix unit tests |
436 |
@patch.object(hooks, 'admin_relation_changed') |
79.1.15
by james.page at ubuntu
Use internal address for haproxy if set, call cluster_joined on config-change hook |
437 |
@patch.object(hooks, 'cluster_joined') |
52.4.1
by yolanda.robla at canonical
added unit testing |
438 |
@patch.object(unison, 'ensure_user') |
439 |
@patch.object(unison, 'get_homedir') |
|
440 |
@patch.object(hooks, 'CONFIGS') |
|
441 |
@patch.object(hooks, 'identity_changed') |
|
442 |
@patch.object(hooks, 'configure_https') |
|
116.1.1
by Edward Hope-Morley
add more is_db_ready() protection |
443 |
def test_config_changed_with_openstack_upgrade(self, configure_https, |
444 |
identity_changed, |
|
445 |
configs, get_homedir, |
|
446 |
ensure_user, cluster_joined, |
|
447 |
admin_relation_changed, |
|
448 |
ensure_permissions, |
|
449 |
mock_peer_units, |
|
450 |
mock_is_db_ready, |
|
120.1.3
by Edward Hope-Morley
more |
451 |
mock_is_db_initialised, |
125.1.1
by Edward Hope-Morley
[hopem,r=] |
452 |
mock_send_ssl_sync_request, |
114.6.2
by Edward Hope-Morley
[hopem,r=] |
453 |
mock_is_ssl_cert_master, |
454 |
mock_is_pki_enabled, |
|
114.6.4
by Edward Hope-Morley
more |
455 |
mock_ensure_ssl_dir, |
114.6.5
by Edward Hope-Morley
more |
456 |
mock_ensure_pki_permissions, |
116.1.1
by Edward Hope-Morley
add more is_db_ready() protection |
457 |
mock_ensure_ssl_cert_master, |
88.4.16
by Corey Bryant
Merge next branch |
458 |
mock_log, git_requested): |
88.4.18
by Corey Bryant
Add deploy from source action support and various fixups after rebase |
459 |
git_requested.return_value = False |
114.6.2
by Edward Hope-Morley
[hopem,r=] |
460 |
mock_is_pki_enabled.return_value = True |
461 |
mock_is_ssl_cert_master.return_value = True |
|
116.1.1
by Edward Hope-Morley
add more is_db_ready() protection |
462 |
mock_is_db_ready.return_value = True |
120.1.3
by Edward Hope-Morley
more |
463 |
mock_is_db_initialised.return_value = True |
52.4.1
by yolanda.robla at canonical
added unit testing |
464 |
self.openstack_upgrade_available.return_value = True |
96.1.1
by Edward Hope-Morley
[hopem,r=] |
465 |
self.is_elected_leader.return_value = True |
96.1.10
by Edward Hope-Morley
tests passing and cleanup |
466 |
# avoid having to mock syncer
|
96.1.13
by Edward Hope-Morley
add sync-master stickiness back into the mix |
467 |
mock_ensure_ssl_cert_master.return_value = False |
96.1.10
by Edward Hope-Morley
tests passing and cleanup |
468 |
mock_peer_units.return_value = [] |
52.4.1
by yolanda.robla at canonical
added unit testing |
469 |
self.relation_ids.return_value = ['identity-service:0'] |
96.1.10
by Edward Hope-Morley
tests passing and cleanup |
470 |
self.related_units.return_value = ['unit/0'] |
52.4.1
by yolanda.robla at canonical
added unit testing |
471 |
|
472 |
hooks.config_changed() |
|
473 |
ensure_user.assert_called_with(user=self.ssh_user, group='keystone') |
|
474 |
get_homedir.assert_called_with(self.ssh_user) |
|
475 |
||
52.4.8
by yolanda.robla at canonical
changing assert_called |
476 |
self.assertTrue(self.do_openstack_upgrade.called) |
52.4.1
by yolanda.robla at canonical
added unit testing |
477 |
|
478 |
self.save_script_rc.assert_called_with() |
|
479 |
configure_https.assert_called_with() |
|
480 |
self.assertTrue(configs.write_all.called) |
|
481 |
||
52.4.8
by yolanda.robla at canonical
changing assert_called |
482 |
self.assertTrue(self.ensure_initial_admin.called) |
52.2.29
by James Page
Final tidy |
483 |
self.log.assert_called_with( |
484 |
'Firing identity_changed hook for all related services.') |
|
485 |
identity_changed.assert_called_with( |
|
486 |
relation_id='identity-service:0', |
|
96.1.4
by Edward Hope-Morley
Fixed a few race issues and switched to using decorators |
487 |
remote_unit='unit/0') |
96.1.14
by Edward Hope-Morley
synced /next |
488 |
admin_relation_changed.assert_called_with('identity-service:0') |
52.4.1
by yolanda.robla at canonical
added unit testing |
489 |
|
88.4.11
by Corey Bryant
Unit tests for deploy from git. |
490 |
@patch.object(hooks, 'git_install_requested') |
88.4.29
by Corey Bryant
mock updates |
491 |
@patch.object(hooks, 'config_value_changed') |
88.4.18
by Corey Bryant
Add deploy from source action support and various fixups after rebase |
492 |
@patch('keystone_utils.log') |
493 |
@patch('keystone_utils.ensure_ssl_cert_master') |
|
88.4.29
by Corey Bryant
mock updates |
494 |
@patch.object(hooks, 'ensure_ssl_dir') |
495 |
@patch.object(hooks, 'is_pki_enabled') |
|
88.4.18
by Corey Bryant
Add deploy from source action support and various fixups after rebase |
496 |
@patch.object(hooks, 'send_ssl_sync_request') |
497 |
@patch.object(hooks, 'is_db_initialised') |
|
498 |
@patch.object(hooks, 'is_db_ready') |
|
499 |
@patch.object(hooks, 'peer_units') |
|
500 |
@patch.object(hooks, 'ensure_permissions') |
|
501 |
@patch.object(hooks, 'admin_relation_changed') |
|
88.4.11
by Corey Bryant
Unit tests for deploy from git. |
502 |
@patch.object(hooks, 'cluster_joined') |
503 |
@patch.object(unison, 'ensure_user') |
|
504 |
@patch.object(unison, 'get_homedir') |
|
505 |
@patch.object(hooks, 'CONFIGS') |
|
506 |
@patch.object(hooks, 'identity_changed') |
|
507 |
@patch.object(hooks, 'configure_https') |
|
88.4.34
by Corey Bryant
Fix lint errors |
508 |
def test_config_changed_git_updated(self, configure_https, |
509 |
identity_changed, |
|
88.4.29
by Corey Bryant
mock updates |
510 |
configs, get_homedir, ensure_user, |
511 |
cluster_joined, admin_relation_changed, |
|
512 |
ensure_permissions, mock_peer_units, |
|
88.4.34
by Corey Bryant
Fix lint errors |
513 |
mock_is_db_ready, |
514 |
mock_is_db_initialised, |
|
88.4.29
by Corey Bryant
mock updates |
515 |
mock_send_ssl_sync_request, |
88.4.34
by Corey Bryant
Fix lint errors |
516 |
mock_is_pki_enabled, |
517 |
mock_ensure_ssl_dir, |
|
88.4.29
by Corey Bryant
mock updates |
518 |
mock_ensure_ssl_cert_master, |
519 |
mock_log, config_val_changed, |
|
520 |
git_requested): |
|
521 |
git_requested.return_value = True |
|
522 |
mock_ensure_ssl_cert_master.return_value = False |
|
523 |
mock_is_pki_enabled.return_value = False |
|
88.4.18
by Corey Bryant
Add deploy from source action support and various fixups after rebase |
524 |
self.openstack_upgrade_available.return_value = False |
525 |
self.is_elected_leader.return_value = True |
|
526 |
mock_peer_units.return_value = [] |
|
88.4.11
by Corey Bryant
Unit tests for deploy from git. |
527 |
self.relation_ids.return_value = ['identity-service:0'] |
88.4.18
by Corey Bryant
Add deploy from source action support and various fixups after rebase |
528 |
self.related_units.return_value = ['unit/0'] |
88.4.11
by Corey Bryant
Unit tests for deploy from git. |
529 |
|
88.4.29
by Corey Bryant
mock updates |
530 |
repo = 'cloud:trusty-juno' |
531 |
openstack_origin_git = { |
|
532 |
'repositories': [ |
|
88.4.34
by Corey Bryant
Fix lint errors |
533 |
{'name': 'requirements', |
534 |
'repository': 'git://git.openstack.org/openstack/requirements', # noqa |
|
535 |
'branch': 'stable/juno'}, |
|
536 |
{'name': 'keystone', |
|
537 |
'repository': 'git://git.openstack.org/openstack/keystone', |
|
538 |
'branch': 'stable/juno'} |
|
88.4.29
by Corey Bryant
mock updates |
539 |
],
|
540 |
'directory': '/mnt/openstack-git', |
|
541 |
}
|
|
542 |
projects_yaml = yaml.dump(openstack_origin_git) |
|
543 |
self.test_config.set('openstack-origin', repo) |
|
544 |
self.test_config.set('openstack-origin-git', projects_yaml) |
|
88.4.11
by Corey Bryant
Unit tests for deploy from git. |
545 |
hooks.config_changed() |
88.4.29
by Corey Bryant
mock updates |
546 |
self.git_install.assert_called_with(projects_yaml) |
88.4.11
by Corey Bryant
Unit tests for deploy from git. |
547 |
self.assertFalse(self.openstack_upgrade_available.called) |
548 |
self.assertFalse(self.do_openstack_upgrade.called) |
|
549 |
||
120.1.3
by Edward Hope-Morley
more |
550 |
@patch.object(hooks, 'is_db_initialised') |
109.1.1
by Edward Hope-Morley
[hopem, r=] |
551 |
@patch.object(hooks, 'is_db_ready') |
96.1.4
by Edward Hope-Morley
Fixed a few race issues and switched to using decorators |
552 |
@patch('keystone_utils.log') |
96.1.13
by Edward Hope-Morley
add sync-master stickiness back into the mix |
553 |
@patch('keystone_utils.ensure_ssl_cert_master') |
89.1.5
by Edward Hope-Morley
notification contains checksum of data we want to use as trigger |
554 |
@patch.object(hooks, 'hashlib') |
89.1.17
by Edward Hope-Morley
final cleanup |
555 |
@patch.object(hooks, 'send_notifications') |
556 |
def test_identity_changed_leader(self, mock_send_notifications, |
|
96.1.13
by Edward Hope-Morley
add sync-master stickiness back into the mix |
557 |
mock_hashlib, mock_ensure_ssl_cert_master, |
120.1.3
by Edward Hope-Morley
more |
558 |
mock_log, mock_is_db_ready, |
559 |
mock_is_db_initialised): |
|
560 |
mock_is_db_initialised.return_value = True |
|
109.1.1
by Edward Hope-Morley
[hopem, r=] |
561 |
mock_is_db_ready.return_value = True |
96.1.13
by Edward Hope-Morley
add sync-master stickiness back into the mix |
562 |
mock_ensure_ssl_cert_master.return_value = False |
52.2.29
by James Page
Final tidy |
563 |
hooks.identity_changed( |
564 |
relation_id='identity-service:0', |
|
565 |
remote_unit='unit/0') |
|
566 |
self.add_service_to_keystone.assert_called_with( |
|
567 |
'identity-service:0', |
|
568 |
'unit/0') |
|
52.4.1
by yolanda.robla at canonical
added unit testing |
569 |
|
96.1.13
by Edward Hope-Morley
add sync-master stickiness back into the mix |
570 |
@patch.object(hooks, 'local_unit') |
96.1.4
by Edward Hope-Morley
Fixed a few race issues and switched to using decorators |
571 |
@patch('keystone_utils.log') |
96.1.13
by Edward Hope-Morley
add sync-master stickiness back into the mix |
572 |
@patch('keystone_utils.ensure_ssl_cert_master') |
573 |
def test_identity_changed_no_leader(self, mock_ensure_ssl_cert_master, |
|
574 |
mock_log, mock_local_unit): |
|
575 |
mock_ensure_ssl_cert_master.return_value = False |
|
576 |
mock_local_unit.return_value = 'unit/0' |
|
96.1.1
by Edward Hope-Morley
[hopem,r=] |
577 |
self.is_elected_leader.return_value = False |
52.2.29
by James Page
Final tidy |
578 |
hooks.identity_changed( |
579 |
relation_id='identity-service:0', |
|
580 |
remote_unit='unit/0') |
|
52.4.1
by yolanda.robla at canonical
added unit testing |
581 |
self.assertFalse(self.add_service_to_keystone.called) |
52.2.29
by James Page
Final tidy |
582 |
self.log.assert_called_with( |
583 |
'Deferring identity_changed() to service leader.') |
|
52.4.1
by yolanda.robla at canonical
added unit testing |
584 |
|
96.1.13
by Edward Hope-Morley
add sync-master stickiness back into the mix |
585 |
@patch.object(hooks, 'local_unit') |
96.1.11
by Edward Hope-Morley
add leader protection to cluster-changed hook |
586 |
@patch.object(hooks, 'peer_units') |
52.4.1
by yolanda.robla at canonical
added unit testing |
587 |
@patch.object(unison, 'ssh_authorized_peers') |
96.1.11
by Edward Hope-Morley
add leader protection to cluster-changed hook |
588 |
def test_cluster_joined(self, ssh_authorized_peers, mock_peer_units, |
96.1.13
by Edward Hope-Morley
add sync-master stickiness back into the mix |
589 |
mock_local_unit): |
590 |
mock_local_unit.return_value = 'unit/0' |
|
96.1.11
by Edward Hope-Morley
add leader protection to cluster-changed hook |
591 |
mock_peer_units.return_value = ['unit/0'] |
52.4.1
by yolanda.robla at canonical
added unit testing |
592 |
hooks.cluster_joined() |
52.2.29
by James Page
Final tidy |
593 |
ssh_authorized_peers.assert_called_with( |
594 |
user=self.ssh_user, group='juju_keystone', |
|
595 |
peer_interface='cluster', ensure_local_user=True) |
|
52.4.1
by yolanda.robla at canonical
added unit testing |
596 |
|
114.6.7
by Edward Hope-Morley
fix race |
597 |
@patch.object(hooks, 'update_all_identity_relation_units') |
598 |
@patch.object(hooks, 'get_ssl_sync_request_units') |
|
96.1.17
by Edward Hope-Morley
ignore ssl actions if not enabled and improve support for non-ssl -> ssl |
599 |
@patch.object(hooks, 'is_ssl_cert_master') |
96.1.11
by Edward Hope-Morley
add leader protection to cluster-changed hook |
600 |
@patch.object(hooks, 'peer_units') |
114.6.7
by Edward Hope-Morley
fix race |
601 |
@patch('keystone_utils.config') |
96.1.4
by Edward Hope-Morley
Fixed a few race issues and switched to using decorators |
602 |
@patch('keystone_utils.log') |
96.1.13
by Edward Hope-Morley
add sync-master stickiness back into the mix |
603 |
@patch('keystone_utils.ensure_ssl_cert_master') |
96.1.4
by Edward Hope-Morley
Fixed a few race issues and switched to using decorators |
604 |
@patch('keystone_utils.synchronize_ca') |
96.1.1
by Edward Hope-Morley
[hopem,r=] |
605 |
@patch.object(hooks, 'check_peer_actions') |
52.4.1
by yolanda.robla at canonical
added unit testing |
606 |
@patch.object(unison, 'ssh_authorized_peers') |
607 |
@patch.object(hooks, 'CONFIGS') |
|
96.1.1
by Edward Hope-Morley
[hopem,r=] |
608 |
def test_cluster_changed(self, configs, ssh_authorized_peers, |
96.1.10
by Edward Hope-Morley
tests passing and cleanup |
609 |
check_peer_actions, mock_synchronize_ca, |
96.1.13
by Edward Hope-Morley
add sync-master stickiness back into the mix |
610 |
mock_ensure_ssl_cert_master, |
114.6.7
by Edward Hope-Morley
fix race |
611 |
mock_log, mock_config, mock_peer_units, |
612 |
mock_is_ssl_cert_master, |
|
613 |
mock_get_ssl_sync_request_units, |
|
614 |
mock_update_all_identity_relation_units): |
|
615 |
||
616 |
relation_settings = {'foo_passwd': '123', |
|
617 |
'identity-service:16_foo': 'bar'} |
|
114.6.8
by Edward Hope-Morley
fix race |
618 |
|
96.1.17
by Edward Hope-Morley
ignore ssl actions if not enabled and improve support for non-ssl -> ssl |
619 |
mock_is_ssl_cert_master.return_value = False |
96.1.11
by Edward Hope-Morley
add leader protection to cluster-changed hook |
620 |
mock_peer_units.return_value = ['unit/0'] |
96.1.13
by Edward Hope-Morley
add sync-master stickiness back into the mix |
621 |
mock_ensure_ssl_cert_master.return_value = False |
96.1.12
by Edward Hope-Morley
validate echoed peer data |
622 |
self.is_elected_leader.return_value = False |
114.6.7
by Edward Hope-Morley
fix race |
623 |
|
624 |
def fake_rel_get(attribute=None, *args, **kwargs): |
|
625 |
if not attribute: |
|
626 |
return relation_settings |
|
627 |
||
628 |
return relation_settings.get(attribute) |
|
629 |
||
630 |
self.relation_get.side_effect = fake_rel_get |
|
631 |
||
632 |
mock_config.return_value = None |
|
633 |
||
52.4.1
by yolanda.robla at canonical
added unit testing |
634 |
hooks.cluster_changed() |
114.6.8
by Edward Hope-Morley
fix race |
635 |
whitelist = ['_passwd', 'identity-service:', 'ssl-cert-master', |
636 |
'db-initialised'] |
|
637 |
self.peer_echo.assert_called_with(includes=whitelist) |
|
52.2.29
by James Page
Final tidy |
638 |
ssh_authorized_peers.assert_called_with( |
112.1.1
by Edward Hope-Morley
[hopem,r=] |
639 |
user=self.ssh_user, group='juju_keystone', |
52.2.29
by James Page
Final tidy |
640 |
peer_interface='cluster', ensure_local_user=True) |
96.1.10
by Edward Hope-Morley
tests passing and cleanup |
641 |
self.assertFalse(mock_synchronize_ca.called) |
52.4.1
by yolanda.robla at canonical
added unit testing |
642 |
self.assertTrue(configs.write_all.called) |
643 |
||
644 |
def test_ha_joined(self): |
|
68.2.18
by james.page at ubuntu
Align ha-joined hook with other charms |
645 |
self.get_hacluster_config.return_value = { |
646 |
'vip': '10.10.10.10', |
|
647 |
'ha-bindiface': 'em0', |
|
648 |
'ha-mcastport': '8080' |
|
649 |
}
|
|
68.2.15
by james.page at ubuntu
Add support for multi-vip clustering, update unit tests |
650 |
self.get_iface_for_address.return_value = 'em1' |
651 |
self.get_netmask_for_address.return_value = '255.255.255.0' |
|
52.4.1
by yolanda.robla at canonical
added unit testing |
652 |
hooks.ha_joined() |
653 |
args = { |
|
106.1.4
by Liam Young
Merged next in and fix unit tests |
654 |
'relation_id': None, |
52.4.1
by yolanda.robla at canonical
added unit testing |
655 |
'corosync_bindiface': 'em0', |
656 |
'corosync_mcastport': '8080', |
|
657 |
'init_services': {'res_ks_haproxy': 'haproxy'}, |
|
68.2.15
by james.page at ubuntu
Add support for multi-vip clustering, update unit tests |
658 |
'resources': {'res_ks_em1_vip': 'ocf:heartbeat:IPaddr2', |
52.4.1
by yolanda.robla at canonical
added unit testing |
659 |
'res_ks_haproxy': 'lsb:haproxy'}, |
660 |
'resource_params': { |
|
68.2.15
by james.page at ubuntu
Add support for multi-vip clustering, update unit tests |
661 |
'res_ks_em1_vip': 'params ip="10.10.10.10"' |
662 |
' cidr_netmask="255.255.255.0" nic="em1"', |
|
52.4.1
by yolanda.robla at canonical
added unit testing |
663 |
'res_ks_haproxy': 'op monitor interval="5s"'}, |
664 |
'clones': {'cl_ks_haproxy': 'res_ks_haproxy'} |
|
665 |
}
|
|
666 |
self.relation_set.assert_called_with(**args) |
|
667 |
||
87.4.1
by james.page at ubuntu
Provide fallback config options for HA VIP iface and cidr when it cannot be automatically determined |
668 |
def test_ha_joined_no_bound_ip(self): |
669 |
self.get_hacluster_config.return_value = { |
|
670 |
'vip': '10.10.10.10', |
|
671 |
'ha-bindiface': 'em0', |
|
672 |
'ha-mcastport': '8080' |
|
673 |
}
|
|
674 |
self.test_config.set('vip_iface', 'eth120') |
|
675 |
self.test_config.set('vip_cidr', '21') |
|
676 |
self.get_iface_for_address.return_value = None |
|
677 |
self.get_netmask_for_address.return_value = None |
|
678 |
hooks.ha_joined() |
|
679 |
args = { |
|
106.1.4
by Liam Young
Merged next in and fix unit tests |
680 |
'relation_id': None, |
87.4.1
by james.page at ubuntu
Provide fallback config options for HA VIP iface and cidr when it cannot be automatically determined |
681 |
'corosync_bindiface': 'em0', |
682 |
'corosync_mcastport': '8080', |
|
683 |
'init_services': {'res_ks_haproxy': 'haproxy'}, |
|
684 |
'resources': {'res_ks_eth120_vip': 'ocf:heartbeat:IPaddr2', |
|
685 |
'res_ks_haproxy': 'lsb:haproxy'}, |
|
686 |
'resource_params': { |
|
687 |
'res_ks_eth120_vip': 'params ip="10.10.10.10"' |
|
688 |
' cidr_netmask="21" nic="eth120"', |
|
689 |
'res_ks_haproxy': 'op monitor interval="5s"'}, |
|
690 |
'clones': {'cl_ks_haproxy': 'res_ks_haproxy'} |
|
691 |
}
|
|
692 |
self.relation_set.assert_called_with(**args) |
|
693 |
||
73.2.2
by Hui Xiang
Sync charm-helpers, Add unit tests, Fix trivial issues. |
694 |
def test_ha_joined_with_ipv6(self): |
695 |
self.test_config.set('prefer-ipv6', True) |
|
696 |
self.get_hacluster_config.return_value = { |
|
697 |
'vip': '2001:db8:1::1', |
|
698 |
'ha-bindiface': 'em0', |
|
699 |
'ha-mcastport': '8080' |
|
700 |
}
|
|
701 |
self.get_iface_for_address.return_value = 'em1' |
|
702 |
self.get_netmask_for_address.return_value = '64' |
|
703 |
hooks.ha_joined() |
|
704 |
args = { |
|
106.1.4
by Liam Young
Merged next in and fix unit tests |
705 |
'relation_id': None, |
73.2.2
by Hui Xiang
Sync charm-helpers, Add unit tests, Fix trivial issues. |
706 |
'corosync_bindiface': 'em0', |
707 |
'corosync_mcastport': '8080', |
|
708 |
'init_services': {'res_ks_haproxy': 'haproxy'}, |
|
709 |
'resources': {'res_ks_em1_vip': 'ocf:heartbeat:IPv6addr', |
|
710 |
'res_ks_haproxy': 'lsb:haproxy'}, |
|
711 |
'resource_params': { |
|
712 |
'res_ks_em1_vip': 'params ipv6addr="2001:db8:1::1"' |
|
713 |
' cidr_netmask="64" nic="em1"', |
|
714 |
'res_ks_haproxy': 'op monitor interval="5s"'}, |
|
715 |
'clones': {'cl_ks_haproxy': 'res_ks_haproxy'} |
|
716 |
}
|
|
717 |
self.relation_set.assert_called_with(**args) |
|
718 |
||
96.1.4
by Edward Hope-Morley
Fixed a few race issues and switched to using decorators |
719 |
@patch('keystone_utils.log') |
96.1.13
by Edward Hope-Morley
add sync-master stickiness back into the mix |
720 |
@patch('keystone_utils.ensure_ssl_cert_master') |
96.1.4
by Edward Hope-Morley
Fixed a few race issues and switched to using decorators |
721 |
@patch('keystone_utils.synchronize_ca') |
52.4.1
by yolanda.robla at canonical
added unit testing |
722 |
@patch.object(hooks, 'CONFIGS') |
96.1.4
by Edward Hope-Morley
Fixed a few race issues and switched to using decorators |
723 |
def test_ha_relation_changed_not_clustered_not_leader(self, configs, |
724 |
mock_synchronize_ca, |
|
96.1.13
by Edward Hope-Morley
add sync-master stickiness back into the mix |
725 |
mock_is_master, |
96.1.4
by Edward Hope-Morley
Fixed a few race issues and switched to using decorators |
726 |
mock_log): |
96.1.13
by Edward Hope-Morley
add sync-master stickiness back into the mix |
727 |
mock_is_master.return_value = False |
52.4.1
by yolanda.robla at canonical
added unit testing |
728 |
self.relation_get.return_value = False |
96.1.1
by Edward Hope-Morley
[hopem,r=] |
729 |
self.is_elected_leader.return_value = False |
52.4.1
by yolanda.robla at canonical
added unit testing |
730 |
|
731 |
hooks.ha_changed() |
|
732 |
self.assertTrue(configs.write_all.called) |
|
96.1.10
by Edward Hope-Morley
tests passing and cleanup |
733 |
self.assertFalse(mock_synchronize_ca.called) |
52.4.1
by yolanda.robla at canonical
added unit testing |
734 |
|
96.1.4
by Edward Hope-Morley
Fixed a few race issues and switched to using decorators |
735 |
@patch('keystone_utils.log') |
96.1.13
by Edward Hope-Morley
add sync-master stickiness back into the mix |
736 |
@patch('keystone_utils.ensure_ssl_cert_master') |
116.1.1
by Edward Hope-Morley
add more is_db_ready() protection |
737 |
@patch.object(hooks, 'is_db_ready') |
120.1.3
by Edward Hope-Morley
more |
738 |
@patch.object(hooks, 'is_db_initialised') |
73.2.7
by Hui Xiang
Resolve conflicts. |
739 |
@patch.object(hooks, 'identity_changed') |
52.4.1
by yolanda.robla at canonical
added unit testing |
740 |
@patch.object(hooks, 'CONFIGS') |
96.1.4
by Edward Hope-Morley
Fixed a few race issues and switched to using decorators |
741 |
def test_ha_relation_changed_clustered_leader(self, configs, |
742 |
identity_changed, |
|
120.1.3
by Edward Hope-Morley
more |
743 |
mock_is_db_initialised, |
116.1.1
by Edward Hope-Morley
add more is_db_ready() protection |
744 |
mock_is_db_ready, |
96.1.13
by Edward Hope-Morley
add sync-master stickiness back into the mix |
745 |
mock_ensure_ssl_cert_master, |
96.1.10
by Edward Hope-Morley
tests passing and cleanup |
746 |
mock_log): |
120.1.3
by Edward Hope-Morley
more |
747 |
mock_is_db_initialised.return_value = True |
116.1.1
by Edward Hope-Morley
add more is_db_ready() protection |
748 |
mock_is_db_ready.return_value = True |
96.1.13
by Edward Hope-Morley
add sync-master stickiness back into the mix |
749 |
mock_ensure_ssl_cert_master.return_value = False |
52.4.1
by yolanda.robla at canonical
added unit testing |
750 |
self.relation_get.return_value = True |
96.1.1
by Edward Hope-Morley
[hopem,r=] |
751 |
self.is_elected_leader.return_value = True |
52.4.1
by yolanda.robla at canonical
added unit testing |
752 |
self.relation_ids.return_value = ['identity-service:0'] |
73.2.7
by Hui Xiang
Resolve conflicts. |
753 |
self.related_units.return_value = ['unit/0'] |
52.4.1
by yolanda.robla at canonical
added unit testing |
754 |
|
755 |
hooks.ha_changed() |
|
756 |
self.assertTrue(configs.write_all.called) |
|
52.2.29
by James Page
Final tidy |
757 |
self.log.assert_called_with( |
96.1.10
by Edward Hope-Morley
tests passing and cleanup |
758 |
'Firing identity_changed hook for all related services.') |
73.2.7
by Hui Xiang
Resolve conflicts. |
759 |
identity_changed.assert_called_with( |
760 |
relation_id='identity-service:0', |
|
96.1.4
by Edward Hope-Morley
Fixed a few race issues and switched to using decorators |
761 |
remote_unit='unit/0') |
73.2.2
by Hui Xiang
Sync charm-helpers, Add unit tests, Fix trivial issues. |
762 |
|
96.1.4
by Edward Hope-Morley
Fixed a few race issues and switched to using decorators |
763 |
@patch('keystone_utils.log') |
96.1.13
by Edward Hope-Morley
add sync-master stickiness back into the mix |
764 |
@patch('keystone_utils.ensure_ssl_cert_master') |
73.2.2
by Hui Xiang
Sync charm-helpers, Add unit tests, Fix trivial issues. |
765 |
@patch.object(hooks, 'CONFIGS') |
96.1.13
by Edward Hope-Morley
add sync-master stickiness back into the mix |
766 |
def test_configure_https_enable(self, configs, mock_ensure_ssl_cert_master, |
96.1.10
by Edward Hope-Morley
tests passing and cleanup |
767 |
mock_log): |
96.1.13
by Edward Hope-Morley
add sync-master stickiness back into the mix |
768 |
mock_ensure_ssl_cert_master.return_value = False |
52.4.1
by yolanda.robla at canonical
added unit testing |
769 |
configs.complete_contexts = MagicMock() |
770 |
configs.complete_contexts.return_value = ['https'] |
|
771 |
configs.write = MagicMock() |
|
772 |
||
773 |
hooks.configure_https() |
|
774 |
self.assertTrue(configs.write_all.called) |
|
775 |
cmd = ['a2ensite', 'openstack_https_frontend'] |
|
776 |
self.check_call.assert_called_with(cmd) |
|
777 |
||
96.1.4
by Edward Hope-Morley
Fixed a few race issues and switched to using decorators |
778 |
@patch('keystone_utils.log') |
96.1.13
by Edward Hope-Morley
add sync-master stickiness back into the mix |
779 |
@patch('keystone_utils.ensure_ssl_cert_master') |
52.4.1
by yolanda.robla at canonical
added unit testing |
780 |
@patch.object(hooks, 'CONFIGS') |
96.1.13
by Edward Hope-Morley
add sync-master stickiness back into the mix |
781 |
def test_configure_https_disable(self, configs, |
782 |
mock_ensure_ssl_cert_master, |
|
96.1.10
by Edward Hope-Morley
tests passing and cleanup |
783 |
mock_log): |
96.1.13
by Edward Hope-Morley
add sync-master stickiness back into the mix |
784 |
mock_ensure_ssl_cert_master.return_value = False |
52.4.1
by yolanda.robla at canonical
added unit testing |
785 |
configs.complete_contexts = MagicMock() |
786 |
configs.complete_contexts.return_value = [''] |
|
787 |
configs.write = MagicMock() |
|
788 |
||
789 |
hooks.configure_https() |
|
790 |
self.assertTrue(configs.write_all.called) |
|
791 |
cmd = ['a2dissite', 'openstack_https_frontend'] |
|
792 |
self.check_call.assert_called_with(cmd) |
|
793 |
||
88.4.11
by Corey Bryant
Unit tests for deploy from git. |
794 |
@patch.object(utils, 'git_install_requested') |
120.1.3
by Edward Hope-Morley
more |
795 |
@patch.object(hooks, 'is_db_ready') |
796 |
@patch.object(hooks, 'is_db_initialised') |
|
96.1.10
by Edward Hope-Morley
tests passing and cleanup |
797 |
@patch('keystone_utils.log') |
96.1.4
by Edward Hope-Morley
Fixed a few race issues and switched to using decorators |
798 |
@patch('keystone_utils.relation_ids') |
799 |
@patch('keystone_utils.is_elected_leader') |
|
96.1.13
by Edward Hope-Morley
add sync-master stickiness back into the mix |
800 |
@patch('keystone_utils.ensure_ssl_cert_master') |
96.1.4
by Edward Hope-Morley
Fixed a few race issues and switched to using decorators |
801 |
@patch('keystone_utils.update_hash_from_path') |
802 |
@patch('keystone_utils.synchronize_ca') |
|
52.4.1
by yolanda.robla at canonical
added unit testing |
803 |
@patch.object(unison, 'ssh_authorized_peers') |
96.1.4
by Edward Hope-Morley
Fixed a few race issues and switched to using decorators |
804 |
def test_upgrade_charm_leader(self, ssh_authorized_peers, |
805 |
mock_synchronize_ca, |
|
806 |
mock_update_hash_from_path, |
|
96.1.13
by Edward Hope-Morley
add sync-master stickiness back into the mix |
807 |
mock_ensure_ssl_cert_master, |
96.1.10
by Edward Hope-Morley
tests passing and cleanup |
808 |
mock_is_elected_leader, |
809 |
mock_relation_ids, |
|
120.1.3
by Edward Hope-Morley
more |
810 |
mock_log, |
811 |
mock_is_db_ready, |
|
88.4.16
by Corey Bryant
Merge next branch |
812 |
mock_is_db_initialised, |
813 |
git_requested): |
|
120.1.3
by Edward Hope-Morley
more |
814 |
mock_is_db_initialised.return_value = True |
815 |
mock_is_db_ready.return_value = True |
|
96.1.13
by Edward Hope-Morley
add sync-master stickiness back into the mix |
816 |
mock_is_elected_leader.return_value = False |
96.1.4
by Edward Hope-Morley
Fixed a few race issues and switched to using decorators |
817 |
mock_relation_ids.return_value = [] |
96.1.13
by Edward Hope-Morley
add sync-master stickiness back into the mix |
818 |
mock_ensure_ssl_cert_master.return_value = True |
96.1.4
by Edward Hope-Morley
Fixed a few race issues and switched to using decorators |
819 |
# Ensure always returns diff
|
820 |
mock_update_hash_from_path.side_effect = \ |
|
821 |
lambda hash, *args, **kwargs: hash.update(str(uuid.uuid4())) |
|
822 |
||
96.1.1
by Edward Hope-Morley
[hopem,r=] |
823 |
self.is_elected_leader.return_value = True |
52.4.5
by yolanda.robla at canonical
mocking extra calls |
824 |
self.filter_installed_packages.return_value = [] |
88.4.11
by Corey Bryant
Unit tests for deploy from git. |
825 |
git_requested.return_value = False |
52.4.1
by yolanda.robla at canonical
added unit testing |
826 |
hooks.upgrade_charm() |
52.4.8
by yolanda.robla at canonical
changing assert_called |
827 |
self.assertTrue(self.apt_install.called) |
52.2.29
by James Page
Final tidy |
828 |
ssh_authorized_peers.assert_called_with( |
112.1.1
by Edward Hope-Morley
[hopem,r=] |
829 |
user=self.ssh_user, group='juju_keystone', |
52.2.29
by James Page
Final tidy |
830 |
peer_interface='cluster', ensure_local_user=True) |
96.1.4
by Edward Hope-Morley
Fixed a few race issues and switched to using decorators |
831 |
self.assertTrue(mock_synchronize_ca.called) |
52.2.29
by James Page
Final tidy |
832 |
self.log.assert_called_with( |
96.1.10
by Edward Hope-Morley
tests passing and cleanup |
833 |
'Firing identity_changed hook for all related services.') |
52.4.8
by yolanda.robla at canonical
changing assert_called |
834 |
self.assertTrue(self.ensure_initial_admin.called) |
52.4.1
by yolanda.robla at canonical
added unit testing |
835 |
|
88.4.11
by Corey Bryant
Unit tests for deploy from git. |
836 |
@patch.object(utils, 'git_install_requested') |
96.1.10
by Edward Hope-Morley
tests passing and cleanup |
837 |
@patch('keystone_utils.log') |
96.1.4
by Edward Hope-Morley
Fixed a few race issues and switched to using decorators |
838 |
@patch('keystone_utils.relation_ids') |
96.1.13
by Edward Hope-Morley
add sync-master stickiness back into the mix |
839 |
@patch('keystone_utils.ensure_ssl_cert_master') |
96.1.4
by Edward Hope-Morley
Fixed a few race issues and switched to using decorators |
840 |
@patch('keystone_utils.update_hash_from_path') |
52.4.1
by yolanda.robla at canonical
added unit testing |
841 |
@patch.object(unison, 'ssh_authorized_peers') |
88.4.11
by Corey Bryant
Unit tests for deploy from git. |
842 |
def test_upgrade_charm_not_leader(self, ssh_authorized_peers, |
96.1.4
by Edward Hope-Morley
Fixed a few race issues and switched to using decorators |
843 |
mock_update_hash_from_path, |
96.1.13
by Edward Hope-Morley
add sync-master stickiness back into the mix |
844 |
mock_ensure_ssl_cert_master, |
96.1.10
by Edward Hope-Morley
tests passing and cleanup |
845 |
mock_relation_ids, |
88.4.16
by Corey Bryant
Merge next branch |
846 |
mock_log, git_requested): |
96.1.4
by Edward Hope-Morley
Fixed a few race issues and switched to using decorators |
847 |
mock_relation_ids.return_value = [] |
96.1.13
by Edward Hope-Morley
add sync-master stickiness back into the mix |
848 |
mock_ensure_ssl_cert_master.return_value = False |
96.1.4
by Edward Hope-Morley
Fixed a few race issues and switched to using decorators |
849 |
# Ensure always returns diff
|
850 |
mock_update_hash_from_path.side_effect = \ |
|
851 |
lambda hash, *args, **kwargs: hash.update(str(uuid.uuid4())) |
|
852 |
||
96.1.1
by Edward Hope-Morley
[hopem,r=] |
853 |
self.is_elected_leader.return_value = False |
52.4.5
by yolanda.robla at canonical
mocking extra calls |
854 |
self.filter_installed_packages.return_value = [] |
88.4.11
by Corey Bryant
Unit tests for deploy from git. |
855 |
git_requested.return_value = False |
52.4.1
by yolanda.robla at canonical
added unit testing |
856 |
hooks.upgrade_charm() |
52.4.8
by yolanda.robla at canonical
changing assert_called |
857 |
self.assertTrue(self.apt_install.called) |
52.2.29
by James Page
Final tidy |
858 |
ssh_authorized_peers.assert_called_with( |
112.1.1
by Edward Hope-Morley
[hopem,r=] |
859 |
user=self.ssh_user, group='juju_keystone', |
52.2.29
by James Page
Final tidy |
860 |
peer_interface='cluster', ensure_local_user=True) |
52.4.1
by yolanda.robla at canonical
added unit testing |
861 |
self.assertFalse(self.log.called) |
862 |
self.assertFalse(self.ensure_initial_admin.called) |