Fix response to non action_managed_upgrades

This patch adds a new handler to make charm react to non
action_managed_upgrades.

Change-Id: If8a4e19ca03d4b4570f2e20edee36cf64df70da9
Signed-off-by: Stamatis Katsaounis <skatsaounis@admin.grnet.gr>
This commit is contained in:
Stamatis Katsaounis 2020-11-13 10:18:00 +02:00
parent 343828b309
commit 27f3386fe9
2 changed files with 13 additions and 0 deletions

View File

@ -33,6 +33,12 @@ charms_openstack.charm.use_defaults(
)
@reactive.when_not('is-update-status-hook')
def auto_upgrade(*args):
with charms_openstack.charm.provide_charm_instance() as watcher_charm:
watcher_charm.upgrade_if_available(args)
@reactive.when('shared-db.available')
@reactive.when('identity-service.available')
@reactive.when('amqp.available')

View File

@ -40,6 +40,7 @@ class TestRegisteredHooks(test_utils.TestRegisteredHooks):
'cluster_connected': ('ha.connected',),
},
'when_not': {
'auto_upgrade': ('is-update-status-hook',),
'init_db': ('db.synced',),
}
}
@ -60,6 +61,12 @@ class TestWatcherHandlers(test_utils.PatchHelper):
self.watcher_charm)
self.provide_charm_instance().__exit__.return_value = None
def test_auto_upgrade(self):
handlers.auto_upgrade('arg1', 'arg2')
self.watcher_charm.upgrade_if_available.assert_called_once_with(
('arg1', 'arg2'))
def test_render_config(self):
self.patch_object(handlers.reactive, 'set_state')
handlers.render_config('arg1', 'arg2')