Fix lint and add unit test to test inconsistent auths
This commit is contained in:
parent
4932df7119
commit
ae5d356e7a
@ -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:
|
||||
|
@ -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)
|
||||
|
@ -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())
|
||||
|
Loading…
Reference in New Issue
Block a user