Merge "Fix incorrectly applied cluster relation settings"

This commit is contained in:
Jenkins 2017-04-06 16:06:30 +00:00 committed by Gerrit Code Review
commit 2029cdf6d0
2 changed files with 24 additions and 5 deletions

View File

@ -239,10 +239,7 @@ def cluster_joined(rid=None):
config('os-{}-network'.format(addr_type))
)
if address:
relation_set(
relation_id=rid,
settings={'{}-address'.format(addr_type): address}
)
settings['{}-address'.format(addr_type)] = address
if config('prefer-ipv6'):
private_addr = get_ipv6_addr(exc_list=[config('vip')])[0]

View File

@ -13,7 +13,7 @@
# limitations under the License.
from mock import (
patch,
patch, call
)
from test_utils import (
@ -218,6 +218,28 @@ class CephRadosGWTests(CharmTestCase):
self.assertEquals(ceph_hooks.canonical_url({}, PUBLIC),
'http://[%s]' % ipv6_addr)
@patch.object(ceph_hooks, 'get_address_in_network')
def test_cluster_joined(self, mock_get_addr):
addrs = {'10.0.0.0/24': '10.0.0.1',
'10.0.1.0/24': '10.0.1.1',
'10.0.2.0/24': '10.0.2.1'}
def fake_get_address_in_network(network):
return addrs.get(network)
mock_get_addr.side_effect = fake_get_address_in_network
self.test_config.set('os-public-network', '10.0.0.0/24')
self.test_config.set('os-admin-network', '10.0.1.0/24')
self.test_config.set('os-internal-network', '10.0.2.0/24')
ceph_hooks.cluster_joined()
self.relation_set.assert_has_calls(
[call(relation_id=None,
**{'admin-address': '10.0.1.1',
'internal-address': '10.0.2.1',
'public-address': '10.0.0.1'})])
def test_cluster_changed(self):
_id_joined = self.patch('identity_joined')
self.relation_ids.return_value = ['rid']