Fix lint and add unit test to test inconsistent auths

This commit is contained in:
Liam Young 2015-10-12 10:56:01 +00:00
parent 89fdb4b94f
commit 64aec4a32e
3 changed files with 29 additions and 3 deletions

View File

@ -85,8 +85,8 @@ class MonContext(context.OSContextGenerator):
if _auth:
auths.append(_auth)
if len(set(auths)) != 1:
e=("Inconsistent or absent auth returned by mon units. Setting "
"auth_supported to 'none'")
e = ("Inconsistent or absent auth returned by mon units. Setting "
"auth_supported to 'none'")
log(e, level=WARNING)
auth = 'none'
else:

View File

@ -124,7 +124,8 @@ def check_optional_relations(configs):
return ('blocked',
'hacluster missing configuration: '
'vip, vip_iface, vip_cidr')
if cmp_pkgrevno(pkg, '0.55') >= 0 and relation_ids('identity-service'):
if cmp_pkgrevno('radosgw', '0.55') >= 0 and \
relation_ids('identity-service'):
required_interfaces['identity'] = ['identity-service']
if required_interfaces:
set_os_workload_status(configs, required_interfaces)

View File

@ -7,6 +7,7 @@ import charmhelpers
TO_PATCH = [
'config',
'log',
'relation_get',
'relation_ids',
'related_units',
@ -175,3 +176,27 @@ class MonContextTest(CharmTestCase):
self.relation_ids.return_value = ['mon:6']
self.related_units.return_value = ['ceph/0', 'ceph/1', 'ceph/2']
self.assertEqual({}, mon_ctxt())
def test_ctxt_inconsistent_auths(self):
self.socket.gethostname.return_value = '10.0.0.10'
mon_ctxt = context.MonContext()
addresses = ['10.5.4.1', '10.5.4.2', '10.5.4.3']
auths = ['cephx', 'cephy', 'cephz']
def _relation_get(attr, unit, rid):
if attr == 'ceph-public-address':
return addresses.pop()
elif attr == 'auth':
return auths.pop()
self.relation_get.side_effect = _relation_get
self.relation_ids.return_value = ['mon:6']
self.related_units.return_value = ['ceph/0', 'ceph/1', 'ceph/2']
expect = {
'auth_supported': 'none',
'embedded_webserver': False,
'hostname': '10.0.0.10',
'mon_hosts': '10.5.4.1:6789 10.5.4.2:6789 10.5.4.3:6789',
'old_auth': False,
'use_syslog': 'false'
}
self.assertEqual(expect, mon_ctxt())