From 53c204a79669be96042a0200858155284c932b69 Mon Sep 17 00:00:00 2001 From: James Page Date: Thu, 22 Nov 2018 15:35:23 +0000 Subject: [PATCH] Drop use of 'amqp.requested-access' flag In an amqp relation is removed and re-added, the charm won't make a new request for access. As the handler simply sets two data items on the relation, avoid the use of the requested-access flag. Change-Id: Ibbffabe277adacf966443bae04a6a64a07964261 Closes-Bug: 1784076 --- src/reactive/designate_handlers.py | 3 --- unit_tests/test_designate_handlers.py | 4 +--- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/reactive/designate_handlers.py b/src/reactive/designate_handlers.py index 26dc0b7..7ca7b57 100644 --- a/src/reactive/designate_handlers.py +++ b/src/reactive/designate_handlers.py @@ -69,7 +69,6 @@ def install_packages(): with provide_charm_instance() as instance: instance.install() reactive.set_state('installed') - reactive.remove_state('amqp.requested-access') reactive.remove_state('shared-db.setup') reactive.remove_state('base-config.rendered') reactive.remove_state('db.synched') @@ -77,12 +76,10 @@ def install_packages(): @reactive.when('amqp.connected') -@reactive.when_not('amqp.requested-access') def setup_amqp_req(amqp): """Send request for rabbit access and vhost""" amqp.request_access(username='designate', vhost='openstack') - reactive.set_state('amqp.requested-access') @reactive.when('shared-db.connected') diff --git a/unit_tests/test_designate_handlers.py b/unit_tests/test_designate_handlers.py index 09eb639..83ce086 100644 --- a/unit_tests/test_designate_handlers.py +++ b/unit_tests/test_designate_handlers.py @@ -84,8 +84,7 @@ class TestHandlers(test_utils.PatchHelper): self.patch_object(handlers.reactive, 'remove_state') handlers.install_packages() the_charm.install.assert_called_once_with() - calls = [mock.call('amqp.requested-access'), - mock.call('shared-db.setup'), + calls = [mock.call('shared-db.setup'), mock.call('base-config.rendered'), mock.call('db.synched')] self.remove_state.assert_has_calls(calls) @@ -96,7 +95,6 @@ class TestHandlers(test_utils.PatchHelper): handlers.setup_amqp_req(amqp) amqp.request_access.assert_called_once_with( username='designate', vhost='openstack') - self.set_state.assert_called_once_with('amqp.requested-access') def test_database(self): database = mock.MagicMock()